diff options
Diffstat (limited to 'WebKit/chromium')
112 files changed, 6645 insertions, 439 deletions
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog index 97b361a..24fa84d 100644 --- a/WebKit/chromium/ChangeLog +++ b/WebKit/chromium/ChangeLog @@ -1,3 +1,1358 @@ +<<<<<<< HEAD +======= +2010-01-31 Kent Tamura <tkent@chromium.org> + + Reviewed by Jeremy Orlow. + + [Chromium] Fix a bug that a selected word is not recognized as a + spell-check source. + https://bugs.webkit.org/show_bug.cgi?id=33660 + + * src/ContextMenuClientImpl.cpp: + (WebKit::isASingleWord): Use wordBreakIterator(), and correctly check + the return value of textBreakNext(). + +2010-01-29 Jeremy Orlow <jorlow@chromium.org> + + Reviewed by Dimitri Glazkov. + + A first step towards the Indexed Database API + https://bugs.webkit.org/show_bug.cgi?id=34342 + + Add runtime enable support for Indexed Database API. + + * features.gypi: + * public/WebRuntimeFeatures.h: + * src/WebRuntimeFeatures.cpp: + (WebKit::WebRuntimeFeatures::enableIndexedDatabase): + (WebKit::WebRuntimeFeatures::isIndexedDatabaseEnabled): + +2010-01-29 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + Add API methods for loading inspector utility scripts. + + https://bugs.webkit.org/show_bug.cgi?id=34326 + + * public/WebDevToolsAgentClient.h: + (WebKit::WebDevToolsAgentClient::injectedScriptSource): + (WebKit::WebDevToolsAgentClient::injectedScriptDispatcherSource): + +2010-01-29 Darin Fisher <darin@chromium.org> + + Reviewed by Adam Barth. + + Add FrameLoaderClient::allowImages method to allow the client to + overrule image loading policy on a per frame basis. + + https://bugs.webkit.org/show_bug.cgi?id=34225 + + * public/WebFrameClient.h: + (WebKit::WebFrameClient::allowImages): + * public/WebSettings.h: + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::allowImages): + * src/FrameLoaderClientImpl.h: + * src/WebSettingsImpl.cpp: + (WebKit::WebSettingsImpl::setImagesEnabled): + * src/WebSettingsImpl.h: + +2010-01-28 Jeremy Orlow <jorlow@chromium.org> + + Reviewed by Darin Fisher. + + StorageNamespaceProxy::copy() should be a no-op + https://bugs.webkit.org/show_bug.cgi?id=34298 + + The comment in the code should make clear why. + + * public/WebViewClient.h: + * src/StorageNamespaceProxy.cpp: + (WebCore::StorageNamespaceProxy::copy): + +2010-01-28 Michael Nordman <michaeln@google.com> + + Reviewed by Alexey Proskuryakov. + + ApplicationCache events should be deferred until after Document onload has fired. + https://bugs.webkit.org/show_bug.cgi?id=29690 + + * src/ApplicationCacheHost.cpp: + (WebCore::ApplicationCacheHost::ApplicationCacheHost): Initialize m_isDeferringEvents to true. + (WebCore::ApplicationCacheHost::notifyDOMApplicationCache): Depending, defer or raise the event. + (WebCore::ApplicationCacheHost::stopDeferringEvents): Raise any deferred events and reset the flag. + +2010-01-27 Aaron Boodman <aa@chromium.org> + + Reviewed by Darin Adler. + + Send full URL and application id of requesting context to Chromium + when checking notification permissions. + + https://bugs.webkit.org/show_bug.cgi?id=34238 + + * public/WebDocument.h: + * src/WebDocument.cpp: + (WebKit::WebDocument::applicationID): + Implement applicationID() method. + + * public/WebNotificationPresenter.h: + * src/NotificationPresenterImpl.cpp: + (WebKit::NotificationPresenterImpl::checkPermission): + * src/NotificationPresenterImpl.h: + Send applicationID and full URL through to Chromium. + +2010-01-27 Darin Fisher <darin@chromium.org> + + Reviewed by Pavel Feldman. + + Expose HistoryItem::documentSequenceNumber + https://bugs.webkit.org/show_bug.cgi?id=34243 + + * public/WebHistoryItem.h: + * src/WebHistoryItem.cpp: + (WebKit::WebHistoryItem::documentSequenceNumber): + (WebKit::WebHistoryItem::setDocumentSequenceNumber): + +2010-01-26 Darin Fisher <darin@chromium.org> + + Reviewed by David Levin. + + Add methods to support running a nested modal loop outside of WebKit. + https://bugs.webkit.org/show_bug.cgi?id=34199 + + * public/WebView.h: + * src/WebViewImpl.cpp: + (WebKit::WebView::willEnterModalLoop): Create PageGroupLoadDeferrer + (WebKit::WebView::didExitModalLoop): Destroy PageGroupLoadDeferrer + +2010-01-27 Darin Fisher <darin@chromium.org> + + Reviewed by Dimitri Glazkov. + + Adding missing WebMutationEvent.cpp file to fix build bustage. + https://bugs.webkit.org/show_bug.cgi?id=33882 + + * public/WebMutationEvent.h: Remove unnecessary constructor. + * src/WebEvent.cpp: Remove unnecessary include of WebMutationEvent.h. + * src/WebMutationEvent.cpp: Added. + +2010-01-27 Jay Campan <jcampan@google.com> + + Reviewed by Darin Fisher. + + Adding EventListeners to the chromium API. + + https://bugs.webkit.org/show_bug.cgi?id=33882 + + * WebKit.gyp: + * public/WebEvent.h: Added. + * public/WebEventListener.h: Added. + * public/WebMutationEvent.h: Added. + * public/WebNode.h: + * public/WebString.h: + (WebKit::operator==): + (WebKit::operator!=): + * src/EventListenerWrapper.cpp: Added. + * src/EventListenerWrapper.h: Added. + * src/WebEvent.cpp: Added. + * src/WebEventListener.cpp: Added. + * src/WebEventListenerPrivate.cpp: Added. + * src/WebEventListenerPrivate.h: Added. + * src/WebNode.cpp: + (WebKit::WebNode::addEventListener): + (WebKit::WebNode::removeEventListener): + * src/WebString.cpp: + (WebKit::WebString::equals): + +2010-01-26 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Darin Fisher. + + Add KeyboardTest to WebKit API tests + https://bugs.webkit.org/show_bug.cgi?id=34178 + + * WebKit.gyp: + * tests/KeyboardTest.cpp: Added. + +2010-01-22 Jeremy Orlow <jorlow@chromium.org> + + Reviewed by Darin Adler. + + Make storage events match the spec. + https://bugs.webkit.org/show_bug.cgi?id=30546 + + Update the storageEvent algorithm to match the change in WebCore. + + * src/StorageAreaProxy.cpp: + (WebCore::StorageAreaProxy::storageEvent): + +2010-01-22 Elliot Glaysher <erg@chromium.org> + + Reviewed by David Levin. + + Chromium: theme selection colors to match gtk theme + Add functions to RenderThemeChromiumLinux to change the selection color + according to the current GTK+ theme. + + Since the change is to the Chromium WebKit API layer, testing is done + in Chromium's test shell (see Chromium side of this patch: + http://codereview.chromium.org/554004) + + https://bugs.webkit.org/show_bug.cgi?id=33921 + + * public/WebView.h: Adds interface to change the selection colors + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::setSelectionColors): Implements new interface. + * src/WebViewImpl.h: + +2010-01-22 Steve VanDeBogart <vandebo@chromium.org> + + Reviewed by David Levin. + + Middle clicking the main scroll bars should not trigger a paste event + in Linux chromium. + https://bugs.webkit.org/show_bug.cgi?id=33062 + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::mouseUp): + +2010-01-22 Albert J. Wong <ajwong@chromium.org> + + Not reviewed. backout. + + Backout r53705. + Causes ui_tests to timeout, and browser_tests to fail with + TestConnectToBadPort and WindowOpenInvalidExtension. + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage): + (WebKit::FrameLoaderClientImpl::postProgressStartedNotification): + (WebKit::FrameLoaderClientImpl::postProgressFinishedNotification): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::WebViewImpl): + * src/WebViewImpl.h: + +2010-01-22 Peter Kasting <pkasting@google.com> + + Not reviewed, backout. + + Back out r52673, which caused several regressions. + https://bugs.webkit.org/show_bug.cgi?id=32533 + + * src/AutocompletePopupMenuClient.cpp: + (WebKit::AutocompletePopupMenuClient::initialize): + (WebKit::AutocompletePopupMenuClient::popupDidHide): + (WebKit::AutocompletePopupMenuClient::setTextFromItem): + * src/AutocompletePopupMenuClient.h: + +2010-01-21 Jeremy Orlow <jorlow@chromium.org> + + Reviewed by Darin Fisher. + + The Chromium WebKit API needs to expose storage event related data + https://bugs.webkit.org/show_bug.cgi?id=33985 + + setItem and removeItem on WebStorageArea need to expose what the previous + value was for the key being modified. Clear needs to return whether it + actually cleared anything. + + * public/WebStorageArea.h: + (WebKit::WebStorageArea::setItem): + (WebKit::WebStorageArea::removeItem): + (WebKit::WebStorageArea::clear): + * src/StorageAreaProxy.cpp: + (WebCore::StorageAreaProxy::StorageAreaProxy): + (WebCore::StorageAreaProxy::setItem): + (WebCore::StorageAreaProxy::removeItem): + (WebCore::StorageAreaProxy::clear): + (WebCore::StorageAreaProxy::storageEvent): + * src/StorageAreaProxy.h: + * src/StorageNamespaceProxy.cpp: + (WebCore::StorageNamespace::localStorageNamespace): + (WebCore::StorageNamespace::sessionStorageNamespace): + (WebCore::StorageNamespaceProxy::StorageNamespaceProxy): + (WebCore::StorageNamespaceProxy::copy): + (WebCore::StorageNamespaceProxy::storageArea): + * src/StorageNamespaceProxy.h: + * src/WebStorageAreaImpl.cpp: + (WebKit::WebStorageAreaImpl::setItem): + (WebKit::WebStorageAreaImpl::removeItem): + (WebKit::WebStorageAreaImpl::clear): + * src/WebStorageAreaImpl.h: + +2010-01-21 Darin Fisher <darin@chromium.org> + + Reviewed by David Levin. + + [Chromium] spurious WebViewClient::didStopLoading if changing + location.hash while a subframe is still loading + + https://bugs.webkit.org/show_bug.cgi?id=33884 + + This is a refinement of http://trac.webkit.org/changeset/51548 + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage): + (WebKit::FrameLoaderClientImpl::postProgressStartedNotification): + (WebKit::FrameLoaderClientImpl::postProgressFinishedNotification): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::WebViewImpl): + (WebKit::WebViewImpl::didStartLoading): + (WebKit::WebViewImpl::didStopLoading): + * src/WebViewImpl.h: + +2010-01-21 Adam Barth <abarth@webkit.org> + + Unreviewed. Added a blank line requested by the great an powerful + fishd. + + * public/WebFrameClient.h: + +2010-01-21 Adam Barth <abarth@webkit.org> + + Reviewed by Eric Seidel. + + [chromium] Add allowPlugins callback to allow per-site enabling of plugins + https://bugs.webkit.org/show_bug.cgi?id=33974 + + Forward the new allowPlugins callback to WebKitClient so that it can + make the policy decision. + + * public/WebFrameClient.h: + (WebKit::WebFrameClient::allowPlugins): + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::allowJavaScript): + (WebKit::FrameLoaderClientImpl::allowPlugins): + * src/FrameLoaderClientImpl.h: + +2010-01-21 James Robinson <jamesr@chromium.org> + + Reviewed by Darin Fisher. + + Bumps the refcount when WebNode::toElement/toConstElement are called. + https://bugs.webkit.org/show_bug.cgi?id=33977 + + Ensures that when a wrapper around a WebNode is create via the + toElement() or toConstElement() calls that the refcount on the WebNode + is increased, by forcing a call to WebNode::assign(). This is needed + so that the following code: + { + WebNode n = someNode(); + WebElement e = n.toElement<WebElement>(); + } + does not decrease the overall refcount on the Node that someNode() + returns. + + This caused crashes in the 'Save page as..' feature. + + * public/WebNode.h: + (WebKit::WebNode::toElement): + (WebKit::WebNode::toConstElement): + +2010-01-21 Michael Nordman <michaeln@google.com> + + Reviewed by Darin Fisher. + + Adds WebKit::WebDataSource::applicationCacheHost() to the API. + https://bugs.webkit.org/show_bug.cgi?id=33880 + + * WebKit.gyp: + * public/WebDataSource.h: + * src/ApplicationCacheHost.cpp: + * src/ApplicationCacheHostInternal.h: Copied from WebKit/chromium/src/ApplicationCacheHost.cpp. + (WebCore::ApplicationCacheHostInternal::notifyEventListener): + (WebCore::ApplicationCacheHostInternal::toWebApplicationCacheHost): + * src/WebDataSourceImpl.cpp: + (WebKit::WebDataSourceImpl::applicationCacheHost): + * src/WebDataSourceImpl.h: + +2010-01-21 Eric Uhrhane <ericu@chromium.org> + + Reviewed by Dmitry Titov. + + Add changes missing from r53595, without which Chromium has no database. + + https://bugs.webkit.org/show_bug.cgi?id=33966 + + No new tests - fixes database layout tests in Chromium. + + * src/WebRuntimeFeatures.cpp: + (WebKit::WebRuntimeFeatures::enableDatabase): + (WebKit::WebRuntimeFeatures::isDatabaseEnabled): + +2010-01-21 Kenneth Russell <kbr@google.com> + + Reviewed by Oliver Hunt. + + [Chromium] Implement texSubImage2D taking WebGLArray + https://bugs.webkit.org/show_bug.cgi?id=33932 + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3D::texSubImage2D): + +2010-01-20 Vitaly Repeshko <vitalyr@chromium.org> + + Reviewed by Pavel Feldman. + + [V8] Support SerializedScriptValue. + https://bugs.webkit.org/show_bug.cgi?id=32920 + http://crbug.com/30620 + + Updated uses of SerializedScriptValue: + * src/PlatformMessagePortChannel.cpp: + (WebCore::PlatformMessagePortChannel::postMessageToRemote): + (WebCore::PlatformMessagePortChannel::tryGetMessageFromRemote): + * src/WebWorkerBase.cpp: + (WebKit::WebWorkerBase::postMessageToWorkerObject): + * src/WebWorkerClientImpl.cpp: + (WebKit::WebWorkerClientImpl::postMessageToWorkerContext): + (WebKit::WebWorkerClientImpl::postMessageToWorkerObjectTask): + * src/WebWorkerImpl.cpp: + (WebKit::WebWorkerImpl::postMessageToWorkerContextTask): + +2010-01-20 Shinichiro Hamaji <hamaji@chromium.org> + + Reviewed by Darin Fisher. + + [Chromium] computePageRectsForFrame seems to be unnecessary + https://bugs.webkit.org/show_bug.cgi?id=33881 + + * src/WebFrameImpl.cpp: Stop including FrameChromium.h + +2010-01-19 Jon Honeycutt <jhoneycutt@apple.com> + + Chromium build fix. + + * public/WebAccessibilityRole.h: + (WebKit::): + Correct enum names. + + * src/LocalizedStrings.cpp: + (WebCore::AXMenuListPopupActionVerb): + Stubbed. + (WebCore::AXMenuListActionVerb): + Stubbed. + +2010-01-19 Jon Honeycutt <jhoneycutt@apple.com> + + Chromium build fix. + + * public/WebAccessibilityRole.h: + (WebKit::): + + * src/AssertMatchingEnums.cpp: + +2010-01-18 Jonathan Dixon <joth@chromium.org> + + Reviewed by Adam Barth. + + Add support for enabling navigator.geolocation at runtime in the V8 bindings. + Adds the [EnabledAtRuntime] modifier to the navigator IDL. + https://bugs.webkit.org/show_bug.cgi?id=33467 + + * public/WebRuntimeFeatures.h: + * src/WebRuntimeFeatures.cpp: + (WebKit::WebRuntimeFeatures::enableGeolocation): + (WebKit::WebRuntimeFeatures::isGeolocationEnabled): + +2010-01-17 Kent Tamura <tkent@chromium.org> + + Reviewed by Shinichiro Hamaji. + + [Chromium] Remove an old runFileChooser() method. + https://bugs.webkit.org/show_bug.cgi?id=33778 + + Chromium code switched to new runFileChooser() introduced by + r53269. The old one is not needed anymore. + + * public/WebViewClient.h: + * src/ChromeClientImpl.cpp: + (WebKit::ChromeClientImpl::runOpenPanel): + +2010-01-15 Eric Seidel <eric@webkit.org> + + No review, rolling out r53344. + http://trac.webkit.org/changeset/53344 + https://bugs.webkit.org/show_bug.cgi?id=32920 + + Broke the Chromium Mac builder. + + * src/PlatformMessagePortChannel.cpp: + (WebCore::PlatformMessagePortChannel::postMessageToRemote): + (WebCore::PlatformMessagePortChannel::tryGetMessageFromRemote): + * src/WebWorkerBase.cpp: + (WebKit::WebWorkerBase::postMessageToWorkerObject): + * src/WebWorkerClientImpl.cpp: + (WebKit::WebWorkerClientImpl::postMessageToWorkerContext): + (WebKit::WebWorkerClientImpl::postMessageToWorkerObjectTask): + * src/WebWorkerImpl.cpp: + (WebKit::WebWorkerImpl::postMessageToWorkerContextTask): + +2010-01-15 Vitaly Repeshko <vitalyr@chromium.org> + + Reviewed by David Levin. + + [V8] Support SerializedScriptValue. + https://bugs.webkit.org/show_bug.cgi?id=32920 + http://crbug.com/30620 + + Updated uses of SerializedScriptValue: + * src/PlatformMessagePortChannel.cpp: + (WebCore::PlatformMessagePortChannel::postMessageToRemote): + (WebCore::PlatformMessagePortChannel::tryGetMessageFromRemote): + * src/WebWorkerBase.cpp: + (WebKit::WebWorkerBase::postMessageToWorkerObject): + * src/WebWorkerClientImpl.cpp: + (WebKit::WebWorkerClientImpl::postMessageToWorkerContext): + (WebKit::WebWorkerClientImpl::postMessageToWorkerObjectTask): + * src/WebWorkerImpl.cpp: + (WebKit::WebWorkerImpl::postMessageToWorkerContextTask): + +2010-01-14 Jeremy Orlow <jorlow@chromium.org> + + Reviewed by Oliver Hunt. + + [Chromium] Forgot to adopt a ref counted object in StorageNamespaceProxy + https://bugs.webkit.org/show_bug.cgi?id=33704 + + * src/StorageNamespaceProxy.cpp: + (WebCore::StorageNamespace::localStorageNamespace): + (WebCore::StorageNamespace::sessionStorageNamespace): + +2010-01-14 Marcus Bulach <bulach@chromium.org> + + Reviewed by Dimitri Glazkov. + + Adds WebKit::WebSecurityOrigin::createFromDatabaseIdentifier. + https://bugs.webkit.org/show_bug.cgi?id=33648 + + * public/WebSecurityOrigin.h: + * src/WebSecurityOrigin.cpp: + (WebKit::WebSecurityOrigin::createFromDatabaseIdentifier): + +2010-01-14 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Adam Roben. + + Drag and Drop source/destination code needs cleanup. + <https://bugs.webkit.org/show_bug.cgi?id=33691>. + + Update to new way of calling sourceOperation. + + * src/DragClientImpl.cpp: + (WebKit::DragClientImpl::startDrag): + +2010-01-14 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + Remove references to V8DOMWrapper::convertToNative*(). + + https://bugs.webkit.org/show_bug.cgi?id=33677 + + * src/WebBindings.cpp: + (WebKit::getDragDataImpl): + (WebKit::getRangeImpl): + +2010-01-14 Kent Tamura <tkent@chromium.org> + + Reviewed by Darin Fisher. + + Introduce WebFileChooserParams to convey parameters for + WebViewClient::runFileChooser(), and add new parameters to it. + https://bugs.webkit.org/show_bug.cgi?id=32473 + + The new parameters are + - selected file names + - "accept" attribute value + + * WebKit.gyp: Add WebFileChooserParams.h + * public/WebFileChooserParams.h: Added. + * public/WebViewClient.h: + (WebKit::WebViewClient::runFileChooser): + Add runFileChooser() with WebFileChooserParams, and mark the old one deprecated. + * src/ChromeClientImpl.cpp: + (WebKit::ChromeClientImpl::runOpenPanel): + Call the new runFileChooser() first, then call the old + runFileChooser() if the new one failed. + +2010-01-13 Kenneth Russell <kbr@google.com> + + Reviewed by Oliver Hunt. + + Need to implement WebGLContextAttributes + https://bugs.webkit.org/show_bug.cgi?id=31169 + + Added the WebGLContextAttributes class and custom JavaScript + bindings to accept a native object as the second argument to + getContext("experimental-webgl") per the WebGL specification. + Added GraphicsContext3D::Attributes struct to isolate DOM and + graphics layers. Added getContextAttributes() to + WebGLRenderingContext. Added test case ensuring that context + attributes can be passed down and returned. Tested in Safari and + Chromium. The attributes will be hooked up to the creation of the + OpenGL context in bug 33416. + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): + (WebCore::GraphicsContext3DInternal::getContextAttributes): + (WebCore::GraphicsContext3D::create): + (WebCore::GraphicsContext3D::GraphicsContext3D): + (WebCore::GraphicsContext3D::getContextAttributes): + +2010-01-13 Jon Honeycutt <jhoneycutt@apple.com> + + MSAA: selected, selectable, extended selectable, and multiple + selectable states are not reported + + https://bugs.webkit.org/show_bug.cgi?id=33574 + <rdar://problem/7536826> + + Reviewed by Darin Adler. + + * public/WebAccessibilityObject.h: + Update for WebCore::AccessibilityObject function rename. + + * src/WebAccessibilityObject.cpp: + (WebKit::WebAccessibilityObject::isMultiSelectable): + Ditto. + +2010-01-13 Jeremy Orlow <jorlow@chromium.org> + + Reviewed by Darin Fisher. + + [Chromium] Move getSessionStorageNamespace from WebKitClient to WebViewClient + https://bugs.webkit.org/show_bug.cgi?id=33492 + + * public/WebKitClient.h: + * public/WebViewClient.h: + (WebKit::WebViewClient::createSessionStorageNamespace): + * src/StorageNamespaceProxy.cpp: + (WebCore::StorageNamespace::sessionStorageNamespace): + +2010-01-13 Jeremy Orlow <jorlow@chromium.org> + + No reviewer. More or less a build fix. My 53180 broke some + stuff on the Chromium port so I'm reverting. + + * public/WebKitClient.h: + * public/WebViewClient.h: + * src/StorageNamespaceProxy.cpp: + (WebCore::StorageNamespace::sessionStorageNamespace): + +2010-01-11 Jeremy Orlow <jorlow@chromium.org> + + Reviewed by Darin Fisher. + + [Chromium] Move getSessionStorageNamespace from WebKitClient to WebViewClient + https://bugs.webkit.org/show_bug.cgi?id=33492 + + * public/WebKitClient.h: + * public/WebViewClient.h: + (WebKit::WebViewClient::getSessionStorageNamespace): + * src/StorageNamespaceProxy.cpp: + (WebCore::StorageNamespace::sessionStorageNamespace): + +2010-01-11 Darin Fisher <darin@chromium.org> + + Reviewed by Dimitri Glazkov. + + [Chromium] Re-work webkit_unit_tests so that WebKit is initialized only once + https://bugs.webkit.org/show_bug.cgi?id=33504 + + * WebKit.gyp: + * tests/KURLTest.cpp: + (ComponentCase::TEST): + * tests/RunAllTests.cpp: Added. + (main): + * tests/WebKitTest.h: Removed. + +2010-01-09 Adam Barth <abarth@webkit.org> + + Reviewed by Darin Adler. + + ScriptController::isEnabled needs to be renamed + https://bugs.webkit.org/show_bug.cgi?id=32063 + + Rename ScriptController::isEnabled to + ScriptController::canExecuteScripts. + + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::bindToWindowObject): + +2010-01-08 Daniel Bates <dbates@webkit.org> + + Reviewed by Adam Barth. + + https://bugs.webkit.org/show_bug.cgi?id=33417 + + Cleans up style errors exposed by the patch for bug #33198. + + No functionality was changed. So, no new tests. + + * src/GraphicsContext3D.cpp: + +2010-01-08 Darin Fisher <darin@chromium.org> + + Reviewed by Dimitri Glazkov. + + [Chromium] Upstream webkit unit tests from the chromium repository + https://bugs.webkit.org/show_bug.cgi?id=33351 + + This adds one such test (for KURL) and sets up the test framework. + + Switch WebKit to build a static library on all platforms. Add a + webkit_unit_tests executable target that runs the unit tests and also + ensures that we don't have any missing symbols (a function that WebKit + as a shared library used to serve). + + Changes chromium_src_dir to ../../WebKit/chromium to match how + WebCore.gyp defines that variable. + + * WebKit.gyp: + * public/WebKitClient.h: + (WebKit::WebKitClient::getPluginList): Remove bogus trailing semi-colon. + (WebKit::WebKitClient::decrementStatsCounter): Remove bogus trailing semi-colon. + (WebKit::WebKitClient::incrementStatsCounter): Remove bogus trailing semi-colon. + (WebKit::WebKitClient::traceEventBegin): Remove bogus trailing semi-colon. + (WebKit::WebKitClient::traceEventEnd): Remove bogus trailing semi-colon. + (WebKit::WebKitClient::histogramCounts): Remove bogus trailing semi-colon. + * tests: Added. + * tests/KURLTest.cpp: Added. + * tests/WebKitTest.h: Added. + +2010-01-07 Mike Belshe <mbelshe@chromium.org> + + Reviewed by Darin Adler. + + Fix Spdy casing to match style guide. + + https://bugs.webkit.org/show_bug.cgi?id=33326 + + * public/WebURLResponse.h: + * src/WebURLResponse.cpp: + (WebKit::WebURLResponse::wasFetchedViaSPDY): + (WebKit::WebURLResponse::setWasFetchedViaSPDY): + +2010-01-07 Daniel Bates <dbates@rim.com> + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=32987 + + Added ENABLE_XHTMLMP flag. Disabled by default. + + * features.gypi: + +2010-01-07 Adam Barth <abarth@webkit.org> + + No review, rolling out r52847. + http://trac.webkit.org/changeset/52847 + https://bugs.webkit.org/show_bug.cgi?id=33232 + + Might have caused a perf regression. + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::detachedFromParent3): + +2010-01-06 Mike Belshe <mike@belshe.com> + + Add a flag to the ResourceResponse for tracking if a request was + fetched via SPDY. This is plumbed through so that we can inform + a webpage via JavaScript if it was fecthed via the experimental + SPDY protocol. + + https://bugs.webkit.org/show_bug.cgi?id=33186 + + * public/WebURLResponse.h: + * src/WebURLResponse.cpp: + (WebKit::WebURLResponse::wasFetchedViaSpdy): + (WebKit::WebURLResponse::setWasFetchedViaSpdy): + +2010-01-06 Darin Fisher <darin@chromium.org> + + Fix release build bustage. + + * src/WebKit.cpp: Need to include Logging.h + +2010-01-05 Darin Fisher <darin@chromium.org> + + Reviewed by Adam Barth. + + [Chromium] Expose more APIs to eliminate WebCore usage in Chromium. + https://bugs.webkit.org/show_bug.cgi?id=33249 + + * WebKit.gyp: + * public/WebFrame.h: + * public/WebGlyphCache.h: Added. + * public/WebKit.h: + * src/WebFrameImpl.cpp: + (WebKit::WebFrame::instanceCount): + (WebKit::WebFrameImpl::WebFrameImpl): + (WebKit::WebFrameImpl::~WebFrameImpl): + * src/WebFrameImpl.h: + * src/WebGlyphCache.cpp: Added. + (WebKit::WebGlyphCache::pageCount): + * src/WebKit.cpp: + (WebKit::enableLogChannel): + +2010-01-05 Adam Barth <abarth@webkit.org> + + Reviewed by Dimitri Glazkov. + + [v8] Move V8DOMWindowShell to ScriptController + https://bugs.webkit.org/show_bug.cgi?id=33232 + + Update FrameLoaderClientImpl.cpp to call clearForClose on + ScriptController instead of on V8Proxy. + + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::detachedFromParent3): + +2010-01-05 Rachel Petterson <rlp@google.com> + + Reviewed by Adam Barth. + + Matches the texImage2D and texSubImage2D functions to their + declarations. Elminates uncessary versions of those functions. + https://bugs.webkit.org/show_bug.cgi?id=31562 + Also bug: https://bugs.webkit.org/show_bug.cgi?id=31493 + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3D::texImage2D): + (WebCore::GraphicsContext3D::texSubImage2D): + +2010-01-04 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Darin Fisher. + + Reorganize, document and rename OS() platform macros. + https://bugs.webkit.org/show_bug.cgi?id=33198 + + Adapt to name changes. + + * src/ChromiumBridge.cpp: + * src/EditorClientImpl.cpp: + (WebKit::EditorClientImpl::isSelectTrailingWhitespaceEnabled): + (WebKit::): + (WebKit::EditorClientImpl::handleEditingKeyboardEvent): + * src/FrameLoaderClientImpl.cpp: + (WebKit::FrameLoaderClientImpl::createPlugin): + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): + (WebCore::GraphicsContext3DInternal::~GraphicsContext3DInternal): + (WebCore::GraphicsContext3DInternal::makeContextCurrent): + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::selectionAsText): + (WebKit::WebFrameImpl::printPage): + * src/WebPluginContainerImpl.cpp: + (WebKit::WebPluginContainerImpl::handleMouseEvent): + (WebKit::WebPluginContainerImpl::handleKeyboardEvent): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::mouseDown): + (WebKit::WebViewImpl::mouseContextMenu): + (WebKit::WebViewImpl::mouseUp): + (WebKit::WebViewImpl::keyEvent): + (WebKit::WebViewImpl::sendContextMenuEvent): + (WebKit::WebViewImpl::setScrollbarColors): + (WebKit::WebViewImpl::navigationPolicyFromMouseEvent): + +2010-01-04 Darin Fisher <darin@chromium.org> + + Reviewed by Eric Seidel. + + [Chromium] Expose more DOM methods to support LayoutTests + https://bugs.webkit.org/show_bug.cgi?id=33185 + + * public/WebDocument.h: Adds documentElement method. + * public/WebElement.h: Adds innerText method. + * public/WebFrame.h: Adds renderTreeAsText and counterValueForElementById + methods, and fixes a few whitespace issues. + * src/WebDocument.cpp: + (WebKit::WebDocument::documentElement): + * src/WebElement.cpp: + (WebKit::WebElement::innerText): + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::clearName): + (WebKit::WebFrameImpl::renderTreeAsText): + (WebKit::WebFrameImpl::counterValueForElementById): + * src/WebFrameImpl.h: + +2010-01-04 Darin Fisher <darin@chromium.org> + + Fix Chromium build bustage. + + * src/WebAnimationControllerImpl.h: + +2010-01-04 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Darin Fisher. + + Adding WebAnimationController to chromium's WebKit API. + + https://bugs.webkit.org/show_bug.cgi?id=32870 + + * WebKit.gyp: + * public/WebAnimationController.h: Added. + (WebKit::WebAnimationController::~WebAnimationController): + * public/WebFrame.h: + * src/WebAnimationControllerImpl.cpp: Added. + (WebKit::WebAnimationControllerImpl::WebAnimationControllerImpl): + (WebKit::WebAnimationControllerImpl::pauseAnimationAtTime): + (WebKit::WebAnimationControllerImpl::pauseTransitionAtTime): + (WebKit::WebAnimationControllerImpl::numberOfActiveAnimations): + * src/WebAnimationControllerImpl.h: Added. + (WebKit::WebAnimationControllerImpl::~WebAnimationControllerImpl): + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::animationController): + (WebKit::WebFrameImpl::WebFrameImpl): + * src/WebFrameImpl.h: + +2010-01-04 Jay Campan <jcampan@google.com> + + Reviewed by Darin Fisher + + Adding more DOM API methods. They are needed for the upcoming + translate feature. + + * public/WebElement.h: + * public/WebNode.h: + * src/WebElement.cpp: + (WebKit::WebElement::tagName): + (WebKit::WebElement::setAttribute): + * src/WebNode.cpp: + (WebKit::WebNode::setNodeValue): + +2010-01-03 Adam Barth <abarth@webkit.org> + + Reviewed by Eric Seidel. + + [Chromium] Implement CookieJarChromium::cookiesEnabled + https://bugs.webkit.org/show_bug.cgi?id=33123 + + Call out to the webKitClient() to see if cookies are enabled. Also + remove some straggling references to policyURL! + + * public/WebKitClient.h: + (WebKit::WebKitClient::setCookies): + (WebKit::WebKitClient::cookies): + (WebKit::WebKitClient::rawCookies): + (WebKit::WebKitClient::cookiesEnabled): + * src/ChromiumBridge.cpp: + (WebCore::ChromiumBridge::cookiesEnabled): + +2010-01-03 Adam Barth <abarth@webkit.org> + + Reviewed by Eric Seidel. + + [Chromium] Remove evaluateInNewContext (it's useless) + https://bugs.webkit.org/show_bug.cgi?id=33068 + + This function has no clients and makes life complicated. Isolated + worlds won out over NewContext and there's not really any going back + now. + + * public/WebFrame.h: + * src/FrameLoaderClientImpl.h: + * src/WebFrameImpl.cpp: + * src/WebFrameImpl.h: + +2009-12-30 Darin Fisher <darin@chromium.org> + + Reviewed by David Levin. + + [Chromium] Delete ResourceRequest::securityInfo + https://bugs.webkit.org/show_bug.cgi?id=26847 + + * src/WebWorkerBase.cpp: + (WebKit::WebWorkerBase::initializeLoader): + +2009-12-30 Albert J. Wong <ajwong@chromium.org> + + Not reviewed. Trivial Chromium build fix. + + Add static_cast<unsigned>() to fix signed/unsigned comparison warning. + + * src/AutocompletePopupMenuClient.cpp: + (WebKit::AutocompletePopupMenuClient::selectionChanged): + +2009-12-30 Zelidrag Hornung <zelidrag@chromium.org> + + Reviewed by Dimitri Glazkov. + + Autocomplete in Chromium now offers suggestions within the input element as a user + a) types text that produces some autocomplete suggestions, and + b) scrolls through suggested values in the menu + The suggested value is rendered but not exposed through JS unti the + user makes the final selection. + + No new tests since this new functionality (autocomplete suggestions) + is intentionally hidden from everything else than renderer. + + * src/AutocompletePopupMenuClient.cpp: + (WebKit::AutocompletePopupMenuClient::initialize): + (WebKit::AutocompletePopupMenuClient::setInitialAutocompleteValue): + (WebKit::AutocompletePopupMenuClient::selectionChanged): + (WebKit::AutocompletePopupMenuClient::popupDidHide): + (WebKit::AutocompletePopupMenuClient::setTextFromItem): + (WebKit::AutocompletePopupMenuClient::resetLastFieldValue): + * src/AutocompletePopupMenuClient.h: + + +2009-12-28 Kinuko Yasuda <kinuko@chromium.org> + + Reviewed by Maciej Stachowiak. + + Fixed isKeypadEvent behavior for chromium/Mac to correctly report + keyLocation as DOM_KEY_LOCATION_NUMPAD for numeric pad key events. + https://bugs.webkit.org/show_bug.cgi?id=28247 + + Test: fast/events/keydown-numpad-keys.html + + * src/mac/WebInputEventFactory.mm: + (WebKit::isKeypadEvent): + +2009-12-22 Kenneth Russell <kbr@google.com> + + Reviewed by Eric Seidel. + + [Chromium] Garbage in transparent regions of images uploaded as textures + https://bugs.webkit.org/show_bug.cgi?id=32888 + + Test: fast/canvas/webgl/bug-32888.html (works in Safari / DumpRenderTree) + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3D::texImage2D): + +2009-12-22 Adam Langley <agl@google.com> + + Build fix: not reviewed. + + r52504 (https://bugs.webkit.org/show_bug.cgi?id=32845) broke the + Chromium build on Windows and Mac due to a misplaced #endif. The + buildbot didn't find the problem because it runs on Linux. + + Have verified this patch with the author of the above. + + * src/GraphicsContext3D.cpp: + +2009-12-22 Kenneth Russell <kbr@google.com> + + Reviewed by Eric Seidel. + + [Chromium] WebGL crashes intermittently on Linux + https://bugs.webkit.org/show_bug.cgi?id=32845 + + The dlclose'ing of libGL.so.1 and dlopen'ing of it each time a + GraphicsContext3D was created was occasionally causing it to be + re-mapped at a different base address. Since GLEW is not + re-initialized every time, primarily for performance reasons, its + cached function pointers were pointing to garbage. Stopped closing + and re-opening libGL.so.1 each time; now it is loaded lazily, when + the first 3D context is created. Also reused the X display + connection since the GLX routines' correctness might hinge upon it + not resulting in a change of GL implementation. + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3DInternal::GLConnection::chooseFBConfig): + (WebCore::GraphicsContext3DInternal::GLConnection::createNewContext): + (WebCore::GraphicsContext3DInternal::GLConnection::createPbuffer): + (WebCore::GraphicsContext3DInternal::GLConnection::destroyPbuffer): + (WebCore::GraphicsContext3DInternal::GLConnection::makeCurrent): + (WebCore::GraphicsContext3DInternal::GLConnection::destroyContext): + (WebCore::GraphicsContext3DInternal::GLConnection::getCurrentContext): + (WebCore::GraphicsContext3DInternal::GLConnection::GLConnection): + (WebCore::GraphicsContext3DInternal::GLConnection::tryLoad): + (WebCore::GraphicsContext3DInternal::GLConnection::create): + (WebCore::GraphicsContext3DInternal::GLConnection::~GLConnection): + (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): + (WebCore::GraphicsContext3DInternal::~GraphicsContext3DInternal): + (WebCore::GraphicsContext3DInternal::makeContextCurrent): + +2009-12-22 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Darin Fisher. + + autoComplete and getElementById methods for WebKit API + + https://bugs.webkit.org/show_bug.cgi?id=32866 + + * public/WebDocument.h: + * public/WebInputElement.h: + * src/WebDocument.cpp: + (WebKit::WebDocument::getElementById): + * src/WebInputElement.cpp: + (WebKit::WebInputElement::autoComplete): + +2009-12-18 Kenneth Russell <kbr@google.com> + + Reviewed by Darin Fisher. + + [Chromium] Eliminate redundant data copy in GraphicsContext3D readback + https://bugs.webkit.org/show_bug.cgi?id=32763 + + Eliminated useless creation of a CGBitmapContext and from there a + CGImage. Now create CGImage directly from data. Also changed + readPixels parameters and CGImage alpha info to try to avoid byte + swapping, and disabled interpolation when drawing the GL content. + Some test cases run twice as fast with these changes, though more + work is needed to achieve desired performance. + + No test case; performance optimization only. Ran WebGL demos from + Khronos site to verify changes. + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): + (WebCore::GraphicsContext3DInternal::~GraphicsContext3DInternal): + (WebCore::GraphicsContext3DInternal::reshape): + (WebCore::GraphicsContext3DInternal::beginPaint): + +2009-12-18 Peter Kasting <pkasting@google.com> + + Reviewed by Adam Barth. + + Chromium build fix + https://bugs.webkit.org/show_bug.cgi?id=32756 + + * public/WebAccessibilityRole.h: + (WebKit::): + * src/AssertMatchingEnums.cpp: + +2009-12-18 Adam Roben <aroben@apple.com> + + Chromium build fix + + * src/ChromiumBridge.cpp: + * src/WebPluginContainerImpl.cpp: + * src/WebViewImpl.cpp: + Added #includes. + +2009-12-17 Eric Seidel <eric@webkit.org> + + No review, rolling out r52291. + http://trac.webkit.org/changeset/52291 + https://bugs.webkit.org/show_bug.cgi?id=32618 + + Darin Fisher points out that this will likely break + the SSL security indicator in Chromium. Rolling out for now. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::WebViewImpl): + +2009-12-17 Alexander Pavlov <apavlov@chromium.org> + + Reviewed by Eric Seidel. + + Disable memory cache client calls so that a new identifier isn't created + for the same resource on reload. + + With the calls enabled, duplicate entries for cached resources are created + in the Web Inspector. Safari for Windows disables the calls near the point of the + Frame instance creation, and we just follow this for Chromium. + https://bugs.webkit.org/show_bug.cgi?id=32618 + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::WebViewImpl): + +2009-12-17 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Darin Fisher. + + Added WebPageSerializer to WebKit API and enriched the WebNode hierarchy to support + downstream unit-testing of serialization. + + WebPageSerializer was adapted from Chromium's dom_serializer, originally authored by Johnny Ding. + + https://bugs.webkit.org/show_bug.cgi?id=31737 + + * WebKit.gyp: + * public/WebDocument.h: Added. + (WebKit::WebDocument::WebDocument): + (WebKit::WebDocument::operator=): + (WebKit::WebDocument::assign): + * public/WebElement.h: + * public/WebFormElement.h: + (WebKit::WebFormElement::operator=): + * public/WebFrame.h: + * public/WebNode.h: + (WebKit::WebNode::): + (WebKit::WebNode::toConstElement): + * public/WebNodeCollection.h: Added. + (WebKit::WebNodeCollection::~WebNodeCollection): + (WebKit::WebNodeCollection::WebNodeCollection): + (WebKit::WebNodeCollection::operator=): + * public/WebNodeList.h: Added. + (WebKit::WebNodeList::~WebNodeList): + (WebKit::WebNodeList::WebNodeList): + (WebKit::WebNodeList::operator=): + * public/WebPageSerializer.h: Added. + * public/WebPageSerializerClient.h: Added. + (WebKit::WebPageSerializerClient::): + (WebKit::WebPageSerializerClient::WebPageSerializerClient): + (WebKit::WebPageSerializerClient::~WebPageSerializerClient): + * public/WebString.h: + * public/WebView.h: + * src/AssertMatchingEnums.cpp: + * src/DOMUtilitiesPrivate.cpp: + (WebKit::elementHasLegalLinkAttribute): + * src/DOMUtilitiesPrivate.h: + * src/WebDocument.cpp: Added. + (WebKit::WebDocument::WebDocument): + (WebKit::WebDocument::operator=): + (WebKit::WebDocument::operator WTF::PassRefPtr<Document>): + (WebKit::WebDocument::frame): + (WebKit::WebDocument::isHTMLDocument): + (WebKit::WebDocument::baseURL): + (WebKit::WebDocument::body): + (WebKit::WebDocument::head): + (WebKit::WebDocument::all): + (WebKit::WebDocument::completeURL): + * src/WebElement.cpp: + (WebKit::WebElement::hasTagName): + (WebKit::WebElement::hasAttribute): + (WebKit::WebElement::getAttribute): + * src/WebEntities.cpp: Added. + (WebKit::populateMap): + (WebKit::): + (WebKit::WebEntities::WebEntities): + (WebKit::WebEntities::entityNameByCode): + (WebKit::WebEntities::convertEntitiesInString): + * src/WebEntities.h: Added. + * src/WebFrameImpl.cpp: + (WebKit::WebFrame::fromFrameOwnerElement): + (WebKit::WebFrameImpl::encoding): + (WebKit::WebFrameImpl::document): + (WebKit::WebFrameImpl::fromFrameOwnerElement): + * src/WebFrameImpl.h: + * src/WebNode.cpp: + (WebKit::WebNode::nodeType): + (WebKit::WebNode::nodeValue): + (WebKit::WebNode::document): + (WebKit::WebNode::firstChild): + (WebKit::WebNode::lastChild): + (WebKit::WebNode::previousSibling): + (WebKit::WebNode::nextSibling): + (WebKit::WebNode::hasChildNodes): + (WebKit::WebNode::childNodes): + (WebKit::WebNode::createMarkup): + (WebKit::WebNode::isTextNode): + (WebKit::WebNode::isElementNode): + * src/WebNodeCollection.cpp: Added. + (WebKit::WebNodeCollection::reset): + (WebKit::WebNodeCollection::assign): + (WebKit::WebNodeCollection::WebNodeCollection): + (WebKit::WebNodeCollection::length): + (WebKit::WebNodeCollection::nextItem): + (WebKit::WebNodeCollection::firstItem): + * src/WebNodeList.cpp: Added. + (WebKit::WebNodeList::reset): + (WebKit::WebNodeList::assign): + (WebKit::WebNodeList::WebNodeList): + (WebKit::WebNodeList::length): + (WebKit::WebNodeList::item): + * src/WebPageSerializer.cpp: Added. + (WebKit::WebPageSerializer::serialize): + (WebKit::WebPageSerializer::generateMetaCharsetDeclaration): + (WebKit::WebPageSerializer::generateMarkOfTheWebDeclaration): + (WebKit::WebPageSerializer::generateBaseTagDeclaration): + * src/WebPageSerializerImpl.cpp: Added. + (WebKit::WebPageSerializerImpl::SerializeDomParam::SerializeDomParam): + (WebKit::WebPageSerializerImpl::preActionBeforeSerializeOpenTag): + (WebKit::WebPageSerializerImpl::postActionAfterSerializeOpenTag): + (WebKit::WebPageSerializerImpl::preActionBeforeSerializeEndTag): + (WebKit::WebPageSerializerImpl::postActionAfterSerializeEndTag): + (WebKit::WebPageSerializerImpl::saveHTMLContentToBuffer): + (WebKit::WebPageSerializerImpl::openTagToString): + (WebKit::WebPageSerializerImpl::endTagToString): + (WebKit::WebPageSerializerImpl::buildContentForNode): + (WebKit::WebPageSerializerImpl::WebPageSerializerImpl): + (WebKit::WebPageSerializerImpl::collectTargetFrames): + (WebKit::WebPageSerializerImpl::serialize): + * src/WebPageSerializerImpl.h: Added. + * src/WebString.cpp: + (WebKit::WebString::WebString): + (WebKit::WebString::operator=): + * src/WebViewImpl.cpp: + +2009-12-17 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by David Levin. + + Provide explicit implementation of 'non-template' WebVector<T>::operator= + + https://bugs.webkit.org/show_bug.cgi?id=32363 + + * public/WebVector.h: + +2009-12-16 Fumitoshi Ukai <ukai@chromium.org> + + Unreviewed, build fix. + + [Chromium] Add EditableTextRole to catch up with + http://trac.webkit.org/changeset/52233 + + * public/WebAccessibilityRole.h: + (WebKit::): Added WebAccessibilityRoleEditableText + * src/AssertMatchingEnums.cpp: Added matching compile assert. + +2009-12-15 Kenneth Russell <kbr@google.com> + + Reviewed by Darin Fisher. + + Don't allow default framebuffer to be mutated + https://bugs.webkit.org/show_bug.cgi?id=32391 + + * src/GraphicsContext3D.cpp: + (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): + (WebCore::GraphicsContext3DInternal::reshape): + (WebCore::GraphicsContext3DInternal::beginPaint): + (WebCore::GraphicsContext3DInternal::bindFramebuffer): + (WebCore::GraphicsContext3D::bindFramebuffer): + +2009-12-15 Dimitri Glazkov <dglazkov@chromium.org> + + Unreviewed, build fix. + + [Chromium] Add TreeGridRole to catch up with + http://trac.webkit.org/changeset/52159. + + * public/WebAccessibilityRole.h: + (WebKit::): Added WebAccessibilityRoleTreeGrid. + * src/AssertMatchingEnums.cpp: Added matching compile assert. + +2009-12-15 Jian Li <jianli@chromium.org> + + Reviewed by Dmitry Titov. + + Bug 31090 - [Chromium] Add DownloadURL format to Chromium clipboard. + https://bugs.webkit.org/show_bug.cgi?id=31090 + + The proposal to whatwg can be found here: + http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-August/022118.html + + * public/WebDragData.h: + * src/WebDragData.cpp: + (WebKit::WebDragData::downloadURL): + (WebKit::WebDragData::setDownloadURL): + +2009-12-14 Evan Stade <estade@chromium.org> + + Reviewed by Darin Fisher. + + https://bugs.webkit.org/show_bug.cgi?id=32347 + Chromium: Context menu launched by menu key has funky behavior + + Make the context menu's position depend on the selection only when an + editable field has focus. Also, don't send multiple context menu events + for a single keypress. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::keyEvent): + (WebKit::WebViewImpl::sendContextMenuEvent): + +>>>>>>> webkit.org at r54127 2009-12-13 Sam Weinig <sam@webkit.org> Reviewed by Dan Bernstein. @@ -13,6 +1368,54 @@ * src/WebViewImpl.cpp: (WebKit::WebViewImpl::WebViewImpl): +<<<<<<< HEAD +======= +2009-12-13 Charles Reis <creis@chromium.org> + + Reviewed by Adam Barth. + + Refactor some security code out of V8 bindings + https://bugs.webkit.org/show_bug.cgi?id=32326 + + * src/WebBindings.cpp: + (WebKit::getDragDataImpl): + +2009-12-11 Nate Chapin <japhet@chromium.org> + + Reviewed by Darin Fisher. + + Expose shouldHideReferrer() in WebSecurityPolicy. + + https://bugs.webkit.org/show_bug.cgi?id=32398 + + * public/WebSecurityPolicy.h: Add shouldHideReferrer(). + * src/WebSecurityPolicy.cpp: + (WebKit:: WebSecurityPolicy::shouldHideReferrer): Added. + +2009-12-11 Avi Drissman <avi@chromium.org> + + Reviewed by Darin Fisher. + + Tickmarks in the scrollbar are not cleared for non-main frames + https://bugs.webkit.org/show_bug.cgi?id=32385 + + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::stopFinding): + +2009-12-11 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + Remove obsolete message handling methods from WebDevTools* interfaces + + https://bugs.webkit.org/show_bug.cgi?id=32320 + + * public/WebDevToolsAgent.h: + * public/WebDevToolsAgentClient.h: + * public/WebDevToolsFrontend.h: + * public/WebDevToolsFrontendClient.h: + +>>>>>>> webkit.org at r54127 2009-12-10 Mike Belshe <mike@belshe.com> Unreviewed, build fix for chromium. diff --git a/WebKit/chromium/WebKit.gyp b/WebKit/chromium/WebKit.gyp index c41bf5b..3b5a17f 100644 --- a/WebKit/chromium/WebKit.gyp +++ b/WebKit/chromium/WebKit.gyp @@ -33,33 +33,23 @@ 'features.gypi', ], 'variables': { + 'webkit_target_type': 'static_library', 'conditions': [ # Location of the chromium src directory and target type is different # if webkit is built inside chromium or as standalone project. ['inside_chromium_build==0', { # Webkit is being built outside of the full chromium project. # e.g. via build-webkit --chromium - 'chromium_src_dir': '.', - # FIXME: To enable shared_library in linux all code (including - # dependencies) must be complied with -fPIC flag. That is - # pending on changes in gyp. - 'webkit_target_type': 'shared_library', + 'chromium_src_dir': '../../WebKit/chromium', },{ # WebKit is checked out in src/chromium/third_party/WebKit 'chromium_src_dir': '../../../..', - 'webkit_target_type': 'static_library', }], # We can't turn on warnings on Windows and Linux until we upstream the # WebKit API. ['OS=="mac"', { 'chromium_code': 1, }], - # FIXME: To enable shared_library in linux all code (including - # dependencies) must be complied with -fPIC flag. That is - # pending on changes in gyp. - ['OS=="linux" or OS=="freebsd"', { - 'webkit_target_type': 'static_library', - }], ], }, 'targets': [ @@ -86,6 +76,7 @@ 'public/WebAccessibilityCache.h', 'public/WebAccessibilityObject.h', 'public/WebAccessibilityRole.h', + 'public/WebAnimationController.h', 'public/WebApplicationCacheHost.h', 'public/WebApplicationCacheHostClient.h', 'public/WebBindings.h', @@ -112,15 +103,20 @@ 'public/WebDevToolsFrontend.h', 'public/WebDevToolsFrontendClient.h', 'public/WebDevToolsMessageData.h', + 'public/WebDocument.h', 'public/WebDragData.h', 'public/WebEditingAction.h', 'public/WebElement.h', + 'public/WebEvent.h', + 'public/WebEventListener.h', 'public/WebFileChooserCompletion.h', + 'public/WebFileChooserParams.h', 'public/WebFindOptions.h', 'public/WebFrame.h', 'public/WebFrameClient.h', 'public/WebFontCache.h', 'public/WebFormElement.h', + 'public/WebGlyphCache.h', 'public/WebHistoryItem.h', 'public/WebHTTPBody.h', 'public/WebImage.h', @@ -136,12 +132,17 @@ 'public/WebMessagePortChannel.h', 'public/WebMessagePortChannelClient.h', 'public/WebMimeRegistry.h', + 'public/WebMutationEvent.h', 'public/WebNavigationType.h', 'public/WebNode.h', + 'public/WebNodeCollection.h', + 'public/WebNodeList.h', 'public/WebNonCopyable.h', 'public/WebNotification.h', 'public/WebNotificationPresenter.h', 'public/WebNotificationPermissionCallback.h', + 'public/WebPageSerializer.h', + 'public/WebPageSerializerClient.h', 'public/WebPasswordAutocompleteListener.h', 'public/WebPasswordFormData.h', 'public/WebPlugin.h', @@ -192,6 +193,7 @@ 'public/win/WebScreenInfoFactory.h', 'public/win/WebScreenInfoFactory.h', 'src/ApplicationCacheHost.cpp', + 'src/ApplicationCacheHostInternal.h', 'src/AssertMatchingEnums.cpp', 'src/AutocompletePopupMenuClient.cpp', 'src/AutocompletePopupMenuClient.h', @@ -211,6 +213,8 @@ 'src/DragClientImpl.h', 'src/EditorClientImpl.cpp', 'src/EditorClientImpl.h', + 'src/EventListenerWrapper.cpp', + 'src/EventListenerWrapper.h', 'src/FrameLoaderClientImpl.cpp', 'src/FrameLoaderClientImpl.h', 'src/gtk/WebFontInfo.cpp', @@ -243,6 +247,8 @@ 'src/WebAccessibilityCacheImpl.cpp', 'src/WebAccessibilityCacheImpl.h', 'src/WebAccessibilityObject.cpp', + 'src/WebAnimationControllerImpl.cpp', + 'src/WebAnimationControllerImpl.h', 'src/WebBindings.cpp', 'src/WebCache.cpp', 'src/WebColor.cpp', @@ -253,14 +259,22 @@ 'src/WebDatabase.cpp', 'src/WebDataSourceImpl.cpp', 'src/WebDataSourceImpl.h', + 'src/WebDocument.cpp', 'src/WebDragData.cpp', 'src/WebElement.cpp', + 'src/WebEntities.cpp', + 'src/WebEntities.h', + 'src/WebEvent.cpp', + 'src/WebEventListener.cpp', + 'src/WebEventListenerPrivate.cpp', + 'src/WebEventListenerPrivate.h', 'src/WebFileChooserCompletionImpl.cpp', 'src/WebFileChooserCompletionImpl.h', 'src/WebFontCache.cpp', 'src/WebFormElement.cpp', 'src/WebFrameImpl.cpp', 'src/WebFrameImpl.h', + 'src/WebGlyphCache.cpp', 'src/WebHistoryItem.cpp', 'src/WebHTTPBody.cpp', 'src/WebImageCG.cpp', @@ -272,8 +286,14 @@ 'src/WebKit.cpp', 'src/WebMediaPlayerClientImpl.cpp', 'src/WebMediaPlayerClientImpl.h', + 'src/WebMutationEvent.cpp', 'src/WebNode.cpp', + 'src/WebNodeCollection.cpp', + 'src/WebNodeList.cpp', 'src/WebNotification.cpp', + 'src/WebPageSerializer.cpp', + 'src/WebPageSerializerImpl.cpp', + 'src/WebPageSerializerImpl.h', 'src/WebPasswordFormData.cpp', 'src/WebPasswordFormUtils.cpp', 'src/WebPasswordFormUtils.h', @@ -393,6 +413,27 @@ }], ], }, + { + 'target_name': 'webkit_unit_tests', + 'type': 'executable', + 'msvs_guid': '7CEFE800-8403-418A-AD6A-2D52C6FC3EAD', + 'dependencies': [ + 'webkit', + '../../WebCore/WebCore.gyp/WebCore.gyp:webcore', + '<(chromium_src_dir)/testing/gtest.gyp:gtest', + '<(chromium_src_dir)/base/base.gyp:base', + '<(chromium_src_dir)/base/base.gyp:base_i18n', + ], + 'include_dirs': [ + 'public', + 'src', + ], + 'sources': [ + 'tests/KeyboardTest.cpp', + 'tests/KURLTest.cpp', + 'tests/RunAllTests.cpp', + ], + }, ], # targets } diff --git a/WebKit/chromium/features.gypi b/WebKit/chromium/features.gypi index 8dd0d0d..da2386b 100644 --- a/WebKit/chromium/features.gypi +++ b/WebKit/chromium/features.gypi @@ -50,9 +50,11 @@ 'ENABLE_JAVASCRIPT_DEBUGGER=0', 'ENABLE_JSC_MULTIPLE_THREADS=0', 'ENABLE_ICONDATABASE=0', + 'ENABLE_INDEXED_DATABASE=1', 'ENABLE_NOTIFICATIONS=1', 'ENABLE_OPENTYPE_SANITIZER=1', 'ENABLE_ORIENTATION_EVENTS=0', + 'ENABLE_XHTMLMP=0', 'ENABLE_XSLT=1', 'ENABLE_XPATH=1', 'ENABLE_SHARED_WORKERS=1', diff --git a/WebKit/chromium/public/WebAccessibilityObject.h b/WebKit/chromium/public/WebAccessibilityObject.h index d32c548..f46c0d8 100644 --- a/WebKit/chromium/public/WebAccessibilityObject.h +++ b/WebKit/chromium/public/WebAccessibilityObject.h @@ -85,7 +85,7 @@ public: bool isEnabled() const; bool isHovered() const; bool isIndeterminate() const; - bool isMultiSelect() const; + bool isMultiSelectable() const; bool isOffScreen() const; bool isPasswordField() const; bool isPressed() const; diff --git a/WebKit/chromium/public/WebAccessibilityRole.h b/WebKit/chromium/public/WebAccessibilityRole.h index e836c56..ec041e0 100644 --- a/WebKit/chromium/public/WebAccessibilityRole.h +++ b/WebKit/chromium/public/WebAccessibilityRole.h @@ -106,8 +106,14 @@ enum WebAccessibilityRole { WebAccessibilityRoleTabList, WebAccessibilityRoleTabPanel, WebAccessibilityRoleTreeRole, + WebAccessibilityRoleTreeGrid, WebAccessibilityRoleTreeItemRole, WebAccessibilityRoleDirectory, + WebAccessibilityRoleEditableText, + + WebAccessibilityRoleListItem, + WebAccessibilityRoleMenuListPopup, + WebAccessibilityRoleMenuListOption, WebAccessibilityRoleLandmarkApplication, WebAccessibilityRoleLandmarkBanner, diff --git a/WebKit/chromium/public/WebAnimationController.h b/WebKit/chromium/public/WebAnimationController.h new file mode 100644 index 0000000..d727d70 --- /dev/null +++ b/WebKit/chromium/public/WebAnimationController.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebAnimationController_h +#define WebAnimationController_h + +#include "WebCommon.h" + +namespace WebKit { + +class WebElement; +class WebString; +class WebURL; + +// WebAnimationController can be used to control animations in a frame. It is +// owned by a WebFrame and its life span is bound to that WebFrame. +class WebAnimationController { +public: + WEBKIT_API virtual bool pauseAnimationAtTime(WebElement&, + const WebString& animationName, + double time) = 0; + WEBKIT_API virtual bool pauseTransitionAtTime(WebElement&, + const WebString& propertyName, + double time) = 0; + + WEBKIT_API virtual unsigned numberOfActiveAnimations() const = 0; +protected: + ~WebAnimationController() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDataSource.h b/WebKit/chromium/public/WebDataSource.h index 3a83341..1aa7a98 100644 --- a/WebKit/chromium/public/WebDataSource.h +++ b/WebKit/chromium/public/WebDataSource.h @@ -36,6 +36,7 @@ namespace WebKit { +class WebApplicationCacheHost; class WebString; class WebURL; class WebURLRequest; @@ -91,6 +92,9 @@ public: virtual ExtraData* extraData() const = 0; virtual void setExtraData(ExtraData*) = 0; + // The application cache host associated with this datasource. + virtual WebApplicationCacheHost* applicationCacheHost() = 0; + protected: ~WebDataSource() { } }; diff --git a/WebKit/chromium/public/WebDevToolsAgent.h b/WebKit/chromium/public/WebDevToolsAgent.h index 9c27628..e3b5186 100644 --- a/WebKit/chromium/public/WebDevToolsAgent.h +++ b/WebKit/chromium/public/WebDevToolsAgent.h @@ -55,12 +55,6 @@ public: virtual void didNavigate() = 0; - // TODO(32320): remove this method from API. - virtual void dispatchMessageFromFrontend(const WebString& className, - const WebString& methodName, - const WebString& param1, - const WebString& param2, - const WebString& param3) = 0; virtual void dispatchMessageFromFrontend(const WebDevToolsMessageData&) = 0; virtual void inspectElementAt(const WebPoint&) = 0; @@ -79,12 +73,6 @@ public: // Asynchronously request debugger to pause immediately. WEBKIT_API static void debuggerPauseScript(); - // TODO(32320): remove this method from API. - WEBKIT_API static bool dispatchMessageFromFrontendOnIOThread(const WebString& className, - const WebString& methodName, - const WebString& param1, - const WebString& param2, - const WebString& param3); WEBKIT_API static bool dispatchMessageFromFrontendOnIOThread(const WebDevToolsMessageData&); typedef void (*MessageLoopDispatchHandler)(); diff --git a/WebKit/chromium/public/WebDevToolsAgentClient.h b/WebKit/chromium/public/WebDevToolsAgentClient.h index ec51654..d78a6f1 100644 --- a/WebKit/chromium/public/WebDevToolsAgentClient.h +++ b/WebKit/chromium/public/WebDevToolsAgentClient.h @@ -31,6 +31,7 @@ #ifndef WebDevToolsAgentClient_h #define WebDevToolsAgentClient_h +#include "WebCString.h" #include "WebCommon.h" namespace WebKit { @@ -39,12 +40,6 @@ struct WebDevToolsMessageData; class WebDevToolsAgentClient { public: - // TODO(32320): remove this method from API. - virtual void sendMessageToFrontend(const WebString& className, - const WebString& methodName, - const WebString& param1, - const WebString& param2, - const WebString& param3) {} virtual void sendMessageToFrontend(const WebDevToolsMessageData&) { } // Invalidates widget which leads to the repaint. @@ -56,14 +51,11 @@ public: // Notifies host upon runtime feature being enabled/disabled. virtual void runtimeFeatureStateChanged(const WebString& feature, bool enabled) { } - // TODO(32320): remove this method from API. - WEBKIT_API static void sendMessageToFrontendOnIOThread(const WebString& className, - const WebString& methodName, - const WebString& param1, - const WebString& param2, - const WebString& param3); WEBKIT_API static void sendMessageToFrontendOnIOThread(const WebDevToolsMessageData&); + virtual WebCString injectedScriptSource() { return WebCString(); } + virtual WebCString injectedScriptDispatcherSource() { return WebCString(); } + protected: ~WebDevToolsAgentClient() { } }; diff --git a/WebKit/chromium/public/WebDevToolsFrontend.h b/WebKit/chromium/public/WebDevToolsFrontend.h index b7d7189..d95f35a 100644 --- a/WebKit/chromium/public/WebDevToolsFrontend.h +++ b/WebKit/chromium/public/WebDevToolsFrontend.h @@ -50,11 +50,6 @@ public: virtual ~WebDevToolsFrontend() {} - virtual void dispatchMessageFromAgent(const WebString& className, - const WebString& methodName, - const WebString& param1, - const WebString& param2, - const WebString& param3) = 0; virtual void dispatchMessageFromAgent(const WebDevToolsMessageData&) = 0; }; diff --git a/WebKit/chromium/public/WebDevToolsFrontendClient.h b/WebKit/chromium/public/WebDevToolsFrontendClient.h index 2f74a8c..6200709 100644 --- a/WebKit/chromium/public/WebDevToolsFrontendClient.h +++ b/WebKit/chromium/public/WebDevToolsFrontendClient.h @@ -40,11 +40,6 @@ class WebDevToolsFrontendClient { public: WebDevToolsFrontendClient() {} - virtual void sendMessageToAgent(const WebString& className, - const WebString& methodName, - const WebString& param1, - const WebString& param2, - const WebString& param3) {}; virtual void sendMessageToAgent(const WebDevToolsMessageData&) {}; virtual void sendDebuggerCommandToAgent(const WebString& command) {}; virtual void sendDebuggerPauseScript() {} diff --git a/WebKit/chromium/public/WebDocument.h b/WebKit/chromium/public/WebDocument.h new file mode 100644 index 0000000..e158c41 --- /dev/null +++ b/WebKit/chromium/public/WebDocument.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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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 WebDocument_h +#define WebDocument_h + +#include "WebNode.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class Document; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { +class WebElement; +class WebFrame; +class WebNodeCollection; +class WebString; +class WebURL; + +// Provides readonly access to some properties of a DOM document. +class WebDocument : public WebNode { +public: + WebDocument() { } + WebDocument(const WebDocument& e) : WebNode(e) { } + + WebDocument& operator=(const WebDocument& e) + { + WebNode::assign(e); + return *this; + } + void assign(const WebDocument& e) { WebNode::assign(e); } + + // Returns the frame the document belongs to or 0 if the document is frameless. + WEBKIT_API WebFrame* frame() const; + WEBKIT_API bool isHTMLDocument() const; + WEBKIT_API WebURL baseURL() const; + WEBKIT_API WebElement documentElement() const; + WEBKIT_API WebElement body() const; + WEBKIT_API WebElement head(); + WEBKIT_API WebNodeCollection all(); + WEBKIT_API WebURL completeURL(const WebString&) const; + WEBKIT_API WebElement getElementById(const WebString& id) const; + WEBKIT_API WebString applicationID() const; + +#if WEBKIT_IMPLEMENTATION + WebDocument(const WTF::PassRefPtr<WebCore::Document>&); + WebDocument& operator=(const WTF::PassRefPtr<WebCore::Document>&); + operator WTF::PassRefPtr<WebCore::Document>() const; +#endif +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebDragData.h b/WebKit/chromium/public/WebDragData.h index f7a165d..01582a9 100644 --- a/WebKit/chromium/public/WebDragData.h +++ b/WebKit/chromium/public/WebDragData.h @@ -72,6 +72,9 @@ public: WEBKIT_API WebString urlTitle() const; WEBKIT_API void setURLTitle(const WebString&); + WEBKIT_API WebURL downloadURL() const; + WEBKIT_API void setDownloadURL(const WebURL&); + WEBKIT_API WebString fileExtension() const; WEBKIT_API void setFileExtension(const WebString&); diff --git a/WebKit/chromium/public/WebElement.h b/WebKit/chromium/public/WebElement.h index d7a2cbf..20f6c9a 100644 --- a/WebKit/chromium/public/WebElement.h +++ b/WebKit/chromium/public/WebElement.h @@ -39,15 +39,21 @@ namespace WTF { template <typename T> class PassRefPtr; } #endif namespace WebKit { - - // Provides readonly access to some properties of a DOM element node. + // Provides access to some properties of a DOM element node. class WebElement : public WebNode { public: WebElement() : WebNode() { } WebElement(const WebElement& e) : WebNode(e) { } WebElement& operator=(const WebElement& e) { WebNode::assign(e); return *this; } - WEBKIT_API void assign(const WebElement& e) { WebNode::assign(e); } + void assign(const WebElement& e) { WebNode::assign(e); } + + WEBKIT_API WebString tagName() const; + WEBKIT_API bool hasTagName(const WebString&) const; + WEBKIT_API bool hasAttribute(const WebString&) const; + WEBKIT_API WebString getAttribute(const WebString&) const; + WEBKIT_API bool setAttribute(const WebString& name, const WebString& value); + WEBKIT_API WebString innerText() const; #if WEBKIT_IMPLEMENTATION WebElement(const WTF::PassRefPtr<WebCore::Element>&); diff --git a/WebKit/chromium/public/WebEvent.h b/WebKit/chromium/public/WebEvent.h new file mode 100644 index 0000000..b0964d1 --- /dev/null +++ b/WebKit/chromium/public/WebEvent.h @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebEvent_h +#define WebEvent_h + +#include "WebCommon.h" +#include "WebNode.h" +#include "WebString.h" + +namespace WebCore { class Event; } +#if WEBKIT_IMPLEMENTATION +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + +class WebEvent { +public: + enum PhaseType { + CapturingPhase = 1, + AtTarget = 2, + BubblingPhase = 3 + }; + + WebEvent() : m_private(0) { } + WebEvent(const WebEvent& e) : m_private(0) { assign(e); } + WebEvent& operator=(const WebEvent& e) + { + assign(e); + return *this; + } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebEvent&); + + bool isNull() const { return !m_private; } + + WEBKIT_API WebString type() const; + WEBKIT_API WebNode target() const; + WEBKIT_API WebNode currentTarget() const; + + WEBKIT_API PhaseType eventPhase() const; + WEBKIT_API bool bubbles() const; + WEBKIT_API bool cancelable() const; + + WEBKIT_API bool isUIEvent() const; + WEBKIT_API bool isMouseEvent() const; + WEBKIT_API bool isMutationEvent() const; + WEBKIT_API bool isKeyboardEvent() const; + WEBKIT_API bool isTextEvent() const; + WEBKIT_API bool isCompositionEvent() const; + WEBKIT_API bool isDragEvent() const; + WEBKIT_API bool isClipboardEvent() const; + WEBKIT_API bool isMessageEvent() const; + WEBKIT_API bool isWheelEvent() const; + WEBKIT_API bool isBeforeTextInsertedEvent() const; + WEBKIT_API bool isOverflowEvent() const; + WEBKIT_API bool isPageTransitionEvent() const; + WEBKIT_API bool isPopStateEvent() const; + WEBKIT_API bool isProgressEvent() const; + WEBKIT_API bool isXMLHttpRequestProgressEvent() const; + WEBKIT_API bool isWebKitAnimationEvent() const; + WEBKIT_API bool isWebKitTransitionEvent() const; + WEBKIT_API bool isBeforeLoadEvent() const; + +#if WEBKIT_IMPLEMENTATION + WebEvent(const WTF::PassRefPtr<WebCore::Event>&); +#endif + +protected: + typedef WebCore::Event WebEventPrivate; + void assign(WebEventPrivate*); + WebEventPrivate* m_private; + + template<typename T> T* unwrap() + { + return static_cast<T*>(m_private); + } + + template<typename T> const T* constUnwrap() const + { + return static_cast<const T*>(m_private); + } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebEventListener.h b/WebKit/chromium/public/WebEventListener.h new file mode 100644 index 0000000..52de1cd --- /dev/null +++ b/WebKit/chromium/public/WebEventListener.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 WebEventListener_h +#define WebEventListener_h + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class Node; } +#endif + +namespace WebKit { + +class EventListenerWrapper; +class WebEvent; +class WebEventListenerPrivate; +class WebNode; +class WebString; + +class WebEventListener { +public: + WebEventListener(); + virtual ~WebEventListener(); + + // Called when an event is received. + virtual void handleEvent(const WebEvent&) = 0; + +#if WEBKIT_IMPLEMENTATION + void notifyEventListenerDeleted(EventListenerWrapper*); + EventListenerWrapper* createEventListenerWrapper(const WebString& eventType, bool useCapture, WebCore::Node* node); + EventListenerWrapper* getEventListenerWrapper(const WebString& eventType, bool useCapture, WebCore::Node* node); +#endif + +private: + WebEventListenerPrivate* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebFileChooserParams.h b/WebKit/chromium/public/WebFileChooserParams.h new file mode 100644 index 0000000..6359f14 --- /dev/null +++ b/WebKit/chromium/public/WebFileChooserParams.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebFileChooserParams_h +#define WebFileChooserParams_h + +#include "WebFileChooserCompletion.h" +#include "WebString.h" +#include "WebVector.h" + +namespace WebKit { + +struct WebFileChooserParams { + // If |multiSelect| is true, the dialog allow to select multiple files. + bool multiSelect; + // |title| is a title of a file chooser dialog. It can be an empty string. + WebString title; + // |initialValue| is a filename which the dialog should select by default. + // It can be an empty string. + WebString initialValue; + // |acceptTypes| has a comma-separated MIME types such as "audio/*,text/plain". + // The dialog may restrict selectable files to the specified MIME types. + // This value comes from an 'accept' attribute value of an INPUT element. + // So it might be a wrong formatted string. + WebString acceptTypes; + // |selectedFiles| has filenames which a file upload control already select. + // A WebViewClient implementation may ask a user to select + // - removing a file from the selected files, + // - appending other files, or + // - replacing with other files + // before opening a file chooser dialog. + WebVector<WebString> selectedFiles; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebFormElement.h b/WebKit/chromium/public/WebFormElement.h index 27a1edb..b07bff9 100644 --- a/WebKit/chromium/public/WebFormElement.h +++ b/WebKit/chromium/public/WebFormElement.h @@ -50,7 +50,11 @@ namespace WebKit { WebFormElement() : WebElement() { } WebFormElement(const WebFormElement& e) : WebElement(e) { } - WebElement& operator=(const WebFormElement& e) { WebElement::assign(e); return *this; } + WebFormElement& operator=(const WebFormElement& e) + { + WebElement::assign(e); + return *this; + } WEBKIT_API void assign(const WebFormElement& e) { WebElement::assign(e); } #if WEBKIT_IMPLEMENTATION diff --git a/WebKit/chromium/public/WebFrame.h b/WebKit/chromium/public/WebFrame.h index 44b57aa..4197c23 100644 --- a/WebKit/chromium/public/WebFrame.h +++ b/WebKit/chromium/public/WebFrame.h @@ -45,8 +45,11 @@ template <class T> class Local; namespace WebKit { +class WebAnimationController; class WebData; class WebDataSource; +class WebDocument; +class WebElement; class WebFormElement; class WebHistoryItem; class WebInputElement; @@ -66,6 +69,9 @@ template <typename T> class WebVector; class WebFrame { public: + // Returns the number of live WebFrame objects, used for leak checking. + WEBKIT_API static int instanceCount(); + // The two functions below retrieve the WebFrame instances relating the // currently executing JavaScript. Since JavaScript can make function // calls across frames, though, we need to be more precise. @@ -85,11 +91,16 @@ public: WEBKIT_API static WebFrame* frameForEnteredContext(); WEBKIT_API static WebFrame* frameForCurrentContext(); + // Returns the frame inside a given frame or iframe element. Returns 0 if + // the given element is not a frame, iframe or if the frame is empty. + WEBKIT_API static WebFrame* fromFrameOwnerElement(const WebElement&); + // Basic properties --------------------------------------------------- // The name of this frame. virtual WebString name() const = 0; + virtual void clearName() = 0; // The url of the document loaded in this frame. This is equivalent to // dataSource()->request().url(). @@ -103,6 +114,9 @@ public: // the document loaded in this frame. virtual WebURL openSearchDescriptionURL() const = 0; + // Return the frame's encoding. + virtual WebString encoding() const = 0; + // Geometry ----------------------------------------------------------- @@ -164,8 +178,12 @@ public: // Content ------------------------------------------------------------ + virtual WebDocument document() const = 0; + virtual void forms(WebVector<WebFormElement>&) const = 0; + virtual WebAnimationController* animationController() = 0; + // Scripting ---------------------------------------------------------- @@ -186,17 +204,6 @@ public: // Executes script in the context of the current page. virtual void executeScript(const WebScriptSource&) = 0; - // Executes script in a new context associated with the frame. The - // script gets its own global scope and its own prototypes for - // intrinsic JS objects (String, Array, and so-on). It shares the - // wrappers for all DOM nodes and DOM constructors. extensionGroup is - // an embedder-provided specifier that controls which v8 extensions are - // loaded into the new context - see WebKit::registerExtension for the - // corresponding specifier. - virtual void executeScriptInNewContext(const WebScriptSource* sources, - unsigned numSources, - int extensionGroup) = 0; - // Executes JavaScript in a new world associated with the web frame. // The script gets its own global scope and its own prototypes for // intrinsic JavaScript objects (String, Array, and so-on). It also @@ -428,6 +435,7 @@ public: // of matches found during the scoping effort. virtual void resetMatchCount() = 0; + // Password autocompletion --------------------------------------------- // Registers a listener for the specified user name input element. The @@ -438,12 +446,14 @@ public: WebInputElement, WebPasswordAutocompleteListener*) = 0; + // Utility ------------------------------------------------------------- // Given a relative URL, returns an absolute URL by resolving the URL // relative to the base URL of the frame's document. This uses the // same algorithm that WebKit uses to resolve hyperlinks found in a // HTML document. + // Deprecated. Use document().completeURL() instead. virtual WebURL completeURL(const WebString&) const = 0; // Returns the contents of this frame as a string. If the text is @@ -460,6 +470,14 @@ public: // from the DOM. virtual WebString contentAsMarkup() const = 0; + // Returns a text representation of the render tree. This method is used + // to support layout tests. + virtual WebString renderTreeAsText() const = 0; + + // Returns the counter value for the specified element. This method is + // used to support layout tests. + virtual WebString counterValueForElementById(const WebString& id) const = 0; + protected: ~WebFrame() { } }; diff --git a/WebKit/chromium/public/WebFrameClient.h b/WebKit/chromium/public/WebFrameClient.h index 297eb62..4078151 100644 --- a/WebKit/chromium/public/WebFrameClient.h +++ b/WebKit/chromium/public/WebFrameClient.h @@ -80,6 +80,12 @@ public: // This frame is about to be closed. virtual void willClose(WebFrame*) { } + // Controls whether plugins are allowed for this frame. + virtual bool allowPlugins(WebFrame*, bool enabledPerSettings) { return enabledPerSettings; } + + // Controls whether images are allowed for this frame. + virtual bool allowImages(WebFrame*, bool enabledPerSettings) { return enabledPerSettings; } + // Load commands ------------------------------------------------------- diff --git a/WebKit/chromium/public/WebGlyphCache.h b/WebKit/chromium/public/WebGlyphCache.h new file mode 100644 index 0000000..661767d --- /dev/null +++ b/WebKit/chromium/public/WebGlyphCache.h @@ -0,0 +1,51 @@ +/* + * 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 WebGlyphCache_h +#define WebGlyphCache_h + +#include "WebCommon.h" + +namespace WebKit { + +// An interface to query WebKit's glyph cache (which maps unicode characters to +// glyphs in particular fonts). +class WebGlyphCache { +public: + // Returns the number of pages in the glyph cache. + WEBKIT_API static size_t pageCount(); + +private: + WebGlyphCache(); // Not intended to be instanced. +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebHistoryItem.h b/WebKit/chromium/public/WebHistoryItem.h index f15a62c..e248a61 100644 --- a/WebKit/chromium/public/WebHistoryItem.h +++ b/WebKit/chromium/public/WebHistoryItem.h @@ -105,6 +105,9 @@ public: WEBKIT_API WebVector<WebString> documentState() const; WEBKIT_API void setDocumentState(const WebVector<WebString>&); + WEBKIT_API long long documentSequenceNumber() const; + WEBKIT_API void setDocumentSequenceNumber(long long); + WEBKIT_API WebString httpContentType() const; WEBKIT_API void setHTTPContentType(const WebString&); diff --git a/WebKit/chromium/public/WebInputElement.h b/WebKit/chromium/public/WebInputElement.h index 75e44b9..226624a 100644 --- a/WebKit/chromium/public/WebInputElement.h +++ b/WebKit/chromium/public/WebInputElement.h @@ -82,6 +82,7 @@ namespace WebKit { Week }; + WEBKIT_API bool autoComplete() const; WEBKIT_API bool isEnabledFormControl() const; WEBKIT_API InputType inputType() const; WEBKIT_API WebString formControlType() const; diff --git a/WebKit/chromium/public/WebKit.h b/WebKit/chromium/public/WebKit.h index b9e6407..732cac6 100644 --- a/WebKit/chromium/public/WebKit.h +++ b/WebKit/chromium/public/WebKit.h @@ -55,6 +55,9 @@ WEBKIT_API WebKitClient* webKitClient(); WEBKIT_API void setLayoutTestMode(bool); WEBKIT_API bool layoutTestMode(); +// Enables the named log channel. See WebCore/platform/Logging.h for details. +WEBKIT_API void enableLogChannel(const char*); + // Purge the plugin list cache. If |reloadPages| is true, any pages // containing plugins will be reloaded after refreshing the plugin list. WEBKIT_API void resetPluginCache(bool reloadPages); diff --git a/WebKit/chromium/public/WebKitClient.h b/WebKit/chromium/public/WebKitClient.h index 2a00a9a..fe6c801 100644 --- a/WebKit/chromium/public/WebKitClient.h +++ b/WebKit/chromium/public/WebKitClient.h @@ -89,6 +89,7 @@ public: virtual WebStorageNamespace* createLocalStorageNamespace(const WebString& path, unsigned quota) { return 0; } // Return a new SessionStorage namespace. + // THIS IS DEPRECATED. WebViewClient::getSessionStorageNamespace() is the new way to access this. virtual WebStorageNamespace* createSessionStorageNamespace() { return 0; } // Called when storage events fire. @@ -178,10 +179,11 @@ public: // Network ------------------------------------------------------------- virtual void setCookies( - const WebURL& url, const WebURL& policyURL, const WebString& cookies) { } - virtual WebString cookies(const WebURL& url, const WebURL& policyURL) { return WebString(); } - virtual bool rawCookies(const WebURL& url, const WebURL& policyURL, WebVector<WebCookie>*) { return false; } + const WebURL& url, const WebURL& firstPartyForCookies, const WebString& cookies) { } + virtual WebString cookies(const WebURL& url, const WebURL& firstPartyForCookies) { return WebString(); } + virtual bool rawCookies(const WebURL& url, const WebURL& firstPartyForCookies, WebVector<WebCookie>*) { return false; } virtual void deleteCookie(const WebURL& url, const WebString& cookieName) { } + virtual bool cookiesEnabled(const WebURL& url, const WebURL& firstPartyForCookies) { return true; } // A suggestion to prefetch IP information for the given hostname. virtual void prefetchHostName(const WebString&) { } @@ -200,23 +202,23 @@ public: // If refresh is true, then cached information should not be used to // satisfy this call. - virtual void getPluginList(bool refresh, WebPluginListBuilder*) { }; + virtual void getPluginList(bool refresh, WebPluginListBuilder*) { } // Profiling ----------------------------------------------------------- - virtual void decrementStatsCounter(const char* name) { }; - virtual void incrementStatsCounter(const char* name) { }; + virtual void decrementStatsCounter(const char* name) { } + virtual void incrementStatsCounter(const char* name) { } // An event is identified by the pair (name, id). The extra parameter // specifies additional data to log with the event. - virtual void traceEventBegin(const char* name, void* id, const char* extra) { }; - virtual void traceEventEnd(const char* name, void* id, const char* extra) { }; + virtual void traceEventBegin(const char* name, void* id, const char* extra) { } + virtual void traceEventEnd(const char* name, void* id, const char* extra) { } // Generic callback for reporting histogram data. Range is identified by the min, max pair. // By default, histogram is exponential, so that min=1, max=1000000, bucketCount=50 would do. Setting // linear to true would require bucket count to cover whole min-max range. - virtual void histogramCounts(const WebString& name, int sample, int min, int max, int bucketCount, bool linear) { }; + virtual void histogramCounts(const WebString& name, int sample, int min, int max, int bucketCount, bool linear) { } // Resources ----------------------------------------------------------- diff --git a/WebKit/chromium/public/WebMutationEvent.h b/WebKit/chromium/public/WebMutationEvent.h new file mode 100644 index 0000000..75eb9c4 --- /dev/null +++ b/WebKit/chromium/public/WebMutationEvent.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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 WebMutationEvent_h +#define WebMutationEvent_h + +#include "WebEvent.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class Event; } +#endif + +namespace WebKit { + +class WebMutationEvent : public WebEvent { +public: + enum AttrChangeType { + Modification = 1, + Addition = 2, + Removal = 3 + }; + + WEBKIT_API WebNode relatedNode() const; + WEBKIT_API WebString prevValue() const; + WEBKIT_API WebString newValue() const; + WEBKIT_API WebString attrName() const; + WEBKIT_API AttrChangeType attrChange() const; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebNode.h b/WebKit/chromium/public/WebNode.h index 03afa90..4d2a0e9 100644 --- a/WebKit/chromium/public/WebNode.h +++ b/WebKit/chromium/public/WebNode.h @@ -40,9 +40,13 @@ namespace WTF { template <typename T> class PassRefPtr; } #endif namespace WebKit { +class WebDocument; +class WebEventListener; +class WebEventListenerPrivate; class WebFrame; +class WebNodeList; -// Provides readonly access to some properties of a DOM node. +// Provides access to some properties of a DOM node. class WebNode { public: virtual ~WebNode() { reset(); } @@ -66,14 +70,52 @@ public: operator WTF::PassRefPtr<WebCore::Node>() const; #endif + enum NodeType { + ElementNode = 1, + AttributeNode, + TextNode, + CDataSectionNode, + EntityReferenceNode, + EntityNode, + ProcessingInstructionsNode, + CommentNode, + DocumentNode, + DocumentTypeNode, + DocumentFragmentNode, + NotationNode, + XPathNamespaceNode + }; + WEBKIT_API NodeType nodeType() const; WEBKIT_API WebNode parentNode() const; WEBKIT_API WebString nodeName() const; + WEBKIT_API WebString nodeValue() const; + WEBKIT_API bool setNodeValue(const WebString&); + // Deprecated. Use document().frame() instead. WEBKIT_API WebFrame* frame() const; + WEBKIT_API WebDocument document() const; + WEBKIT_API WebNode firstChild() const; + WEBKIT_API WebNode lastChild() const; + WEBKIT_API WebNode previousSibling() const; + WEBKIT_API WebNode nextSibling() const; + WEBKIT_API bool hasChildNodes() const; + WEBKIT_API WebNodeList childNodes(); + WEBKIT_API WebString createMarkup() const; + WEBKIT_API bool isTextNode() const; + WEBKIT_API bool isElementNode() const; + WEBKIT_API void addEventListener(const WebString& eventType, WebEventListener* listener, bool useCapture); + WEBKIT_API void removeEventListener(const WebString& eventType, WebEventListener* listener, bool useCapture); template<typename T> T toElement() { T res; - res.m_private = m_private; + res.WebNode::assign(*this); + return res; + } + + template<typename T> const T toConstElement() const + { + T res; + res.WebNode::assign(*this); return res; } diff --git a/WebKit/chromium/public/WebNodeCollection.h b/WebKit/chromium/public/WebNodeCollection.h new file mode 100644 index 0000000..fee4f44 --- /dev/null +++ b/WebKit/chromium/public/WebNodeCollection.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebNodeCollection_h +#define WebNodeCollection_h + +#include "WebCommon.h" + +namespace WebCore { class HTMLCollection; } +#if WEBKIT_IMPLEMENTATION +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { +class WebNode; + +// Provides readonly access to some properties of a DOM node. +class WebNodeCollection { +public: + ~WebNodeCollection() { reset(); } + + WebNodeCollection() : m_private(0) { } + WebNodeCollection(const WebNodeCollection& n) : m_private(0) { assign(n); } + WebNodeCollection& operator=(const WebNodeCollection& n) + { + assign(n); + return *this; + } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebNodeCollection&); + + WEBKIT_API unsigned length() const; + WEBKIT_API WebNode nextItem() const; + WEBKIT_API WebNode firstItem() const; + +#if WEBKIT_IMPLEMENTATION + WebNodeCollection(const WTF::PassRefPtr<WebCore::HTMLCollection>&); +#endif + +private: + void assign(WebCore::HTMLCollection*); + WebCore::HTMLCollection* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebNodeList.h b/WebKit/chromium/public/WebNodeList.h new file mode 100644 index 0000000..23efab0 --- /dev/null +++ b/WebKit/chromium/public/WebNodeList.h @@ -0,0 +1,74 @@ +/* + * 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 WebNodeList_h +#define WebNodeList_h + +#include "WebCommon.h" + +namespace WebCore { class NodeList; } +#if WEBKIT_IMPLEMENTATION +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { +class WebNode; + +// Provides readonly access to some properties of a DOM node. +class WebNodeList { +public: + ~WebNodeList() { reset(); } + + WebNodeList() : m_private(0) { } + WebNodeList(const WebNodeList& n) : m_private(0) { assign(n); } + WebNodeList& operator=(const WebNodeList& n) + { + assign(n); + return *this; + } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebNodeList&); + + WEBKIT_API unsigned length() const; + WEBKIT_API WebNode item(size_t) const; + +#if WEBKIT_IMPLEMENTATION + WebNodeList(const WTF::PassRefPtr<WebCore::NodeList>&); +#endif + +private: + void assign(WebCore::NodeList*); + WebCore::NodeList* m_private; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebNotificationPresenter.h b/WebKit/chromium/public/WebNotificationPresenter.h index 653b142..a3764aa 100644 --- a/WebKit/chromium/public/WebNotificationPresenter.h +++ b/WebKit/chromium/public/WebNotificationPresenter.h @@ -35,8 +35,10 @@ namespace WebKit { +class WebDocument; class WebNotification; class WebNotificationPermissionCallback; +class WebURL; // Provides the services to show desktop notifications to the user. class WebNotificationPresenter { @@ -57,8 +59,9 @@ public: // being destroyed. Does _not_ remove the notification if being shown, but detaches it from receiving events. virtual void objectDestroyed(const WebNotification&) = 0; - // Checks the permission level of a given origin. - virtual Permission checkPermission(const WebString& origin) = 0; + // Checks the permission level for the given URL. If the URL is being displayed in a document + // (as opposed to a worker or other ScriptExecutionContext), |document| will also be provided. + virtual Permission checkPermission(const WebURL& url, WebDocument* document) = 0; // Requests permission for a given origin. This operation is asynchronous and the callback provided // will be invoked when the permission decision is made. Callback pointer must remain diff --git a/WebKit/chromium/public/WebPageSerializer.h b/WebKit/chromium/public/WebPageSerializer.h new file mode 100644 index 0000000..94f7994 --- /dev/null +++ b/WebKit/chromium/public/WebPageSerializer.h @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebPageSerializer_h +#define WebPageSerializer_h + +#include "WebCommon.h" + +namespace WebKit { +class WebFrame; +class WebPageSerializerClient; +class WebString; +class WebURL; +template <typename T> class WebVector; + +// Get html data by serializing all frames of current page with lists +// which contain all resource links that have local copy. +class WebPageSerializer { +public: + // 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 WebPageSeriazlierClient once the data buffer is full. + // + // Return false means no available frame has been serialized, otherwise + // return true. + // + // The parameter frame specifies which frame need to be serialized. + // The parameter recursive specifies whether we need to + // serialize all sub frames of the specified frame or not. + // The parameter client specifies the pointer of interface + // WebPageSerializerClient providing a sink interface to receive the + // individual chunks of data to be saved. + // The parameter links contain original URLs of all saved links. + // The parameter localPaths contain corresponding local file paths of all + // saved links, which matched with vector:links one by one. + // The parameter localDirectoryName is relative path of directory which + // contain all saved auxiliary files included all sub frames and resources. + WEBKIT_API static bool serialize(WebFrame* frame, + bool recursive, + WebPageSerializerClient* client, + const WebVector<WebURL>& links, + const WebVector<WebString>& localPaths, + const WebString& localDirectoryName); + + // FIXME: The following are here for unit testing purposes. Consider + // changing the unit tests instead. + + // Generate the META for charset declaration. + WEBKIT_API static WebString generateMetaCharsetDeclaration(const WebString& charset); + // Generate the MOTW declaration. + WEBKIT_API static WebString generateMarkOfTheWebDeclaration(const WebURL& url); + // Generate the default base tag declaration. + WEBKIT_API static WebString generateBaseTagDeclaration(const WebString& baseTarget); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebPageSerializerClient.h b/WebKit/chromium/public/WebPageSerializerClient.h new file mode 100644 index 0000000..c30ddbc --- /dev/null +++ b/WebKit/chromium/public/WebPageSerializerClient.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebPageSerializerClient_h +#define WebPageSerializerClient_h + +namespace WebKit { +class WebCString; +class WebURL; + +// This class is used for providing sink interface that can be used to receive +// the individual chunks of data to be saved. +class WebPageSerializerClient { +public: + // This enum indicates This sink interface can receive the individual chunks + // of serialized data to be saved, so we use values of following enum + // definition to indicate the serialization status of serializing all html + // content. If current frame is not complete serialized, call + // didSerializeDataForFrame with URL of current frame, data, data length and + // flag CurrentFrameIsNotFinished. + // If current frame is complete serialized, call didSerializeDataForFrame + // with URL of current frame, data, data length and flag + // CurrentFrameIsFinished. + // If all frames of page are complete serialized, call + // didSerializeDataForFrame with empty URL, empty data, 0 and flag + // AllFramesAreFinished. + enum PageSerializationStatus { + CurrentFrameIsNotFinished, + CurrentFrameIsFinished, + AllFramesAreFinished, + }; + + // Receive the individual chunks of serialized and encoded data to be saved. + // The parameter frameURL specifies what frame the data belongs. The + // parameter data contains the available data for saving. The parameter + // status indicates the status of data serialization. + virtual void didSerializeDataForFrame(const WebURL& frameURL, + const WebCString& data, + PageSerializationStatus status) = 0; + WebPageSerializerClient() { } + +protected: + virtual ~WebPageSerializerClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/public/WebRuntimeFeatures.h b/WebKit/chromium/public/WebRuntimeFeatures.h index eb6b2da..04f88c9 100644 --- a/WebKit/chromium/public/WebRuntimeFeatures.h +++ b/WebKit/chromium/public/WebRuntimeFeatures.h @@ -62,6 +62,12 @@ public: WEBKIT_API static void enableApplicationCache(bool); WEBKIT_API static bool isApplicationCacheEnabled(); + WEBKIT_API static void enableGeolocation(bool); + WEBKIT_API static bool isGeolocationEnabled(); + + WEBKIT_API static void enableIndexedDatabase(bool); + WEBKIT_API static bool isIndexedDatabaseEnabled(); + private: WebRuntimeFeatures(); }; diff --git a/WebKit/chromium/public/WebSecurityOrigin.h b/WebKit/chromium/public/WebSecurityOrigin.h index d04fbc6..7b04aac 100644 --- a/WebKit/chromium/public/WebSecurityOrigin.h +++ b/WebKit/chromium/public/WebSecurityOrigin.h @@ -55,6 +55,8 @@ public: return *this; } + WEBKIT_API static WebSecurityOrigin* createFromDatabaseIdentifier(const WebString& databaseIdentifier); + WEBKIT_API void reset(); WEBKIT_API void assign(const WebSecurityOrigin&); diff --git a/WebKit/chromium/public/WebSecurityPolicy.h b/WebKit/chromium/public/WebSecurityPolicy.h index 47dfe87..8e1ee52 100644 --- a/WebKit/chromium/public/WebSecurityPolicy.h +++ b/WebKit/chromium/public/WebSecurityPolicy.h @@ -55,6 +55,10 @@ public: const WebURL& sourceOrigin, const WebString& destinationProtocol, const WebString& destinationHost, bool allowDestinationSubdomains); WEBKIT_API static void resetOriginAccessWhiteLists(); + + // Returns whether the url should be allowed to see the referrer + // based on their respective protocols. + WEBKIT_API static bool shouldHideReferrer(const WebURL& url, const WebString& referrer); private: WebSecurityPolicy(); diff --git a/WebKit/chromium/public/WebSettings.h b/WebKit/chromium/public/WebSettings.h index da36806..d75ccde 100644 --- a/WebKit/chromium/public/WebSettings.h +++ b/WebKit/chromium/public/WebSettings.h @@ -58,6 +58,7 @@ public: virtual void setWebSecurityEnabled(bool) = 0; virtual void setJavaScriptCanOpenWindowsAutomatically(bool) = 0; virtual void setLoadsImagesAutomatically(bool) = 0; + virtual void setImagesEnabled(bool) = 0; virtual void setPluginsEnabled(bool) = 0; virtual void setDOMPasteAllowed(bool) = 0; virtual void setDeveloperExtrasEnabled(bool) = 0; diff --git a/WebKit/chromium/public/WebStorageArea.h b/WebKit/chromium/public/WebStorageArea.h index 71dc7a5..302e10c 100644 --- a/WebKit/chromium/public/WebStorageArea.h +++ b/WebKit/chromium/public/WebStorageArea.h @@ -32,10 +32,10 @@ #define WebStorageArea_h #include "WebCommon.h" +#include "WebString.h" namespace WebKit { -class WebString; class WebURL; // In WebCore, there's one distinct StorageArea per origin per StorageNamespace. This @@ -60,14 +60,41 @@ public: // Set the value that corresponds to a specific key. QuotaException is set if we've // the StorageArea would have exceeded its quota. The value is NOT set when there's // an exception. url is the url that should be used if a storage event fires. - virtual void setItem(const WebString& key, const WebString& value, const WebURL& url, bool& quotaException) = 0; + // FIXME: The following is a hack to keep Chromium compiling until the other half is landed. Remove soon. + virtual void setItem(const WebString& key, const WebString& newValue, const WebURL& url, bool& quotaException) // Deprecated. + { + WebString oldValue; + setItem(key, newValue, url, quotaException, oldValue); + } + virtual void setItem(const WebString& key, const WebString& newValue, const WebURL& url, bool& quotaException, WebString& oldValue) + { + setItem(key, newValue, url, quotaException); + } // Remove the value associated with a particular key. url is the url that should be used // if a storage event fires. - virtual void removeItem(const WebString& key, const WebURL& url) = 0; + // FIXME: The following is a hack to keep Chromium compiling until the other half is landed. Remove soon. + virtual void removeItem(const WebString& key, const WebURL& url) // Deprecated. + { + WebString oldValue; + removeItem(key, url, oldValue); + } + virtual void removeItem(const WebString& key, const WebURL& url, WebString& oldValue) + { + removeItem(key, url); + } // Clear all key/value pairs. url is the url that should be used if a storage event fires. - virtual void clear(const WebURL& url) = 0; + // FIXME: The following is a hack to keep Chromium compiling until the other half is landed. Remove soon. + virtual void clear(const WebURL& url) // Deprecated. + { + bool somethingCleared; + clear(url, somethingCleared); + } + virtual void clear(const WebURL& url, bool& somethingCleared) + { + clear(url); + } }; } // namespace WebKit diff --git a/WebKit/chromium/public/WebString.h b/WebKit/chromium/public/WebString.h index d9b66b2..d2cf9ea 100644 --- a/WebKit/chromium/public/WebString.h +++ b/WebKit/chromium/public/WebString.h @@ -76,6 +76,8 @@ public: WEBKIT_API void assign(const WebString&); WEBKIT_API void assign(const WebUChar* data, size_t len); + WEBKIT_API bool equals(const WebString& s) const; + WEBKIT_API size_t length() const; WEBKIT_API const WebUChar* data() const; @@ -87,6 +89,18 @@ public: WEBKIT_API static WebString fromUTF8(const char* data, size_t length); WEBKIT_API static WebString fromUTF8(const char* data); + template <int N> WebString(const char (&data)[N]) + : m_private(0) + { + assign(fromUTF8(data, N - 1)); + } + + template <int N> WebString& operator=(const char (&data)[N]) + { + assign(fromUTF8(data, N - 1)); + return *this; + } + #if WEBKIT_IMPLEMENTATION WebString(const WebCore::String&); WebString& operator=(const WebCore::String&); @@ -96,6 +110,7 @@ public: WebString& operator=(const WebCore::AtomicString&); operator WebCore::AtomicString() const; #else + WebString(const string16& s) : m_private(0) { assign(s.data(), s.length()); @@ -150,6 +165,16 @@ private: WebStringPrivate* m_private; }; +inline bool operator==(const WebString& a, const WebString& b) +{ + return a.equals(b); +} + +inline bool operator!=(const WebString& a, const WebString& b) +{ + return !(a == b); +} + } // namespace WebKit #endif diff --git a/WebKit/chromium/public/WebURLResponse.h b/WebKit/chromium/public/WebURLResponse.h index cdac83c..1dac069 100644 --- a/WebKit/chromium/public/WebURLResponse.h +++ b/WebKit/chromium/public/WebURLResponse.h @@ -118,6 +118,11 @@ public: const WebCore::ResourceResponse& toResourceResponse() const; #endif + // Flag whether this request was loaded via the SPDY protocol or not. + // SPDY is an experimental web protocol, see http://dev.chromium.org/spdy + WEBKIT_API bool wasFetchedViaSPDY() const; + WEBKIT_API void setWasFetchedViaSPDY(bool); + protected: void assign(WebURLResponsePrivate*); diff --git a/WebKit/chromium/public/WebVector.h b/WebKit/chromium/public/WebVector.h index d1f99b4..0520895 100644 --- a/WebKit/chromium/public/WebVector.h +++ b/WebKit/chromium/public/WebVector.h @@ -84,6 +84,13 @@ public: initializeFrom(other.size() ? &other[0] : 0, other.size()); } + WebVector& operator=(const WebVector& other) + { + if (this != &other) + assign(other); + return *this; + } + template <typename C> WebVector<T>& operator=(const C& other) { diff --git a/WebKit/chromium/public/WebView.h b/WebKit/chromium/public/WebView.h index 5e1f15d..aba556c 100644 --- a/WebKit/chromium/public/WebView.h +++ b/WebKit/chromium/public/WebView.h @@ -251,11 +251,25 @@ public: WEBKIT_API static void resetVisitedLinkState(); - // Scrollbar colors ---------------------------------------------------- + // Custom colors ------------------------------------------------------- + virtual void setScrollbarColors(unsigned inactiveColor, unsigned activeColor, unsigned trackColor) = 0; + virtual void setSelectionColors(unsigned activeBackgroundColor, + unsigned activeForegroundColor, + unsigned inactiveBackgroundColor, + unsigned inactiveForegroundColor) = 0; + + + // Modal dialog support ------------------------------------------------ + + // Call these methods before and after running a nested, modal event loop + // to suspend script callbacks and resource loads. + WEBKIT_API static void willEnterModalLoop(); + WEBKIT_API static void didExitModalLoop(); + protected: ~WebView() {} }; diff --git a/WebKit/chromium/public/WebViewClient.h b/WebKit/chromium/public/WebViewClient.h index 2e2f953..964d382 100644 --- a/WebKit/chromium/public/WebViewClient.h +++ b/WebKit/chromium/public/WebViewClient.h @@ -34,6 +34,7 @@ #include "WebDragOperation.h" #include "WebEditingAction.h" #include "WebFileChooserCompletion.h" +#include "WebFileChooserParams.h" #include "WebString.h" #include "WebTextAffinity.h" #include "WebTextDirection.h" @@ -48,6 +49,7 @@ class WebFrame; class WebNode; class WebNotificationPresenter; class WebRange; +class WebStorageNamespace; class WebURL; class WebView; class WebWidget; @@ -63,7 +65,9 @@ class WebViewClient : virtual public WebWidgetClient { public: // Factory methods ----------------------------------------------------- - // Create a new related WebView. + // Create a new related WebView. This method must clone its session storage + // so any subsequent calls to createSessionStorageNamespace conform to the + // WebStorage specification. virtual WebView* createView(WebFrame* creator) { return 0; } // Create a new WebPopupMenu. In the second form, the client is @@ -71,6 +75,8 @@ public: virtual WebWidget* createPopupMenu(bool activatable) { return 0; } virtual WebWidget* createPopupMenu(const WebPopupMenuInfo&) { return 0; } + // Create a session storage namespace object associated with this WebView. + virtual WebStorageNamespace* createSessionStorageNamespace() { return 0; } // Misc ---------------------------------------------------------------- @@ -161,9 +167,8 @@ public: // dialog is closed, it should call the WebFileChooserCompletion to // pass the results of the dialog. Returns false if // WebFileChooseCompletion will never be called. - virtual bool runFileChooser( - bool multiSelect, const WebString& title, - const WebString& initialValue, WebFileChooserCompletion*) { return false; } + virtual bool runFileChooser(const WebFileChooserParams&, + WebFileChooserCompletion*) { return false; } // Displays a modal alert dialog containing the given message. Returns // once the user dismisses the dialog. diff --git a/WebKit/chromium/src/ApplicationCacheHost.cpp b/WebKit/chromium/src/ApplicationCacheHost.cpp index ef8f860..5fa4a66 100644 --- a/WebKit/chromium/src/ApplicationCacheHost.cpp +++ b/WebKit/chromium/src/ApplicationCacheHost.cpp @@ -33,14 +33,11 @@ #if ENABLE(OFFLINE_WEB_APPLICATIONS) +#include "ApplicationCacheHostInternal.h" #include "DocumentLoader.h" #include "DOMApplicationCache.h" #include "Frame.h" #include "Settings.h" -#include "WebApplicationCacheHost.h" -#include "WebApplicationCacheHostClient.h" -#include "WebKit.h" -#include "WebKitClient.h" #include "WebURL.h" #include "WebURLError.h" #include "WebURLResponse.h" @@ -51,27 +48,6 @@ using namespace WebKit; namespace WebCore { -// ApplicationCacheHostInternal ----------------------------------------------- - -class ApplicationCacheHostInternal : public WebApplicationCacheHostClient { -public: - ApplicationCacheHostInternal(ApplicationCacheHost* host) - : m_innerHost(host) - { - m_outerHost.set(WebKit::webKitClient()->createApplicationCacheHost(this)); - } - - virtual void notifyEventListener(WebApplicationCacheHost::EventID eventID) - { - m_innerHost->notifyDOMApplicationCache( - static_cast<ApplicationCacheHost::EventID>(eventID)); - } - - ApplicationCacheHost* m_innerHost; - OwnPtr<WebApplicationCacheHost> m_outerHost; -}; - -// ApplicationCacheHost ------------------------------------------------------- // 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. @@ -79,6 +55,7 @@ public: ApplicationCacheHost::ApplicationCacheHost(DocumentLoader* documentLoader) : m_domApplicationCache(0) , m_documentLoader(documentLoader) + , m_defersEvents(true) { ASSERT(m_documentLoader); } @@ -220,15 +197,32 @@ void ApplicationCacheHost::setDOMApplicationCache(DOMApplicationCache* domApplic void ApplicationCacheHost::notifyDOMApplicationCache(EventID id) { + if (m_defersEvents) { + m_deferredEvents.append(id); + return; + } if (m_domApplicationCache) { ExceptionCode ec = 0; - m_domApplicationCache->dispatchEvent( - Event::create(DOMApplicationCache::toEventType(id), false, false), - ec); + m_domApplicationCache->dispatchEvent(Event::create(DOMApplicationCache::toEventType(id), false, false), ec); ASSERT(!ec); } } +void ApplicationCacheHost::stopDeferringEvents() +{ + RefPtr<DocumentLoader> protect(documentLoader()); + for (unsigned i = 0; i < m_deferredEvents.size(); ++i) { + EventID id = m_deferredEvents[i]; + if (m_domApplicationCache) { + ExceptionCode ec = 0; + m_domApplicationCache->dispatchEvent(Event::create(DOMApplicationCache::toEventType(id), false, false), ec); + ASSERT(!ec); + } + } + m_deferredEvents.clear(); + m_defersEvents = false; +} + ApplicationCacheHost::Status ApplicationCacheHost::status() const { return m_internal ? static_cast<Status>(m_internal->m_outerHost->status()) : UNCACHED; diff --git a/WebKit/chromium/src/ApplicationCacheHostInternal.h b/WebKit/chromium/src/ApplicationCacheHostInternal.h new file mode 100644 index 0000000..3e52c1b --- /dev/null +++ b/WebKit/chromium/src/ApplicationCacheHostInternal.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ApplicationCacheHost.h" + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + +#include "WebApplicationCacheHostClient.h" +#include "WebKit.h" +#include "WebKitClient.h" + +namespace WebCore { + +class ApplicationCacheHostInternal : public WebKit::WebApplicationCacheHostClient { +public: + ApplicationCacheHostInternal(ApplicationCacheHost* host) + : m_innerHost(host) + { + m_outerHost.set(WebKit::webKitClient()->createApplicationCacheHost(this)); + } + + virtual void notifyEventListener(WebKit::WebApplicationCacheHost::EventID eventID) + { + m_innerHost->notifyDOMApplicationCache(static_cast<ApplicationCacheHost::EventID>(eventID)); + } + + static WebKit::WebApplicationCacheHost* toWebApplicationCacheHost(ApplicationCacheHost* innerHost) + { + if (innerHost && innerHost->m_internal.get()) + return innerHost->m_internal->m_outerHost.get(); + return 0; + } + +private: + friend class ApplicationCacheHost; + ApplicationCacheHost* m_innerHost; + OwnPtr<WebKit::WebApplicationCacheHost> m_outerHost; +}; + +} + +#endif // ENABLE(OFFLINE_WEB_APPLICATIONS) diff --git a/WebKit/chromium/src/AssertMatchingEnums.cpp b/WebKit/chromium/src/AssertMatchingEnums.cpp index 35e2057..1d2948f 100644 --- a/WebKit/chromium/src/AssertMatchingEnums.cpp +++ b/WebKit/chromium/src/AssertMatchingEnums.cpp @@ -116,6 +116,8 @@ COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleWebArea, WebAreaRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleHeading, HeadingRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleListBox, ListBoxRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleListBoxOption, ListBoxOptionRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenuListOption, MenuListOptionRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenuListPopup, MenuListPopupRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTableHeaderContainer, TableHeaderContainerRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDefinitionListTerm, DefinitionListTermRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDefinitionListDefinition, DefinitionListDefinitionRole); @@ -126,8 +128,11 @@ COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTab, TabRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTabList, TabListRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTabPanel, TabPanelRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTreeRole, TreeRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTreeGrid, TreeGridRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTreeItemRole, TreeItemRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDirectory, DirectoryRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleEditableText, EditableTextRole); +COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleListItem, ListItemRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkApplication, LandmarkApplicationRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkBanner, LandmarkBannerRole); COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkComplementary, LandmarkComplementaryRole); @@ -245,6 +250,20 @@ COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Month, HTMLInputElement::MONTH); COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Time, HTMLInputElement::TIME); COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Week, HTMLInputElement::WEEK); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::ElementNode, Node::ELEMENT_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::AttributeNode, Node::ATTRIBUTE_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::TextNode, Node::TEXT_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::CDataSectionNode, Node::CDATA_SECTION_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::EntityReferenceNode, Node::ENTITY_REFERENCE_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::EntityNode, Node::ENTITY_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::ProcessingInstructionsNode, Node::PROCESSING_INSTRUCTION_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::CommentNode, Node::COMMENT_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::DocumentNode, Node::DOCUMENT_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::DocumentTypeNode, Node::DOCUMENT_TYPE_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::DocumentFragmentNode, Node::DOCUMENT_FRAGMENT_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::NotationNode, Node::NOTATION_NODE); +COMPILE_ASSERT_MATCHING_ENUM(WebNode::XPathNamespaceNode, Node::XPATH_NAMESPACE_NODE); + #if ENABLE(VIDEO) COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Empty, MediaPlayer::Empty); COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Idle, MediaPlayer::Idle); diff --git a/WebKit/chromium/src/ChromeClientImpl.cpp b/WebKit/chromium/src/ChromeClientImpl.cpp index 4e20124..9079094 100644 --- a/WebKit/chromium/src/ChromeClientImpl.cpp +++ b/WebKit/chromium/src/ChromeClientImpl.cpp @@ -560,22 +560,20 @@ void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileCh if (!client) return; - bool multipleFiles = fileChooser->allowsMultipleFiles(); - - WebString suggestion; - if (fileChooser->filenames().size() > 0) - suggestion = fileChooser->filenames()[0]; - + WebFileChooserParams params; + params.multiSelect = fileChooser->allowsMultipleFiles(); + params.acceptTypes = fileChooser->acceptTypes(); + params.selectedFiles = fileChooser->filenames(); + if (params.selectedFiles.size() > 0) + params.initialValue = params.selectedFiles[0]; WebFileChooserCompletionImpl* chooserCompletion = new WebFileChooserCompletionImpl(fileChooser); - bool ok = client->runFileChooser(multipleFiles, - WebString(), - suggestion, - chooserCompletion); - if (!ok) { - // Choosing failed, so do callback with an empty list. - chooserCompletion->didChooseFile(WebVector<WebString>()); - } + + if (client->runFileChooser(params, chooserCompletion)) + return; + + // Choosing failed, so do callback with an empty list. + chooserCompletion->didChooseFile(WebVector<WebString>()); } void ChromeClientImpl::popupOpened(PopupContainer* popupContainer, diff --git a/WebKit/chromium/src/ChromiumBridge.cpp b/WebKit/chromium/src/ChromiumBridge.cpp index 93d92ba..0fd0825 100644 --- a/WebKit/chromium/src/ChromiumBridge.cpp +++ b/WebKit/chromium/src/ChromiumBridge.cpp @@ -33,6 +33,7 @@ #include <googleurl/src/url_util.h> +#include "Chrome.h" #include "ChromeClientImpl.h" #include "WebClipboard.h" #include "WebCookie.h" @@ -54,13 +55,13 @@ #include "WebViewImpl.h" #include "WebWorkerClientImpl.h" -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) #include "WebRect.h" #include "WebSandboxSupport.h" #include "WebThemeEngine.h" #endif -#if PLATFORM(LINUX) +#if OS(LINUX) #include "WebSandboxSupport.h" #include "WebFontInfo.h" #endif @@ -212,6 +213,12 @@ void ChromiumBridge::deleteCookie(const KURL& url, const String& cookieName) webKitClient()->deleteCookie(url, cookieName); } +bool ChromiumBridge::cookiesEnabled(const KURL& url, + const KURL& firstPartyForCookies) +{ + return webKitClient()->cookiesEnabled(url, firstPartyForCookies); +} + // DNS ------------------------------------------------------------------------ void ChromiumBridge::prefetchDNS(const String& hostname) @@ -278,7 +285,7 @@ KURL ChromiumBridge::filePathToURL(const String& path) // Font ----------------------------------------------------------------------- -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) bool ChromiumBridge::ensureFontLoaded(HFONT font) { WebSandboxSupport* ss = webKitClient()->sandboxSupport(); @@ -289,7 +296,7 @@ bool ChromiumBridge::ensureFontLoaded(HFONT font) } #endif -#if PLATFORM(LINUX) +#if OS(LINUX) String ChromiumBridge::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters) { if (webKitClient()->sandboxSupport()) @@ -473,7 +480,7 @@ double ChromiumBridge::currentTime() // Theming -------------------------------------------------------------------- -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) void ChromiumBridge::paintButton( GraphicsContext* gc, int part, int state, int classicState, diff --git a/WebKit/chromium/src/ContextMenuClientImpl.cpp b/WebKit/chromium/src/ContextMenuClientImpl.cpp index f23919e..72b861f 100644 --- a/WebKit/chromium/src/ContextMenuClientImpl.cpp +++ b/WebKit/chromium/src/ContextMenuClientImpl.cpp @@ -79,11 +79,11 @@ static WebURL urlFromFrame(Frame* frame) return WebURL(); } -// Helper function to determine whether text is a single word or a sentence. +// Helper function to determine whether text is a single word. static bool isASingleWord(const String& text) { - TextBreakIterator* it = characterBreakIterator(text.characters(), text.length()); - return it && textBreakNext(it) == TextBreakDone; + TextBreakIterator* it = wordBreakIterator(text.characters(), text.length()); + return it && textBreakNext(it) == static_cast<int>(text.length()); } // Helper function to get misspelled word on which context menu diff --git a/WebKit/chromium/src/DOMUtilitiesPrivate.cpp b/WebKit/chromium/src/DOMUtilitiesPrivate.cpp index ffdd85d..4081db6 100644 --- a/WebKit/chromium/src/DOMUtilitiesPrivate.cpp +++ b/WebKit/chromium/src/DOMUtilitiesPrivate.cpp @@ -84,4 +84,53 @@ String nameOfInputElement(HTMLInputElement* element) return WebInputElement(element).nameForAutofill(); } +bool elementHasLegalLinkAttribute(const Element* element, + const QualifiedName& attrName) +{ + if (attrName == HTMLNames::srcAttr) { + // Check src attribute. + if (element->hasTagName(HTMLNames::imgTag) + || element->hasTagName(HTMLNames::scriptTag) + || element->hasTagName(HTMLNames::iframeTag) + || element->hasTagName(HTMLNames::frameTag)) + return true; + if (element->hasTagName(HTMLNames::inputTag)) { + const HTMLInputElement* input = + static_cast<const HTMLInputElement*>(element); + if (input->inputType() == HTMLInputElement::IMAGE) + return true; + } + } else if (attrName == HTMLNames::hrefAttr) { + // Check href attribute. + if (element->hasTagName(HTMLNames::linkTag) + || element->hasTagName(HTMLNames::aTag) + || element->hasTagName(HTMLNames::areaTag)) + return true; + } else if (attrName == HTMLNames::actionAttr) { + if (element->hasTagName(HTMLNames::formTag)) + return true; + } else if (attrName == HTMLNames::backgroundAttr) { + if (element->hasTagName(HTMLNames::bodyTag) + || element->hasTagName(HTMLNames::tableTag) + || element->hasTagName(HTMLNames::trTag) + || element->hasTagName(HTMLNames::tdTag)) + return true; + } else if (attrName == HTMLNames::citeAttr) { + if (element->hasTagName(HTMLNames::blockquoteTag) + || element->hasTagName(HTMLNames::qTag) + || element->hasTagName(HTMLNames::delTag) + || element->hasTagName(HTMLNames::insTag)) + return true; + } else if (attrName == HTMLNames::classidAttr + || attrName == HTMLNames::dataAttr) { + if (element->hasTagName(HTMLNames::objectTag)) + return true; + } else if (attrName == HTMLNames::codebaseAttr) { + if (element->hasTagName(HTMLNames::objectTag) + || element->hasTagName(HTMLNames::appletTag)) + return true; + } + return false; +} + } // namespace WebKit diff --git a/WebKit/chromium/src/DOMUtilitiesPrivate.h b/WebKit/chromium/src/DOMUtilitiesPrivate.h index c02bf84..253ab3f 100644 --- a/WebKit/chromium/src/DOMUtilitiesPrivate.h +++ b/WebKit/chromium/src/DOMUtilitiesPrivate.h @@ -32,11 +32,13 @@ #define DOMUtilitiesPrivate_h namespace WebCore { +class Element; class HTMLInputElement; class HTMLLinkElement; class HTMLMetaElement; class HTMLOptionElement; class Node; +class QualifiedName; class String; } @@ -53,6 +55,16 @@ WebCore::HTMLOptionElement* toHTMLOptionElement(WebCore::Node*); // FIXME: Deprecate. Use WebInputElement::nameForAutofill instead. WebCore::String nameOfInputElement(WebCore::HTMLInputElement*); +// 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/WebKit/chromium/src/DragClientImpl.cpp b/WebKit/chromium/src/DragClientImpl.cpp index 5d8a9c3..671e7ca 100644 --- a/WebKit/chromium/src/DragClientImpl.cpp +++ b/WebKit/chromium/src/DragClientImpl.cpp @@ -79,9 +79,7 @@ void DragClientImpl::startDrag(DragImageRef dragImage, WebDragData dragData = static_cast<ClipboardChromium*>(clipboard)->dataObject(); - DragOperation dragOperationMask; - if (!clipboard->sourceOperation(dragOperationMask)) - dragOperationMask = DragOperationEvery; + DragOperation dragOperationMask = clipboard->sourceOperation(); m_webView->startDragging( eventPos, dragData, static_cast<WebDragOperationsMask>(dragOperationMask)); diff --git a/WebKit/chromium/src/EditorClientImpl.cpp b/WebKit/chromium/src/EditorClientImpl.cpp index 5db8ff7..e035e6a 100644 --- a/WebKit/chromium/src/EditorClientImpl.cpp +++ b/WebKit/chromium/src/EditorClientImpl.cpp @@ -105,7 +105,7 @@ bool EditorClientImpl::isSelectTrailingWhitespaceEnabled() { if (m_webView->client()) return m_webView->client()->isSelectTrailingWhitespaceEnabled(); -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) return true; #else return false; @@ -357,7 +357,7 @@ 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 PLATFORM(DARWIN) +#if OS(DARWIN) // Aliases for the generic key defintions to make kbd shortcuts definitions more // readable on OS X. static const unsigned OptionKey = AltKey; @@ -387,7 +387,7 @@ struct KeyPressEntry { static const KeyDownEntry keyDownEntries[] = { { VKEY_LEFT, 0, "MoveLeft" }, { VKEY_LEFT, ShiftKey, "MoveLeftAndModifySelection" }, -#if PLATFORM(DARWIN) +#if OS(DARWIN) { VKEY_LEFT, OptionKey, "MoveWordLeft" }, { VKEY_LEFT, OptionKey | ShiftKey, "MoveWordLeftAndModifySelection" }, @@ -398,7 +398,7 @@ static const KeyDownEntry keyDownEntries[] = { #endif { VKEY_RIGHT, 0, "MoveRight" }, { VKEY_RIGHT, ShiftKey, "MoveRightAndModifySelection" }, -#if PLATFORM(DARWIN) +#if OS(DARWIN) { VKEY_RIGHT, OptionKey, "MoveWordRight" }, { VKEY_RIGHT, OptionKey | ShiftKey, "MoveWordRightAndModifySelection" }, @@ -418,12 +418,12 @@ static const KeyDownEntry keyDownEntries[] = { { VKEY_HOME, 0, "MoveToBeginningOfLine" }, { VKEY_HOME, ShiftKey, "MoveToBeginningOfLineAndModifySelection" }, -#if PLATFORM(DARWIN) +#if OS(DARWIN) { VKEY_LEFT, CommandKey, "MoveToBeginningOfLine" }, { VKEY_LEFT, CommandKey | ShiftKey, "MoveToBeginningOfLineAndModifySelection" }, #endif -#if PLATFORM(DARWIN) +#if OS(DARWIN) { VKEY_UP, CommandKey, "MoveToBeginningOfDocument" }, { VKEY_UP, CommandKey | ShiftKey, "MoveToBeginningOfDocumentAndModifySelection" }, @@ -434,7 +434,7 @@ static const KeyDownEntry keyDownEntries[] = { #endif { VKEY_END, 0, "MoveToEndOfLine" }, { VKEY_END, ShiftKey, "MoveToEndOfLineAndModifySelection" }, -#if PLATFORM(DARWIN) +#if OS(DARWIN) { VKEY_DOWN, CommandKey, "MoveToEndOfDocument" }, { VKEY_DOWN, CommandKey | ShiftKey, "MoveToEndOfDocumentAndModifySelection" }, @@ -443,7 +443,7 @@ static const KeyDownEntry keyDownEntries[] = { { VKEY_END, CtrlKey | ShiftKey, "MoveToEndOfDocumentAndModifySelection" }, #endif -#if PLATFORM(DARWIN) +#if OS(DARWIN) { VKEY_RIGHT, CommandKey, "MoveToEndOfLine" }, { VKEY_RIGHT, CommandKey | ShiftKey, "MoveToEndOfLineAndModifySelection" }, @@ -451,7 +451,7 @@ static const KeyDownEntry keyDownEntries[] = { { VKEY_BACK, 0, "DeleteBackward" }, { VKEY_BACK, ShiftKey, "DeleteBackward" }, { VKEY_DELETE, 0, "DeleteForward" }, -#if PLATFORM(DARWIN) +#if OS(DARWIN) { VKEY_BACK, OptionKey, "DeleteWordBackward" }, { VKEY_DELETE, OptionKey, "DeleteWordForward" }, #else @@ -473,7 +473,7 @@ static const KeyDownEntry keyDownEntries[] = { { VKEY_INSERT, CtrlKey, "Copy" }, { VKEY_INSERT, ShiftKey, "Paste" }, { VKEY_DELETE, ShiftKey, "Cut" }, -#if !PLATFORM(DARWIN) +#if !OS(DARWIN) // On OS X, we pipe these back to the browser, so that it can do menu item // blinking. { 'C', CtrlKey, "Copy" }, @@ -600,13 +600,13 @@ bool EditorClientImpl::handleEditingKeyboardEvent(KeyboardEvent* evt) // unexpected behaviour if (ch < ' ') return false; -#if !PLATFORM(WIN_OS) +#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 PLATFORM(DARWIN) +#if OS(DARWIN) if (evt->keyEvent()->metaKey()) return false; #endif diff --git a/WebKit/chromium/src/EventListenerWrapper.cpp b/WebKit/chromium/src/EventListenerWrapper.cpp new file mode 100644 index 0000000..f2d2979 --- /dev/null +++ b/WebKit/chromium/src/EventListenerWrapper.cpp @@ -0,0 +1,72 @@ +/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "EventListenerWrapper.h"
+
+#include "Event.h"
+#include "EventListener.h"
+
+#include "WebEvent.h"
+#include "WebEventListener.h"
+
+namespace WebKit {
+
+EventListenerWrapper::EventListenerWrapper(WebEventListener* webEventListener)
+ : EventListener(EventListener::JSEventListenerType)
+ , m_webEventListener(webEventListener)
+{
+}
+
+EventListenerWrapper::~EventListenerWrapper()
+{
+ if (m_webEventListener)
+ m_webEventListener->notifyEventListenerDeleted(this);
+}
+
+bool EventListenerWrapper::operator==(const EventListener& listener)
+{
+ return this == &listener;
+}
+
+void EventListenerWrapper::handleEvent(ScriptExecutionContext* context, Event* event)
+{
+ if (!m_webEventListener)
+ return;
+ WebEvent webEvent(event);
+ m_webEventListener->handleEvent(webEvent);
+}
+
+void EventListenerWrapper::webEventListenerDeleted()
+{
+ m_webEventListener = 0;
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/EventListenerWrapper.h b/WebKit/chromium/src/EventListenerWrapper.h new file mode 100644 index 0000000..2a0cbbb --- /dev/null +++ b/WebKit/chromium/src/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 "EventListener.h"
+
+namespace WebCore {
+class ScriptExecutionContext;
+}
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebEventListener;
+
+class EventListenerWrapper : public EventListener {
+public:
+ EventListenerWrapper(WebEventListener*);
+ ~EventListenerWrapper();
+
+ virtual bool operator==(const EventListener&);
+ virtual void handleEvent(ScriptExecutionContext*, Event*);
+
+ void webEventListenerDeleted();
+
+private:
+ WebEventListener* m_webEventListener;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/FrameLoaderClientImpl.cpp b/WebKit/chromium/src/FrameLoaderClientImpl.cpp index 3ca8e8d..b984308 100644 --- a/WebKit/chromium/src/FrameLoaderClientImpl.cpp +++ b/WebKit/chromium/src/FrameLoaderClientImpl.cpp @@ -164,6 +164,22 @@ bool FrameLoaderClientImpl::allowJavaScript(bool enabledPerSettings) return enabledPerSettings; } +bool FrameLoaderClientImpl::allowPlugins(bool enabledPerSettings) +{ + if (m_webFrame->client()) + return m_webFrame->client()->allowPlugins(m_webFrame, enabledPerSettings); + + return enabledPerSettings; +} + +bool FrameLoaderClientImpl::allowImages(bool enabledPerSettings) +{ + if (m_webFrame->client()) + return m_webFrame->client()->allowImages(m_webFrame, enabledPerSettings); + + return enabledPerSettings; +} + bool FrameLoaderClientImpl::hasWebView() const { return m_webFrame->viewImpl(); @@ -1325,7 +1341,7 @@ PassRefPtr<Widget> FrameLoaderClientImpl::createPlugin( const String& mimeType, bool loadManually) { -#if !PLATFORM(WIN_OS) +#if !OS(WINDOWS) // WebCore asks us to make a plugin even if we don't have a // registered handler, with a comment saying it's so we can display // the broken plugin icon. In Chromium, we normally register a diff --git a/WebKit/chromium/src/FrameLoaderClientImpl.h b/WebKit/chromium/src/FrameLoaderClientImpl.h index 4ddfe5f..901600c 100644 --- a/WebKit/chromium/src/FrameLoaderClientImpl.h +++ b/WebKit/chromium/src/FrameLoaderClientImpl.h @@ -66,7 +66,7 @@ public: virtual void didCreateScriptContextForFrame(); virtual void didDestroyScriptContextForFrame(); - // A context untied to a frame was created (through evaluateInNewContext). + // A context untied to a frame was created (through evaluateInIsolatedWorld). // This context is not tied to the lifetime of its frame, and is destroyed // in garbage collection. virtual void didCreateIsolatedScriptContext(); @@ -192,6 +192,8 @@ public: virtual void registerForIconNotification(bool listen = true); virtual void didChangeScrollOffset(); virtual bool allowJavaScript(bool enabledPerSettings); + virtual bool allowPlugins(bool enabledPerSettings); + virtual bool allowImages(bool enabledPerSettings); private: void makeDocumentView(); diff --git a/WebKit/chromium/src/GraphicsContext3D.cpp b/WebKit/chromium/src/GraphicsContext3D.cpp index c9ba5a1..7fe31b0 100644 --- a/WebKit/chromium/src/GraphicsContext3D.cpp +++ b/WebKit/chromium/src/GraphicsContext3D.cpp @@ -56,7 +56,7 @@ #include <stdio.h> #include <wtf/FastMalloc.h> -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) #include <windows.h> #endif @@ -76,11 +76,11 @@ #include "NativeImageSkia.h" #endif -#if PLATFORM(DARWIN) +#if OS(DARWIN) #define USE_TEXTURE_RECTANGLE_FOR_FRAMEBUFFER #endif -#if PLATFORM(LINUX) +#if OS(LINUX) #include <dlfcn.h> #include "GL/glxew.h" #endif @@ -98,7 +98,7 @@ namespace WebCore { class GraphicsContext3DInternal { public: - GraphicsContext3DInternal(); + GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs); ~GraphicsContext3DInternal(); bool makeContextCurrent(); @@ -116,12 +116,15 @@ public: void activeTexture(unsigned long texture); void bindBuffer(unsigned long target, WebGLBuffer* buffer); + void bindFramebuffer(unsigned long target, + WebGLFramebuffer* framebuffer); void bindTexture(unsigned long target, WebGLTexture* texture); void bufferDataImpl(unsigned long target, int size, const void* data, unsigned long usage); void disableVertexAttribArray(unsigned long index); void enableVertexAttribArray(unsigned long index); unsigned long getError(); + GraphicsContext3D::Attributes getContextAttributes(); void vertexAttribPointer(unsigned long indx, int size, int type, bool normalized, unsigned long stride, unsigned long offset); void viewportImpl(long x, long y, unsigned long width, unsigned long height); @@ -129,11 +132,16 @@ public: void synthesizeGLError(unsigned long error); private: + GraphicsContext3D::Attributes m_attrs; + unsigned int m_texture; unsigned int m_fbo; unsigned int m_depthBuffer; unsigned int m_cachedWidth, m_cachedHeight; + // For tracking which FBO is bound + unsigned int m_boundFBO; + #ifdef FLIP_FRAMEBUFFER_VERTICALLY unsigned char* m_scanline; void flipVertically(unsigned char* framebuffer, @@ -176,7 +184,8 @@ private: SkBitmap* m_resizingBitmap; #endif -#if PLATFORM(WIN_OS) + static bool s_initializedGLEW; +#if OS(WINDOWS) HWND m_canvasWindow; HDC m_canvasDC; HGLRC m_contextObj; @@ -184,30 +193,170 @@ private: CGLPBufferObj m_pbuffer; CGLContextObj m_contextObj; unsigned char* m_renderOutput; - CGContextRef m_cgContext; -#elif PLATFORM(LINUX) - Display* m_display; +#elif OS(LINUX) GLXContext m_contextObj; GLXPbuffer m_pbuffer; + // In order to avoid problems caused by linking against libGL, we // dynamically look up all the symbols we need. // http://code.google.com/p/chromium/issues/detail?id=16800 - void* m_libGL; - PFNGLXCHOOSEFBCONFIGPROC m_glXChooseFBConfig; - PFNGLXCREATENEWCONTEXTPROC m_glXCreateNewContext; - PFNGLXCREATEPBUFFERPROC m_glXCreatePbuffer; - PFNGLXDESTROYPBUFFERPROC m_glXDestroyPbuffer; - typedef Bool (* PFNGLXMAKECURRENTPROC)(Display* dpy, GLXDrawable drawable, GLXContext ctx); - PFNGLXMAKECURRENTPROC m_glXMakeCurrent; - typedef void (* PFNGLXDESTROYCONTEXTPROC)(Display* dpy, GLXContext ctx); - PFNGLXDESTROYCONTEXTPROC m_glXDestroyContext; - typedef GLXContext (* PFNGLXGETCURRENTCONTEXTPROC)(void); - PFNGLXGETCURRENTCONTEXTPROC m_glXGetCurrentContext; + class GLConnection { + public: + ~GLConnection(); + + static GLConnection* create(); + + GLXFBConfig* chooseFBConfig(int screen, const int *attrib_list, int *nelements) + { + return m_glXChooseFBConfig(m_display, screen, attrib_list, nelements); + } + + GLXContext createNewContext(GLXFBConfig config, int renderType, GLXContext shareList, Bool direct) + { + return m_glXCreateNewContext(m_display, config, renderType, shareList, direct); + } + + GLXPbuffer createPbuffer(GLXFBConfig config, const int *attribList) + { + return m_glXCreatePbuffer(m_display, config, attribList); + } + + void destroyPbuffer(GLXPbuffer pbuf) + { + m_glXDestroyPbuffer(m_display, pbuf); + } + + Bool makeCurrent(GLXDrawable drawable, GLXContext ctx) + { + return m_glXMakeCurrent(m_display, drawable, ctx); + } + + void destroyContext(GLXContext ctx) + { + m_glXDestroyContext(m_display, ctx); + } + + GLXContext getCurrentContext() + { + return m_glXGetCurrentContext(); + } + + private: + Display* m_display; + void* m_libGL; + PFNGLXCHOOSEFBCONFIGPROC m_glXChooseFBConfig; + PFNGLXCREATENEWCONTEXTPROC m_glXCreateNewContext; + PFNGLXCREATEPBUFFERPROC m_glXCreatePbuffer; + PFNGLXDESTROYPBUFFERPROC m_glXDestroyPbuffer; + typedef Bool (* PFNGLXMAKECURRENTPROC)(Display* dpy, GLXDrawable drawable, GLXContext ctx); + PFNGLXMAKECURRENTPROC m_glXMakeCurrent; + typedef void (* PFNGLXDESTROYCONTEXTPROC)(Display* dpy, GLXContext ctx); + PFNGLXDESTROYCONTEXTPROC m_glXDestroyContext; + typedef GLXContext (* PFNGLXGETCURRENTCONTEXTPROC)(void); + PFNGLXGETCURRENTCONTEXTPROC m_glXGetCurrentContext; + + GLConnection(Display* display, + void* libGL, + PFNGLXCHOOSEFBCONFIGPROC chooseFBConfig, + PFNGLXCREATENEWCONTEXTPROC createNewContext, + PFNGLXCREATEPBUFFERPROC createPbuffer, + PFNGLXDESTROYPBUFFERPROC destroyPbuffer, + PFNGLXMAKECURRENTPROC makeCurrent, + PFNGLXDESTROYCONTEXTPROC destroyContext, + PFNGLXGETCURRENTCONTEXTPROC getCurrentContext) + : m_libGL(libGL) + , m_display(display) + , m_glXChooseFBConfig(chooseFBConfig) + , m_glXCreateNewContext(createNewContext) + , m_glXCreatePbuffer(createPbuffer) + , m_glXDestroyPbuffer(destroyPbuffer) + , m_glXMakeCurrent(makeCurrent) + , m_glXDestroyContext(destroyContext) + , m_glXGetCurrentContext(getCurrentContext) + { + } + + static void* tryLoad(const char* libName) + { + // We use RTLD_GLOBAL semantics so that GLEW initialization works; + // GLEW expects to be able to open the current process's handle + // and do dlsym's of GL entry points from there. + return dlopen(libName, RTLD_LAZY | RTLD_GLOBAL); + } + }; + + static GLConnection* s_gl; #else #error Must port GraphicsContext3D to your platform #endif }; +bool GraphicsContext3DInternal::s_initializedGLEW = false; + +#if OS(LINUX) +GraphicsContext3DInternal::GLConnection* GraphicsContext3DInternal::s_gl = 0; + +GraphicsContext3DInternal::GLConnection* GraphicsContext3DInternal::GLConnection::create() +{ + Display* dpy = XOpenDisplay(0); + if (!dpy) { + printf("GraphicsContext3D: error opening X display\n"); + return 0; + } + + void* libGL = 0; + const char* libNames[] = { + "/usr/lib/libGL.so.1", + "/usr/lib32/libGL.so.1", + "/usr/lib64/libGL.so.1", + }; + for (int i = 0; i < sizeof(libNames) / sizeof(const char*); i++) { + libGL = tryLoad(libNames[i]); + if (libGL) + break; + } + if (!libGL) { + printf("GraphicsContext3D: error opening libGL.so.1\n"); + printf("GraphicsContext3D: tried:\n"); + for (int i = 0; i < sizeof(libNames) / sizeof(const char*); i++) + printf(" %s\n", libNames[i]); + return 0; + } + + PFNGLXCHOOSEFBCONFIGPROC chooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) dlsym(libGL, "glXChooseFBConfig"); + PFNGLXCREATENEWCONTEXTPROC createNewContext = (PFNGLXCREATENEWCONTEXTPROC) dlsym(libGL, "glXCreateNewContext"); + PFNGLXCREATEPBUFFERPROC createPbuffer = (PFNGLXCREATEPBUFFERPROC) dlsym(libGL, "glXCreatePbuffer"); + PFNGLXDESTROYPBUFFERPROC destroyPbuffer = (PFNGLXDESTROYPBUFFERPROC) dlsym(libGL, "glXDestroyPbuffer"); + PFNGLXMAKECURRENTPROC makeCurrent = (PFNGLXMAKECURRENTPROC) dlsym(libGL, "glXMakeCurrent"); + PFNGLXDESTROYCONTEXTPROC destroyContext = (PFNGLXDESTROYCONTEXTPROC) dlsym(libGL, "glXDestroyContext"); + PFNGLXGETCURRENTCONTEXTPROC getCurrentContext = (PFNGLXGETCURRENTCONTEXTPROC) dlsym(libGL, "glXGetCurrentContext"); + if (!chooseFBConfig || !createNewContext || !createPbuffer + || !destroyPbuffer || !makeCurrent || !destroyContext + || !getCurrentContext) { + XCloseDisplay(dpy); + dlclose(libGL); + printf("GraphicsContext3D: error looking up bootstrapping entry points\n"); + return 0; + } + return new GLConnection(dpy, + libGL, + chooseFBConfig, + createNewContext, + createPbuffer, + destroyPbuffer, + makeCurrent, + destroyContext, + getCurrentContext); +} + +GraphicsContext3DInternal::GLConnection::~GLConnection() +{ + XCloseDisplay(m_display); + dlclose(m_libGL); +} + +#endif // OS(LINUX) + GraphicsContext3DInternal::VertexAttribPointerState::VertexAttribPointerState() : enabled(false) , buffer(0) @@ -220,20 +369,12 @@ GraphicsContext3DInternal::VertexAttribPointerState::VertexAttribPointerState() { } -#if PLATFORM(LINUX) -static void* tryLoad(const char* libName) -{ - // We use RTLD_GLOBAL semantics so that GLEW initialization works; - // GLEW expects to be able to open the current process's handle - // and do dlsym's of GL entry points from there. - return dlopen(libName, RTLD_LAZY | RTLD_GLOBAL); -} -#endif - -GraphicsContext3DInternal::GraphicsContext3DInternal() - : m_texture(0) +GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs) + : m_attrs(attrs) + , m_texture(0) , m_fbo(0) , m_depthBuffer(0) + , m_boundFBO(0) #ifdef FLIP_FRAMEBUFFER_VERTICALLY , m_scanline(0) #endif @@ -241,7 +382,7 @@ GraphicsContext3DInternal::GraphicsContext3DInternal() #if PLATFORM(SKIA) , m_resizingBitmap(0) #endif -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) , m_canvasWindow(0) , m_canvasDC(0) , m_contextObj(0) @@ -249,23 +390,24 @@ GraphicsContext3DInternal::GraphicsContext3DInternal() , m_pbuffer(0) , m_contextObj(0) , m_renderOutput(0) - , m_cgContext(0) -#elif PLATFORM(LINUX) - , m_display(0) +#elif OS(LINUX) , m_contextObj(0) , m_pbuffer(0) - , m_glXChooseFBConfig(0) - , m_glXCreateNewContext(0) - , m_glXCreatePbuffer(0) - , m_glXDestroyPbuffer(0) - , m_glXMakeCurrent(0) - , m_glXDestroyContext(0) - , m_glXGetCurrentContext(0) #else #error Must port to your platform #endif { -#if PLATFORM(WIN_OS) + // FIXME: we need to take into account the user's requested + // context creation attributes, in particular stencil and + // antialias, and determine which could and could not be honored + // based on the capabilities of the OpenGL implementation. + m_attrs.alpha = true; + m_attrs.depth = true; + m_attrs.stencil = false; + m_attrs.antialias = false; + m_attrs.premultipliedAlpha = true; + +#if OS(WINDOWS) WNDCLASS wc; if (!GetClassInfo(GetModuleHandle(0), L"CANVASGL", &wc)) { ZeroMemory(&wc, sizeof(WNDCLASS)); @@ -377,43 +519,13 @@ GraphicsContext3DInternal::GraphicsContext3DInternal() } m_pbuffer = pbuffer; m_contextObj = context; -#elif PLATFORM(LINUX) - m_display = XOpenDisplay(0); - if (!m_display) { - printf("GraphicsContext3D: error opening X display\n"); - return; +#elif OS(LINUX) + if (!s_gl) { + s_gl = GLConnection::create(); + if (!s_gl) + return; } - const char* libNames[] = { - "/usr/lib/libGL.so.1", - "/usr/lib32/libGL.so.1", - "/usr/lib64/libGL.so.1", - }; - for (int i = 0; i < sizeof(libNames) / sizeof(const char*); i++) { - m_libGL = tryLoad(libNames[i]); - if (m_libGL) - break; - } - if (!m_libGL) { - printf("GraphicsContext3D: error opening libGL.so.1\n"); - printf("GraphicsContext3D: tried:"); - for (int i = 0; i < sizeof(libNames) / sizeof(const char*); i++) - printf(" %s", libNames[i]); - return; - } - m_glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) dlsym(m_libGL, "glXChooseFBConfig"); - m_glXCreateNewContext = (PFNGLXCREATENEWCONTEXTPROC) dlsym(m_libGL, "glXCreateNewContext"); - m_glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC) dlsym(m_libGL, "glXCreatePbuffer"); - m_glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC) dlsym(m_libGL, "glXDestroyPbuffer"); - m_glXMakeCurrent = (PFNGLXMAKECURRENTPROC) dlsym(m_libGL, "glXMakeCurrent"); - m_glXDestroyContext = (PFNGLXDESTROYCONTEXTPROC) dlsym(m_libGL, "glXDestroyContext"); - m_glXGetCurrentContext = (PFNGLXGETCURRENTCONTEXTPROC) dlsym(m_libGL, "glXGetCurrentContext"); - if (!m_glXChooseFBConfig || !m_glXCreateNewContext || !m_glXCreatePbuffer - || !m_glXDestroyPbuffer || !m_glXMakeCurrent || !m_glXDestroyContext - || !m_glXGetCurrentContext) { - printf("GraphicsContext3D: error looking up bootstrapping entry points\n"); - return; - } int configAttrs[] = { GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, @@ -424,7 +536,7 @@ GraphicsContext3DInternal::GraphicsContext3DInternal() 0 }; int nelements = 0; - GLXFBConfig* config = m_glXChooseFBConfig(m_display, 0, configAttrs, &nelements); + GLXFBConfig* config = s_gl->chooseFBConfig(0, configAttrs, &nelements); if (!config) { printf("GraphicsContext3D: glXChooseFBConfig failed\n"); return; @@ -434,7 +546,7 @@ GraphicsContext3DInternal::GraphicsContext3DInternal() XFree(config); return; } - GLXContext context = m_glXCreateNewContext(m_display, config[0], GLX_RGBA_TYPE, 0, True); + GLXContext context = s_gl->createNewContext(config[0], GLX_RGBA_TYPE, 0, True); if (!context) { printf("GraphicsContext3D: glXCreateNewContext failed\n"); XFree(config); @@ -447,13 +559,13 @@ GraphicsContext3DInternal::GraphicsContext3DInternal() 1, 0 }; - GLXPbuffer pbuffer = m_glXCreatePbuffer(m_display, config[0], pbufferAttrs); + GLXPbuffer pbuffer = s_gl->createPbuffer(config[0], pbufferAttrs); XFree(config); if (!pbuffer) { printf("GraphicsContext3D: glxCreatePbuffer failed\n"); return; } - if (!m_glXMakeCurrent(m_display, pbuffer, context)) { + if (!s_gl->makeCurrent(pbuffer, context)) { printf("GraphicsContext3D: glXMakeCurrent failed\n"); return; } @@ -463,8 +575,7 @@ GraphicsContext3DInternal::GraphicsContext3DInternal() #error Must port to your platform #endif - static bool initializedGLEW = false; - if (!initializedGLEW) { + if (!s_initializedGLEW) { // Initialize GLEW and check for GL 2.0 support by the drivers. GLenum glewInitResult = glewInit(); if (glewInitResult != GLEW_OK) { @@ -475,7 +586,7 @@ GraphicsContext3DInternal::GraphicsContext3DInternal() printf("GraphicsContext3D: OpenGL 2.0 not supported\n"); return; } - initializedGLEW = true; + s_initializedGLEW = true; } } @@ -495,7 +606,7 @@ GraphicsContext3DInternal::~GraphicsContext3DInternal() if (m_resizingBitmap) delete m_resizingBitmap; #endif -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) wglMakeCurrent(0, 0); wglDeleteContext(m_contextObj); ReleaseDC(m_canvasWindow, m_canvasDC); @@ -504,16 +615,12 @@ GraphicsContext3DInternal::~GraphicsContext3DInternal() CGLSetCurrentContext(0); CGLDestroyContext(m_contextObj); CGLDestroyPBuffer(m_pbuffer); - if (m_cgContext) - CGContextRelease(m_cgContext); if (m_renderOutput) delete[] m_renderOutput; -#elif PLATFORM(LINUX) - m_glXMakeCurrent(m_display, 0, 0); - m_glXDestroyContext(m_display, m_contextObj); - m_glXDestroyPbuffer(m_display, m_pbuffer); - XCloseDisplay(m_display); - dlclose(m_libGL); +#elif OS(LINUX) + s_gl->makeCurrent(0, 0); + s_gl->destroyContext(m_contextObj); + s_gl->destroyPbuffer(m_pbuffer); #else #error Must port to your platform #endif @@ -522,7 +629,7 @@ GraphicsContext3DInternal::~GraphicsContext3DInternal() bool GraphicsContext3DInternal::makeContextCurrent() { -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) if (wglGetCurrentContext() != m_contextObj) if (wglMakeCurrent(m_canvasDC, m_contextObj)) return true; @@ -530,9 +637,9 @@ bool GraphicsContext3DInternal::makeContextCurrent() if (CGLGetCurrentContext() != m_contextObj) if (CGLSetCurrentContext(m_contextObj) == kCGLNoError) return true; -#elif PLATFORM(LINUX) - if (m_glXGetCurrentContext() != m_contextObj) - if (m_glXMakeCurrent(m_display, m_pbuffer, m_contextObj)) +#elif OS(LINUX) + if (s_gl->getCurrentContext() != m_contextObj) + if (s_gl->makeCurrent(m_pbuffer, m_contextObj)) return true; #else #error Must port to your platform @@ -594,6 +701,7 @@ void GraphicsContext3DInternal::reshape(int width, int height) glBindTexture(target, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); + m_boundFBO = m_fbo; glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthBuffer); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); @@ -623,20 +731,12 @@ void GraphicsContext3DInternal::reshape(int width, int height) #if PLATFORM(CG) // Need to reallocate the client-side backing store. // FIXME: make this more efficient. - if (m_cgContext) { - CGContextRelease(m_cgContext); - m_cgContext = 0; - } if (m_renderOutput) { delete[] m_renderOutput; m_renderOutput = 0; } int rowBytes = width * 4; m_renderOutput = new unsigned char[height * rowBytes]; - CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); - m_cgContext = CGBitmapContextCreate(m_renderOutput, width, height, 8, rowBytes, - colorSpace, kCGImageAlphaPremultipliedLast); - CGColorSpaceRelease(colorSpace); #endif // PLATFORM(CG) } @@ -681,6 +781,9 @@ void GraphicsContext3DInternal::beginPaint(WebGLRenderingContext* context) HTMLCanvasElement* canvas = context->canvas(); ImageBuffer* imageBuffer = canvas->buffer(); unsigned char* pixels = 0; + bool mustRestoreFBO = (m_boundFBO != m_fbo); + if (mustRestoreFBO) + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); #if PLATFORM(SKIA) const SkBitmap* canvasBitmap = imageBuffer->context()->platformContext()->bitmap(); const SkBitmap* readbackBitmap = 0; @@ -721,15 +824,16 @@ void GraphicsContext3DInternal::beginPaint(WebGLRenderingContext* context) glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_BGRA, GL_UNSIGNED_BYTE, pixels); #elif PLATFORM(CG) if (m_renderOutput) { - ASSERT(CGBitmapContextGetWidth(m_cgContext) == m_cachedWidth); - ASSERT(CGBitmapContextGetHeight(m_cgContext) == m_cachedHeight); pixels = m_renderOutput; - glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels); } #else #error Must port to your platform #endif + if (mustRestoreFBO) + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO); + #ifdef FLIP_FRAMEBUFFER_VERTICALLY if (pixels) flipVertically(pixels, m_cachedWidth, m_cachedHeight); @@ -745,7 +849,20 @@ void GraphicsContext3DInternal::beginPaint(WebGLRenderingContext* context) } #elif PLATFORM(CG) if (m_renderOutput) { - CGImageRef cgImage = CGBitmapContextCreateImage(m_cgContext); + int rowBytes = m_cachedWidth * 4; + CGDataProviderRef dataProvider = CGDataProviderCreateWithData(0, m_renderOutput, rowBytes * m_cachedHeight, 0); + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGImageRef cgImage = CGImageCreate(m_cachedWidth, + m_cachedHeight, + 8, + 32, + rowBytes, + colorSpace, + kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, + dataProvider, + 0, + false, + kCGRenderingIntentDefault); // CSS styling may cause the canvas's content to be resized on // the page. Go back to the Canvas to figure out the correct // width and height to draw. @@ -756,9 +873,13 @@ void GraphicsContext3DInternal::beginPaint(WebGLRenderingContext* context) // rendering results. CGContextSetBlendMode(imageBuffer->context()->platformContext(), kCGBlendModeCopy); + CGContextSetInterpolationQuality(imageBuffer->context()->platformContext(), + kCGInterpolationNone); CGContextDrawImage(imageBuffer->context()->platformContext(), rect, cgImage); CGImageRelease(cgImage); + CGColorSpaceRelease(colorSpace); + CGDataProviderRelease(dataProvider); } #else #error Must port to your platform @@ -788,6 +909,17 @@ void GraphicsContext3DInternal::bindBuffer(unsigned long target, glBindBuffer(target, bufID); } +void GraphicsContext3DInternal::bindFramebuffer(unsigned long target, + WebGLFramebuffer* framebuffer) +{ + makeContextCurrent(); + GLuint id = EXTRACT(framebuffer); + if (!id) + id = m_fbo; + glBindFramebufferEXT(target, id); + m_boundFBO = id; +} + // If we didn't have to hack GL_TEXTURE_WRAP_R for cube maps, // we could just use: // GL_SAME_METHOD_2_X2(BindTexture, bindTexture, unsigned long, WebGLTexture*) @@ -864,6 +996,11 @@ unsigned long GraphicsContext3DInternal::getError() return glGetError(); } +GraphicsContext3D::Attributes GraphicsContext3DInternal::getContextAttributes() +{ + return m_attrs; +} + void GraphicsContext3DInternal::vertexAttribPointer(unsigned long indx, int size, int type, bool normalized, unsigned long stride, unsigned long offset) { @@ -1012,17 +1149,17 @@ void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 gl##glname(a1, a2, a3, a4, a5, a6, a7, a8); \ } -PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create() +PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs) { - PassOwnPtr<GraphicsContext3D> context = new GraphicsContext3D(); + PassOwnPtr<GraphicsContext3D> context = new GraphicsContext3D(attrs); // FIXME: add error checking return context; } -GraphicsContext3D::GraphicsContext3D() +GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs) : m_currentWidth(0) , m_currentHeight(0) - , m_internal(new GraphicsContext3DInternal()) + , m_internal(new GraphicsContext3DInternal(attrs)) { } @@ -1190,7 +1327,10 @@ void GraphicsContext3D::bindBuffer(unsigned long target, m_internal->bindBuffer(target, buffer); } -GL_SAME_METHOD_2_X2(BindFramebufferEXT, bindFramebuffer, unsigned long, WebGLFramebuffer*) +void GraphicsContext3D::bindFramebuffer(unsigned long target, WebGLFramebuffer* framebuffer) +{ + m_internal->bindFramebuffer(target, framebuffer); +} GL_SAME_METHOD_2_X2(BindRenderbufferEXT, bindRenderbuffer, unsigned long, WebGLRenderbuffer*) @@ -1448,6 +1588,11 @@ void GraphicsContext3D::getBufferParameteriv(unsigned long target, unsigned long glGetBufferParameteriv(target, pname, value); } +GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes() +{ + return m_internal->getContextAttributes(); +} + unsigned long GraphicsContext3D::getError() { return m_internal->getError(); @@ -1735,7 +1880,7 @@ int GraphicsContext3D::texImage2D(unsigned target, unsigned border, unsigned format, unsigned type, - WebGLArray* pixels) + void* pixels) { // FIXME: must do validation similar to JOGL's to ensure that // the incoming array is of the appropriate length. @@ -1747,25 +1892,10 @@ int GraphicsContext3D::texImage2D(unsigned target, border, format, type, - pixels->baseAddress()); + pixels); return 0; } -int GraphicsContext3D::texImage2D(unsigned target, - unsigned level, - unsigned internalformat, - unsigned width, - unsigned height, - unsigned border, - unsigned format, - unsigned type, - ImageData* pixels) -{ - // FIXME: implement. - notImplemented(); - return -1; -} - // Remove premultiplied alpha from color channels. // FIXME: this is lossy. Must retrieve original values from HTMLImageElement. static void unmultiplyAlpha(unsigned char* rgbaData, int numPixels) @@ -1926,6 +2056,7 @@ int GraphicsContext3D::texImage2D(unsigned target, unsigned level, Image* image, colorSpace, kCGImageAlphaPremultipliedLast); CGColorSpaceRelease(colorSpace); + CGContextSetBlendMode(tmpContext, kCGBlendModeCopy); CGContextDrawImage(tmpContext, CGRectMake(0, 0, static_cast<CGFloat>(width), static_cast<CGFloat>(height)), cgImage); @@ -1939,14 +2070,6 @@ int GraphicsContext3D::texImage2D(unsigned target, unsigned level, Image* image, return res; } -int GraphicsContext3D::texImage2D(unsigned target, unsigned level, HTMLVideoElement* video, - bool flipY, bool premultiplyAlpha) -{ - // FIXME: implement. - notImplemented(); - return -1; -} - GL_SAME_METHOD_3(TexParameterf, texParameterf, unsigned, unsigned, float); GL_SAME_METHOD_3(TexParameteri, texParameteri, unsigned, unsigned, int); @@ -1959,34 +2082,16 @@ int GraphicsContext3D::texSubImage2D(unsigned target, unsigned height, unsigned format, unsigned type, - WebGLArray* pixels) + void* pixels) { - // FIXME: implement. - notImplemented(); - return -1; -} - -int GraphicsContext3D::texSubImage2D(unsigned target, - unsigned level, - unsigned xoffset, - unsigned yoffset, - unsigned width, - unsigned height, - unsigned format, - unsigned type, - ImageData* pixels) -{ - // FIXME: implement. - notImplemented(); - return -1; + glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + return 0; } int GraphicsContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, - unsigned width, - unsigned height, Image* image, bool flipY, bool premultiplyAlpha) @@ -1996,21 +2101,6 @@ int GraphicsContext3D::texSubImage2D(unsigned target, return -1; } -int GraphicsContext3D::texSubImage2D(unsigned target, - unsigned level, - unsigned xoffset, - unsigned yoffset, - unsigned width, - unsigned height, - HTMLVideoElement* video, - bool flipY, - bool premultiplyAlpha) -{ - // FIXME: implement. - notImplemented(); - return -1; -} - GL_SAME_METHOD_2(Uniform1f, uniform1f, long, float) void GraphicsContext3D::uniform1fv(long location, float* v, int size) diff --git a/WebKit/chromium/src/LocalizedStrings.cpp b/WebKit/chromium/src/LocalizedStrings.cpp index 1121931..4e01848 100644 --- a/WebKit/chromium/src/LocalizedStrings.cpp +++ b/WebKit/chromium/src/LocalizedStrings.cpp @@ -165,6 +165,16 @@ String AXLinkActionVerb() return query(WebLocalizedString::AXLinkActionVerb); } +String AXMenuListPopupActionVerb() +{ + return String(); +} + +String AXMenuListActionVerb() +{ + return String(); +} + String multipleFileUploadText(unsigned numberOfFiles) { return query(WebLocalizedString::MultipleFileUploadText, numberOfFiles); diff --git a/WebKit/chromium/src/NotificationPresenterImpl.cpp b/WebKit/chromium/src/NotificationPresenterImpl.cpp index 6b22319..a38b8b5 100644 --- a/WebKit/chromium/src/NotificationPresenterImpl.cpp +++ b/WebKit/chromium/src/NotificationPresenterImpl.cpp @@ -33,12 +33,15 @@ #if ENABLE(NOTIFICATIONS) +#include "Document.h" #include "Notification.h" #include "SecurityOrigin.h" +#include "WebDocument.h" #include "WebNotification.h" #include "WebNotificationPermissionCallback.h" #include "WebNotificationPresenter.h" +#include "WebURL.h" #include <wtf/PassRefPtr.h> @@ -89,9 +92,13 @@ void NotificationPresenterImpl::notificationObjectDestroyed(Notification* notifi m_presenter->objectDestroyed(PassRefPtr<Notification>(notification)); } -NotificationPresenter::Permission NotificationPresenterImpl::checkPermission(SecurityOrigin* origin) +NotificationPresenter::Permission NotificationPresenterImpl::checkPermission(const KURL& url, Document* document) { - int result = m_presenter->checkPermission(origin->toString()); + WebDocument webDocument; + if (document) + webDocument = document; + + int result = m_presenter->checkPermission(url, document ? &webDocument : 0); return static_cast<NotificationPresenter::Permission>(result); } diff --git a/WebKit/chromium/src/NotificationPresenterImpl.h b/WebKit/chromium/src/NotificationPresenterImpl.h index 4afe9dc..8e3799c 100644 --- a/WebKit/chromium/src/NotificationPresenterImpl.h +++ b/WebKit/chromium/src/NotificationPresenterImpl.h @@ -54,7 +54,7 @@ public: virtual bool show(WebCore::Notification* object); virtual void cancel(WebCore::Notification* object); virtual void notificationObjectDestroyed(WebCore::Notification* object); - virtual WebCore::NotificationPresenter::Permission checkPermission(WebCore::SecurityOrigin* origin); + virtual WebCore::NotificationPresenter::Permission checkPermission(const WebCore::KURL& url, WebCore::Document* document); virtual void requestPermission(WebCore::SecurityOrigin* origin, WTF::PassRefPtr<WebCore::VoidCallback> callback); private: diff --git a/WebKit/chromium/src/PlatformMessagePortChannel.cpp b/WebKit/chromium/src/PlatformMessagePortChannel.cpp index f8c41d3..aa42a10 100644 --- a/WebKit/chromium/src/PlatformMessagePortChannel.cpp +++ b/WebKit/chromium/src/PlatformMessagePortChannel.cpp @@ -179,7 +179,7 @@ void PlatformMessagePortChannel::postMessageToRemote(PassOwnPtr<MessagePortChann if (!m_localPort || !m_webChannel) return; - WebString messageString = message->message()->toString(); + WebString messageString = message->message()->toWireString(); OwnPtr<WebCore::MessagePortChannelArray> channels = message->channels(); WebMessagePortChannelArray* webChannels = 0; if (channels.get() && channels->size()) { @@ -211,7 +211,7 @@ bool PlatformMessagePortChannel::tryGetMessageFromRemote(OwnPtr<MessagePortChann (*channels)[i] = MessagePortChannel::create(platformChannel); } } - RefPtr<SerializedScriptValue> serializedMessage = SerializedScriptValue::create(message); + RefPtr<SerializedScriptValue> serializedMessage = SerializedScriptValue::createFromWire(message); result = MessagePortChannel::EventData::create(serializedMessage.release(), channels.release()); } diff --git a/WebKit/chromium/src/StorageAreaProxy.cpp b/WebKit/chromium/src/StorageAreaProxy.cpp index 551507f..c9185fe 100644 --- a/WebKit/chromium/src/StorageAreaProxy.cpp +++ b/WebKit/chromium/src/StorageAreaProxy.cpp @@ -1,5 +1,6 @@ /* * 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 @@ -28,11 +29,16 @@ #if ENABLE(DOM_STORAGE) +#include "DOMWindow.h" #include "Document.h" +#include "EventNames.h" #include "ExceptionCode.h" #include "Frame.h" +#include "Page.h" +#include "PageGroup.h" #include "SecurityOrigin.h" #include "StorageAreaImpl.h" +#include "StorageEvent.h" #include "WebStorageArea.h" #include "WebString.h" @@ -40,8 +46,9 @@ namespace WebCore { -StorageAreaProxy::StorageAreaProxy(WebKit::WebStorageArea* storageArea) +StorageAreaProxy::StorageAreaProxy(WebKit::WebStorageArea* storageArea, StorageType storageType) : m_storageArea(storageArea) + , m_storageType(storageType) { } @@ -64,21 +71,34 @@ String StorageAreaProxy::getItem(const String& key) const return m_storageArea->getItem(key); } -void StorageAreaProxy::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame) +String StorageAreaProxy::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame) { bool quotaException = false; - m_storageArea->setItem(key, value, frame->document()->url(), quotaException); + WebKit::WebString oldValue; + m_storageArea->setItem(key, value, frame->document()->url(), quotaException, oldValue); ec = quotaException ? QUOTA_EXCEEDED_ERR : 0; + String oldValueString = oldValue; + if (oldValueString != value) + storageEvent(key, oldValue, value, m_storageType, frame->document()->securityOrigin(), frame); + return oldValue; } -void StorageAreaProxy::removeItem(const String& key, Frame* frame) +String StorageAreaProxy::removeItem(const String& key, Frame* frame) { - m_storageArea->removeItem(key, frame->document()->url()); + WebKit::WebString oldValue; + m_storageArea->removeItem(key, frame->document()->url(), oldValue); + if (!oldValue.isNull()) + storageEvent(key, oldValue, String(), m_storageType, frame->document()->securityOrigin(), frame); + return oldValue; } -void StorageAreaProxy::clear(Frame* frame) +bool StorageAreaProxy::clear(Frame* frame) { - m_storageArea->clear(frame->document()->url()); + bool clearedSomething; + m_storageArea->clear(frame->document()->url(), clearedSomething); + if (clearedSomething) + storageEvent(String(), String(), String(), m_storageType, frame->document()->securityOrigin(), frame); + return clearedSomething; } bool StorageAreaProxy::contains(const String& key) const @@ -86,6 +106,41 @@ bool StorageAreaProxy::contains(const String& key) const return !getItem(key).isNull(); } +// Copied from WebCore/storage/StorageEventDispatcher.cpp out of necessity. It's probably best to keep it current. +void StorageAreaProxy::storageEvent(const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin, Frame* sourceFrame) +{ + Page* page = sourceFrame->page(); + if (!page) + return; + + // We need to copy all relevant frames from every page to a vector since sending the event to one frame might mutate the frame tree + // of any given page in the group or mutate the page group itself. + Vector<RefPtr<Frame> > frames; + if (storageType == SessionStorage) { + // Send events only to our page. + for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) { + if (sourceFrame != frame && frame->document()->securityOrigin()->equal(securityOrigin)) + frames.append(frame); + } + + for (unsigned i = 0; i < frames.size(); ++i) + frames[i]->document()->enqueueStorageEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), frames[i]->domWindow()->sessionStorage())); + } else { + // Send events to every page. + const HashSet<Page*>& pages = page->group().pages(); + HashSet<Page*>::const_iterator end = pages.end(); + for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { + for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) { + if (sourceFrame != frame && frame->document()->securityOrigin()->equal(securityOrigin)) + frames.append(frame); + } + } + + for (unsigned i = 0; i < frames.size(); ++i) + frames[i]->document()->enqueueStorageEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), frames[i]->domWindow()->localStorage())); + } +} + } // namespace WebCore #endif // ENABLE(DOM_STORAGE) diff --git a/WebKit/chromium/src/StorageAreaProxy.h b/WebKit/chromium/src/StorageAreaProxy.h index 5d09d82..b169828 100644 --- a/WebKit/chromium/src/StorageAreaProxy.h +++ b/WebKit/chromium/src/StorageAreaProxy.h @@ -34,22 +34,28 @@ namespace WebKit { class WebStorageArea; } namespace WebCore { +class Frame; +class SecurityOrigin; + class StorageAreaProxy : public StorageArea { public: - StorageAreaProxy(WebKit::WebStorageArea* storageArea); + StorageAreaProxy(WebKit::WebStorageArea*, StorageType); virtual ~StorageAreaProxy(); // The HTML5 DOM Storage API virtual unsigned length() const; virtual String key(unsigned index) const; virtual String getItem(const String& key) const; - virtual void setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame); - virtual void removeItem(const String& key, Frame* sourceFrame); - virtual void clear(Frame* sourceFrame); + virtual String setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame); + virtual String removeItem(const String& key, Frame* sourceFrame); + virtual bool clear(Frame* sourceFrame); virtual bool contains(const String& key) const; private: + void storageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Frame* sourceFrame); + OwnPtr<WebKit::WebStorageArea> m_storageArea; + StorageType m_storageType; }; } // namespace WebCore diff --git a/WebKit/chromium/src/StorageNamespaceProxy.cpp b/WebKit/chromium/src/StorageNamespaceProxy.cpp index e22bbef..1be1967 100644 --- a/WebKit/chromium/src/StorageNamespaceProxy.cpp +++ b/WebKit/chromium/src/StorageNamespaceProxy.cpp @@ -28,27 +28,35 @@ #if ENABLE(DOM_STORAGE) +#include "Chrome.h" +#include "ChromeClientImpl.h" +#include "Page.h" #include "SecurityOrigin.h" #include "StorageAreaProxy.h" #include "WebKit.h" #include "WebKitClient.h" #include "WebStorageNamespace.h" #include "WebString.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" namespace WebCore { PassRefPtr<StorageNamespace> StorageNamespace::localStorageNamespace(const String& path, unsigned quota) { - return new StorageNamespaceProxy(WebKit::webKitClient()->createLocalStorageNamespace(path, quota)); + return adoptRef(new StorageNamespaceProxy(WebKit::webKitClient()->createLocalStorageNamespace(path, quota), LocalStorage)); } -PassRefPtr<StorageNamespace> StorageNamespace::sessionStorageNamespace() +PassRefPtr<StorageNamespace> StorageNamespace::sessionStorageNamespace(Page* page) { - return new StorageNamespaceProxy(WebKit::webKitClient()->createSessionStorageNamespace()); + WebKit::ChromeClientImpl* chromeClientImpl = static_cast<WebKit::ChromeClientImpl*>(page->chrome()->client()); + WebKit::WebViewClient* webViewClient = chromeClientImpl->webView()->client(); + return adoptRef(new StorageNamespaceProxy(webViewClient->createSessionStorageNamespace(), SessionStorage)); } -StorageNamespaceProxy::StorageNamespaceProxy(WebKit::WebStorageNamespace* storageNamespace) +StorageNamespaceProxy::StorageNamespaceProxy(WebKit::WebStorageNamespace* storageNamespace, StorageType storageType) : m_storageNamespace(storageNamespace) + , m_storageType(storageType) { } @@ -58,12 +66,19 @@ StorageNamespaceProxy::~StorageNamespaceProxy() PassRefPtr<StorageNamespace> StorageNamespaceProxy::copy() { - return adoptRef(new StorageNamespaceProxy(m_storageNamespace->copy())); + ASSERT(m_storageType == SessionStorage); + // The WebViewClient knows what its session storage namespace id is but we + // do not. Returning 0 here causes it to be fetched (via the WebViewClient) + // on its next use. Note that it is WebViewClient::createView's + // responsibility to clone the session storage namespace id and that the + // only time copy() is called is directly after the createView call...which + // is why all of this is safe. + return 0; } PassRefPtr<StorageArea> StorageNamespaceProxy::storageArea(PassRefPtr<SecurityOrigin> origin) { - return adoptRef(new StorageAreaProxy(m_storageNamespace->createStorageArea(origin->toString()))); + return adoptRef(new StorageAreaProxy(m_storageNamespace->createStorageArea(origin->toString()), m_storageType)); } void StorageNamespaceProxy::close() diff --git a/WebKit/chromium/src/StorageNamespaceProxy.h b/WebKit/chromium/src/StorageNamespaceProxy.h index 9ff624b..28d7a23 100644 --- a/WebKit/chromium/src/StorageNamespaceProxy.h +++ b/WebKit/chromium/src/StorageNamespaceProxy.h @@ -28,6 +28,7 @@ #if ENABLE(DOM_STORAGE) +#include "StorageArea.h" #include "StorageNamespace.h" namespace WebKit { class WebStorageNamespace; } @@ -36,7 +37,7 @@ namespace WebCore { class StorageNamespaceProxy : public StorageNamespace { public: - StorageNamespaceProxy(WebKit::WebStorageNamespace* storageNamespace); + StorageNamespaceProxy(WebKit::WebStorageNamespace*, StorageType); virtual ~StorageNamespaceProxy(); virtual PassRefPtr<StorageArea> storageArea(PassRefPtr<SecurityOrigin>); virtual PassRefPtr<StorageNamespace> copy(); @@ -45,6 +46,7 @@ public: private: OwnPtr<WebKit::WebStorageNamespace> m_storageNamespace; + StorageType m_storageType; }; } // namespace WebCore diff --git a/WebKit/chromium/src/WebAccessibilityObject.cpp b/WebKit/chromium/src/WebAccessibilityObject.cpp index bdbd260..c386d44 100644 --- a/WebKit/chromium/src/WebAccessibilityObject.cpp +++ b/WebKit/chromium/src/WebAccessibilityObject.cpp @@ -231,13 +231,13 @@ bool WebAccessibilityObject::isIndeterminate() const return m_private->isIndeterminate(); } -bool WebAccessibilityObject::isMultiSelect() const +bool WebAccessibilityObject::isMultiSelectable() const { if (!m_private) return 0; m_private->updateBackingStore(); - return m_private->isMultiSelect(); + return m_private->isMultiSelectable(); } bool WebAccessibilityObject::isOffScreen() const diff --git a/WebKit/chromium/src/WebAnimationControllerImpl.cpp b/WebKit/chromium/src/WebAnimationControllerImpl.cpp new file mode 100644 index 0000000..32a7a61 --- /dev/null +++ b/WebKit/chromium/src/WebAnimationControllerImpl.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebAnimationControllerImpl.h" + +#include "AnimationController.h" +#include "Element.h" + +#include "WebElement.h" +#include "WebFrameImpl.h" +#include "WebString.h" + +using namespace WebCore; + +namespace WebKit { + +WebAnimationControllerImpl::WebAnimationControllerImpl(WebFrameImpl* frameImpl) + : m_frameImpl(frameImpl) +{ + ASSERT(m_frameImpl); +} + +AnimationController* WebAnimationControllerImpl::animationController() const +{ + if (!m_frameImpl->frame()) + return 0; + return m_frameImpl->frame()->animation(); +} + +bool WebAnimationControllerImpl::pauseAnimationAtTime(WebElement& element, + const WebString& animationName, + double time) +{ + AnimationController* controller = animationController(); + if (!controller) + return 0; + return controller->pauseAnimationAtTime(PassRefPtr<Element>(element)->renderer(), + animationName, + time); +} + +bool WebAnimationControllerImpl::pauseTransitionAtTime(WebElement& element, + const WebString& propertyName, + double time) +{ + AnimationController* controller = animationController(); + if (!controller) + return 0; + return controller->pauseTransitionAtTime(PassRefPtr<Element>(element)->renderer(), + propertyName, + time); +} + +unsigned WebAnimationControllerImpl::numberOfActiveAnimations() const +{ + AnimationController* controller = animationController(); + if (!controller) + return 0; + return controller->numberOfActiveAnimations(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebAnimationControllerImpl.h b/WebKit/chromium/src/WebAnimationControllerImpl.h new file mode 100644 index 0000000..8b0676e --- /dev/null +++ b/WebKit/chromium/src/WebAnimationControllerImpl.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebAnimationControllerImpl_h +#define WebAnimationControllerImpl_h + +// FIXME: This relative path is a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebAnimationController.h" + +namespace WebCore { +class AnimationController; +} + +namespace WebKit { +class WebFrameImpl; + +class WebAnimationControllerImpl : public WebAnimationController { +public: + explicit WebAnimationControllerImpl(WebFrameImpl*); + virtual ~WebAnimationControllerImpl() { } + + virtual bool pauseAnimationAtTime(WebElement&, + const WebString& animationName, + double time); + virtual bool pauseTransitionAtTime(WebElement&, + const WebString& propertyName, + double time); + virtual unsigned numberOfActiveAnimations() const; +private: + WebFrameImpl* m_frameImpl; + WebCore::AnimationController* animationController() const; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebBindings.cpp b/WebKit/chromium/src/WebBindings.cpp index 0bc67b6..04f2f85 100644 --- a/WebKit/chromium/src/WebBindings.cpp +++ b/WebKit/chromium/src/WebBindings.cpp @@ -44,9 +44,12 @@ #include "MouseEvent.h" #include "NPV8Object.h" // for PrivateIdentifier #include "Range.h" +#include "V8BindingState.h" #include "V8DOMWrapper.h" +#include "V8Event.h" #include "V8Helpers.h" #include "V8Proxy.h" +#include "V8Range.h" #elif USE(JSC) #include "bridge/c/c_utility.h" #endif @@ -223,20 +226,20 @@ static bool getDragDataImpl(NPObject* npobj, int* eventId, WebDragData* data) // Get the current WebCore event. v8::Handle<v8::Value> currentEvent(getEvent(context)); - Event* event = V8DOMWrapper::convertToNativeEvent(currentEvent); + Event* event = V8Event::toNative(v8::Handle<v8::Object>::Cast(currentEvent)); if (!event) return false; // Check that the given npobj is that event. V8NPObject* object = reinterpret_cast<V8NPObject*>(npobj); - Event* given = V8DOMWrapper::convertToNativeEvent(object->v8Object); + Event* given = V8Event::toNative(object->v8Object); if (given != event) return false; // Check the execution frames are same origin. V8Proxy* current = V8Proxy::retrieve(V8Proxy::retrieveFrameForCurrentContext()); Frame* frame = V8Proxy::retrieveFrame(context); - if (!current || !current->canAccessFrame(frame, false)) + if (!current || !V8BindingSecurity::canAccessFrame(V8BindingState::Only(), frame, false)) return false; const EventNames& names(eventNames()); @@ -284,7 +287,7 @@ static bool getRangeImpl(NPObject* npobj, WebRange* range) if (V8ClassIndex::RANGE != V8DOMWrapper::domWrapperType(v8object)) return false; - Range* native = V8DOMWrapper::convertToNativeObject<WebCore::Range>(V8ClassIndex::RANGE, v8object); + Range* native = V8Range::toNative(v8object); if (!native) return false; diff --git a/WebKit/chromium/src/WebDataSourceImpl.cpp b/WebKit/chromium/src/WebDataSourceImpl.cpp index 456706a..5a315cf 100644 --- a/WebKit/chromium/src/WebDataSourceImpl.cpp +++ b/WebKit/chromium/src/WebDataSourceImpl.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "WebDataSourceImpl.h" +#include "ApplicationCacheHostInternal.h" #include "WebURL.h" #include "WebURLError.h" #include "WebVector.h" @@ -108,6 +109,14 @@ void WebDataSourceImpl::setExtraData(ExtraData* extraData) m_extraData.set(extraData); } +WebApplicationCacheHost* WebDataSourceImpl::applicationCacheHost() { +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + return ApplicationCacheHostInternal::toWebApplicationCacheHost(DocumentLoader::applicationCacheHost()); +#else + return 0; +#endif +} + WebNavigationType WebDataSourceImpl::toWebNavigationType(NavigationType type) { switch (type) { diff --git a/WebKit/chromium/src/WebDataSourceImpl.h b/WebKit/chromium/src/WebDataSourceImpl.h index 8860fe4..f868e95 100644 --- a/WebKit/chromium/src/WebDataSourceImpl.h +++ b/WebKit/chromium/src/WebDataSourceImpl.h @@ -46,7 +46,6 @@ #include <wtf/PassOwnPtr.h> #include <wtf/Vector.h> - namespace WebKit { class WebPluginLoadObserver; @@ -73,6 +72,7 @@ public: virtual double triggeringEventTime() const; virtual ExtraData* extraData() const; virtual void setExtraData(ExtraData*); + virtual WebApplicationCacheHost* applicationCacheHost(); static WebNavigationType toWebNavigationType(WebCore::NavigationType type); diff --git a/WebKit/chromium/src/WebDocument.cpp b/WebKit/chromium/src/WebDocument.cpp new file mode 100644 index 0000000..84f3004 --- /dev/null +++ b/WebKit/chromium/src/WebDocument.cpp @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebDocument.h" + +#include "Document.h" +#include "DocumentLoader.h" +#include "Element.h" +#include "HTMLAllCollection.h" +#include "HTMLBodyElement.h" +#include "HTMLCollection.h" +#include "HTMLElement.h" +#include "HTMLHeadElement.h" +#include "NodeList.h" + +#include "WebElement.h" +#include "WebFrameImpl.h" +#include "WebNodeCollection.h" +#include "WebURL.h" + +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +WebDocument::WebDocument(const PassRefPtr<Document>& elem) + : WebNode(elem.releaseRef()) +{ +} + +WebDocument& WebDocument::operator=(const PassRefPtr<Document>& elem) +{ + WebNode::assign(elem.releaseRef()); + return *this; +} + +WebDocument::operator PassRefPtr<Document>() const +{ + return PassRefPtr<Document>(static_cast<Document*>(m_private)); +} + +WebFrame* WebDocument::frame() const +{ + return WebFrameImpl::fromFrame(constUnwrap<Document>()->frame()); +} + +bool WebDocument::isHTMLDocument() const +{ + return constUnwrap<Document>()->isHTMLDocument(); +} + +WebURL WebDocument::baseURL() const +{ + return constUnwrap<Document>()->baseURL(); +} + +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()); +} + +WebNodeCollection WebDocument::all() +{ + return WebNodeCollection(unwrap<Document>()->all()); +} + +WebURL WebDocument::completeURL(const WebString& partialURL) const +{ + return constUnwrap<Document>()->completeURL(partialURL); +} + +WebElement WebDocument::getElementById(const WebString& id) const +{ + return WebElement(constUnwrap<Document>()->getElementById(id)); +} + +WebString WebDocument::applicationID() const +{ + const char* kChromeApplicationHeader = "x-chrome-application"; + + // First check if the document's response included a header indicating the + // application it should go with. + const Document* document = constUnwrap<Document>(); + Frame* frame = document->frame(); + if (!frame) + return WebString(); + + DocumentLoader* loader = frame->loader()->documentLoader(); + if (!loader) + return WebString(); + + WebString headerValue = + loader->response().httpHeaderField(kChromeApplicationHeader); + if (!headerValue.isEmpty()) + return headerValue; + + // Otherwise, fall back to looking for the meta tag. + RefPtr<NodeList> metaTags = + const_cast<Document*>(document)->getElementsByTagName("meta"); + for (unsigned i = 0; i < metaTags->length(); ++i) { + Element* element = static_cast<Element*>(metaTags->item(i)); + if (element->getAttribute("http-equiv").lower() == + kChromeApplicationHeader) { + return element->getAttribute("value"); + } + } + + return WebString(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebDragData.cpp b/WebKit/chromium/src/WebDragData.cpp index 4af1119..3bd4a02 100644 --- a/WebKit/chromium/src/WebDragData.cpp +++ b/WebKit/chromium/src/WebDragData.cpp @@ -88,6 +88,18 @@ void WebDragData::setURLTitle(const WebString& urlTitle) m_private->urlTitle = urlTitle; } +WebURL WebDragData::downloadURL() const +{ + ASSERT(!isNull()); + return m_private->downloadURL; +} + +void WebDragData::setDownloadURL(const WebURL& downloadURL) +{ + ensureMutable(); + m_private->downloadURL = downloadURL; +} + WebString WebDragData::fileExtension() const { ASSERT(!isNull()); diff --git a/WebKit/chromium/src/WebElement.cpp b/WebKit/chromium/src/WebElement.cpp index 3f13ee1..d0a0862 100644 --- a/WebKit/chromium/src/WebElement.cpp +++ b/WebKit/chromium/src/WebElement.cpp @@ -54,5 +54,38 @@ WebElement::operator WTF::PassRefPtr<Element>() const return PassRefPtr<Element>(static_cast<Element*>(m_private)); } +WebString WebElement::tagName() const +{ + return constUnwrap<Element>()->tagName(); +} + +bool WebElement::hasTagName(const WebString& tagName) const +{ + return equalIgnoringCase(constUnwrap<Element>()->tagName(), + tagName.operator WebCore::String()); +} + +bool WebElement::hasAttribute(const WebString& attrName) const +{ + return constUnwrap<Element>()->hasAttribute(attrName); +} + +WebString WebElement::getAttribute(const WebString& attrName) const +{ + return constUnwrap<Element>()->getAttribute(attrName); +} + +bool WebElement::setAttribute(const WebString& attrName, const WebString& attrValue) +{ + ExceptionCode exceptionCode = 0; + unwrap<Element>()->setAttribute(attrName, attrValue, exceptionCode); + return !exceptionCode; +} + +WebString WebElement::innerText() const +{ + return constUnwrap<Element>()->innerText(); +} + } // namespace WebKit diff --git a/WebKit/chromium/src/WebEntities.cpp b/WebKit/chromium/src/WebEntities.cpp new file mode 100644 index 0000000..b9143d9 --- /dev/null +++ b/WebKit/chromium/src/WebEntities.cpp @@ -0,0 +1,133 @@ +/* + * 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 <string.h> + +#include "PlatformString.h" +#include "StringBuilder.h" +#include <wtf/HashMap.h> + +#include "WebString.h" + +using namespace WebCore; + +namespace { +// Note that this file is also included by HTMLTokenizer.cpp so we are getting +// two copies of the data in memory. We can fix this by changing the script +// that generated the array to create a static const that is its length, but +// this is low priority since the data is less than 4K. We use anonymous +// namespace to prevent name collisions. +#include "HTMLEntityNames.c" // NOLINT +} + +namespace WebKit { + +void populateMap(WTF::HashMap<int, WebCore::String>& map, + const Entity* entities, + size_t entitiesCount, + bool standardHTML) +{ + ASSERT(map.isEmpty()); + const Entity* entity = &entities[0]; + for (size_t i = 0; i < entitiesCount; i++, entity++) { + int code = entity->code; + String name = entity->name; + // For consistency, use the lowe case for entities that have both. + if (map.contains(code) && map.get(code) == name.lower()) + continue; + // Don't register %, ⊅ and &supl;. + if (standardHTML && (code == '%' || code == 0x2285 || code == 0x00b9)) + continue; + map.set(code, name); + } + if (standardHTML) + map.set(static_cast<int>(0x0027), String("#39")); +} + +static const Entity xmlBuiltInEntityCodes[] = { + { "lt", 0x003c }, + { "gt", 0x003e }, + { "amp", 0x0026 }, + { "apos", 0x0027 }, + { "quot", 0x0022 } +}; + +WebEntities::WebEntities(bool xmlEntities) +{ + if (xmlEntities) + populateMap(m_entitiesMap, + xmlBuiltInEntityCodes, + sizeof(xmlBuiltInEntityCodes) / sizeof(Entity), + false); + else + populateMap(m_entitiesMap, + wordlist, + sizeof(wordlist) / sizeof(Entity), + true); +} + +String WebEntities::entityNameByCode(int code) const +{ + if (m_entitiesMap.contains(code)) + return m_entitiesMap.get(code); + return ""; +} + +String WebEntities::convertEntitiesInString(const String& value) const +{ + unsigned len = value.length(); + const UChar* startPos = value.characters(); + const UChar* curPos = startPos; + + // FIXME: Optimize - create StringBuilder only if value has any entities. + StringBuilder result; + while (len--) { + if (m_entitiesMap.contains(*curPos)) { + // Append content before entity code. + if (curPos > startPos) + result.append(String(startPos, curPos - startPos)); + result.append("&"); + result.append(m_entitiesMap.get(*curPos)); + result.append(";"); + startPos = ++curPos; + } else + curPos++; + } + // Append the remaining content. + if (curPos > startPos) + result.append(String(startPos, curPos - startPos)); + + return result.toString(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebEntities.h b/WebKit/chromium/src/WebEntities.h new file mode 100644 index 0000000..ad3c310 --- /dev/null +++ b/WebKit/chromium/src/WebEntities.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebEntities_h +#define WebEntities_h + +#include "PlatformString.h" +#include <wtf/HashMap.h> + +namespace WebKit { + +class WebEntities { +public: + // ', %, ⊅, &supl; are not defined by the HTML standards. + // - IE does not support ' as an HTML entity (but support it as an XML + // entity.) + // - Firefox supports ' as an HTML entity. + // - Both of IE and Firefox don't support %, ⊅ 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 ', and don't use entity references for %, ⊅ + // 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. + WebCore::String entityNameByCode(int code) const; + + // Returns a new string with corresponding entity names replaced. + WebCore::String convertEntitiesInString(const WebCore::String&) const; +private: + typedef HashMap<int, WebCore::String> EntitiesMapType; + // An internal object that maps the Unicode character to corresponding + // entity notation. + EntitiesMapType m_entitiesMap; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebEvent.cpp b/WebKit/chromium/src/WebEvent.cpp new file mode 100644 index 0000000..8c68959 --- /dev/null +++ b/WebKit/chromium/src/WebEvent.cpp @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebEvent.h" + +#include "Event.h" +#include "Node.h" +#include <wtf/PassRefPtr.h> + +namespace WebKit { + +class WebEventPrivate : public WebCore::Event { +}; + +void WebEvent::reset() +{ + assign(0); +} + +void WebEvent::assign(const WebEvent& other) +{ + WebEventPrivate* p = const_cast<WebEventPrivate*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +void WebEvent::assign(WebEventPrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +WebEvent::WebEvent(const WTF::PassRefPtr<WebCore::Event>& event) + : m_private(static_cast<WebEventPrivate*>(event.releaseRef())) +{ +} + +WebString WebEvent::type() const +{ + ASSERT(m_private); + return m_private->type(); +} + +WebNode WebEvent::target() const +{ + ASSERT(m_private); + return WebNode(m_private->target()->toNode()); +} + +WebNode WebEvent::currentTarget() const +{ + ASSERT(m_private); + return WebNode(m_private->currentTarget()->toNode()); +} + +WebEvent::PhaseType WebEvent::eventPhase() const +{ + ASSERT(m_private); + return static_cast<WebEvent::PhaseType>(m_private->eventPhase()); +} + +bool WebEvent::bubbles() const +{ + ASSERT(m_private); + return m_private->bubbles(); +} + +bool WebEvent::cancelable() const +{ + ASSERT(m_private); + return m_private->cancelable(); +} + +bool WebEvent::isUIEvent() const +{ + ASSERT(m_private); + return m_private->isUIEvent(); +} + +bool WebEvent::isMouseEvent() const +{ + ASSERT(m_private); + return m_private->isMouseEvent(); +} + +bool WebEvent::isMutationEvent() const +{ + ASSERT(m_private); + return m_private->isMutationEvent(); +} + +bool WebEvent::isKeyboardEvent() const +{ + ASSERT(m_private); + return m_private->isKeyboardEvent(); +} + +bool WebEvent::isTextEvent() const +{ + ASSERT(m_private); + return m_private->isTextEvent(); +} + +bool WebEvent::isCompositionEvent() const +{ + ASSERT(m_private); + return m_private->isCompositionEvent(); +} + +bool WebEvent::isDragEvent() const +{ + ASSERT(m_private); + return m_private->isDragEvent(); +} + +bool WebEvent::isClipboardEvent() const +{ + ASSERT(m_private); + return m_private->isClipboardEvent(); +} + +bool WebEvent::isMessageEvent() const +{ + ASSERT(m_private); + return m_private->isMessageEvent(); +} + +bool WebEvent::isWheelEvent() const +{ + ASSERT(m_private); + return m_private->isWheelEvent(); +} + +bool WebEvent::isBeforeTextInsertedEvent() const +{ + ASSERT(m_private); + return m_private->isBeforeTextInsertedEvent(); +} + +bool WebEvent::isOverflowEvent() const +{ + ASSERT(m_private); + return m_private->isOverflowEvent(); +} + +bool WebEvent::isPageTransitionEvent() const +{ + ASSERT(m_private); + return m_private->isPageTransitionEvent(); +} + +bool WebEvent::isPopStateEvent() const +{ + ASSERT(m_private); + return m_private->isPopStateEvent(); +} + +bool WebEvent::isProgressEvent() const +{ + ASSERT(m_private); + return m_private->isProgressEvent(); +} + +bool WebEvent::isXMLHttpRequestProgressEvent() const +{ + ASSERT(m_private); + return m_private->isXMLHttpRequestProgressEvent(); +} + +bool WebEvent::isWebKitAnimationEvent() const +{ + ASSERT(m_private); + return m_private->isWebKitAnimationEvent(); +} + +bool WebEvent::isWebKitTransitionEvent() const +{ + ASSERT(m_private); + return m_private->isWebKitTransitionEvent(); +} + +bool WebEvent::isBeforeLoadEvent() const +{ + ASSERT(m_private); + return m_private->isBeforeLoadEvent(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebEventListener.cpp b/WebKit/chromium/src/WebEventListener.cpp new file mode 100644 index 0000000..8d9a887 --- /dev/null +++ b/WebKit/chromium/src/WebEventListener.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 "WebEventListener.h"
+
+#include "WebEventListenerPrivate.h"
+
+namespace WebKit {
+
+WebEventListener::WebEventListener()
+ : m_private(new WebEventListenerPrivate(this))
+{
+}
+
+WebEventListener::~WebEventListener()
+{
+ m_private->webEventListenerDeleted();
+ delete m_private;
+}
+
+void WebEventListener::notifyEventListenerDeleted(EventListenerWrapper* wrapper)
+{
+ m_private->eventListenerDeleted(wrapper);
+}
+
+EventListenerWrapper* WebEventListener::createEventListenerWrapper(const WebString& eventType, bool useCapture, Node* node)
+{
+ return m_private->createEventListenerWrapper(eventType, useCapture, node);
+}
+
+EventListenerWrapper* WebEventListener::getEventListenerWrapper(const WebString& eventType, bool useCapture, Node* node)
+{
+ return m_private->getEventListenerWrapper(eventType, useCapture, node);
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebEventListenerPrivate.cpp b/WebKit/chromium/src/WebEventListenerPrivate.cpp new file mode 100644 index 0000000..bd14baf --- /dev/null +++ b/WebKit/chromium/src/WebEventListenerPrivate.cpp @@ -0,0 +1,87 @@ +/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebEventListenerPrivate.h"
+
+#include "EventListenerWrapper.h"
+#include "WebEventListener.h"
+
+namespace WebKit {
+
+WebEventListenerPrivate::WebEventListenerPrivate(WebEventListener* webEventListener)
+ : m_webEventListener(webEventListener)
+{
+}
+
+WebEventListenerPrivate::~WebEventListenerPrivate()
+{
+}
+
+EventListenerWrapper* WebEventListenerPrivate::createEventListenerWrapper(const WebString& eventType, bool useCapture, Node* node)
+{
+ EventListenerWrapper* listenerWrapper = new EventListenerWrapper(m_webEventListener);
+ WebEventListenerPrivate::ListenerInfo listenerInfo(eventType, useCapture, listenerWrapper, node);
+ m_listenerWrappers.append(listenerInfo);
+ return listenerWrapper;
+}
+
+EventListenerWrapper* WebEventListenerPrivate::getEventListenerWrapper(const WebString& eventType, bool useCapture, Node* node)
+{
+ Vector<WebEventListenerPrivate::ListenerInfo>::const_iterator iter;
+ for (iter = m_listenerWrappers.begin(); iter != m_listenerWrappers.end(); ++iter) {
+ if (iter->node == node)
+ return iter->eventListenerWrapper;
+ }
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+void WebEventListenerPrivate::webEventListenerDeleted()
+{
+ // Notifies all WebEventListenerWrappers that we are going away so they can
+ // invalidate their pointer to us.
+ Vector<WebEventListenerPrivate::ListenerInfo>::const_iterator iter;
+ for (iter = m_listenerWrappers.begin(); iter != m_listenerWrappers.end(); ++iter)
+ iter->eventListenerWrapper->webEventListenerDeleted();
+}
+
+void WebEventListenerPrivate::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/WebKit/chromium/src/WebEventListenerPrivate.h b/WebKit/chromium/src/WebEventListenerPrivate.h new file mode 100644 index 0000000..0ba2b5d --- /dev/null +++ b/WebKit/chromium/src/WebEventListenerPrivate.h @@ -0,0 +1,95 @@ +/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebEventListenerPrivate_h
+#define WebEventListenerPrivate_h
+
+#include "WebString.h"
+
+#include <wtf/Vector.h>
+
+namespace WebCore {
+class Node;
+}
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class EventListenerWrapper;
+class WebEventListener;
+
+class WebEventListenerPrivate {
+public:
+ WebEventListenerPrivate(WebEventListener* webEventListener);
+ ~WebEventListenerPrivate();
+
+ EventListenerWrapper* createEventListenerWrapper(
+ const WebString& eventType, bool useCapture, Node* node);
+
+ // Gets the ListenerEventWrapper for a specific node.
+ // Used by WebNode::removeEventListener().
+ EventListenerWrapper* getEventListenerWrapper(
+ const WebString& eventType, bool useCapture, Node* node);
+
+ // Called by the WebEventListener when it is about to be deleted.
+ void webEventListenerDeleted();
+
+ // Called by the EventListenerWrapper when it is about to be deleted.
+ void eventListenerDeleted(EventListenerWrapper* eventListener);
+
+ struct ListenerInfo {
+ ListenerInfo(const WebString& eventType, bool useCapture,
+ EventListenerWrapper* eventListenerWrapper,
+ Node* node)
+ : eventType(eventType)
+ , useCapture(useCapture)
+ , eventListenerWrapper(eventListenerWrapper)
+ , node(node)
+ {
+ }
+
+ WebString eventType;
+ bool useCapture;
+ EventListenerWrapper* eventListenerWrapper;
+ Node* node;
+ };
+
+private:
+ WebEventListener* m_webEventListener;
+
+ // 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/WebKit/chromium/src/WebFrameImpl.cpp b/WebKit/chromium/src/WebFrameImpl.cpp index ab6769f..28c27cc 100644 --- a/WebKit/chromium/src/WebFrameImpl.cpp +++ b/WebKit/chromium/src/WebFrameImpl.cpp @@ -84,7 +84,6 @@ #include "Editor.h" #include "EventHandler.h" #include "FormState.h" -#include "FrameChromium.h" #include "FrameLoader.h" #include "FrameLoadRequest.h" #include "FrameTree.h" @@ -104,6 +103,7 @@ #include "PlatformContextSkia.h" #include "PrintContext.h" #include "RenderFrame.h" +#include "RenderTreeAsText.h" #include "RenderView.h" #include "RenderWidget.h" #include "ReplaceSelectionCommand.h" @@ -120,8 +120,10 @@ #include "SubstituteData.h" #include "TextAffinity.h" #include "TextIterator.h" +#include "WebAnimationControllerImpl.h" #include "WebConsoleMessage.h" #include "WebDataSourceImpl.h" +#include "WebDocument.h" #include "WebFindOptions.h" #include "WebFormElement.h" #include "WebFrameClient.h" @@ -142,11 +144,11 @@ #include <wtf/CurrentTime.h> -#if PLATFORM(DARWIN) +#if OS(DARWIN) #include "LocalCurrentGraphicsContext.h" #endif -#if PLATFORM(LINUX) +#if OS(LINUX) #include <gdk/gdk.h> #endif @@ -154,6 +156,8 @@ 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"; @@ -329,6 +333,11 @@ private: // WebFrame ------------------------------------------------------------------- +int WebFrame::instanceCount() +{ + return frameCount; +} + WebFrame* WebFrame::frameForEnteredContext() { Frame* frame = @@ -343,11 +352,22 @@ WebFrame* WebFrame::frameForCurrentContext() return WebFrameImpl::fromFrame(frame); } +WebFrame* WebFrame::fromFrameOwnerElement(const WebElement& element) +{ + return WebFrameImpl::fromFrameOwnerElement( + PassRefPtr<Element>(element).get()); +} + WebString WebFrameImpl::name() const { return m_frame->tree()->name(); } +void WebFrameImpl::clearName() +{ + m_frame->tree()->clearName(); +} + WebURL WebFrameImpl::url() const { const WebDataSource* ds = dataSource(); @@ -391,6 +411,11 @@ WebURL WebFrameImpl::openSearchDescriptionURL() const return WebURL(); } +WebString WebFrameImpl::encoding() const +{ + return frame()->loader()->encoding(); +} + WebSize WebFrameImpl::scrollOffset() const { FrameView* view = frameView(); @@ -515,6 +540,13 @@ WebFrame* WebFrameImpl::findChildByExpression(const WebString& xpath) const return fromFrame(frameElement->contentFrame()); } +WebDocument WebFrameImpl::document() const +{ + if (!m_frame || !m_frame->document()) + return WebDocument(); + return WebDocument(m_frame->document()); +} + void WebFrameImpl::forms(WebVector<WebFormElement>& results) const { if (!m_frame) @@ -533,6 +565,11 @@ void WebFrameImpl::forms(WebVector<WebFormElement>& results) const results.swap(temp); } +WebAnimationController* WebFrameImpl::animationController() +{ + return &m_animationController; +} + WebSecurityOrigin WebFrameImpl::securityOrigin() const { if (!m_frame || !m_frame->document()) @@ -559,7 +596,7 @@ NPObject* WebFrameImpl::windowObject() const void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object) { ASSERT(m_frame); - if (!m_frame || !m_frame->script()->isEnabled()) + if (!m_frame || !m_frame->script()->canExecuteScripts()) return; String key = name; @@ -576,19 +613,6 @@ void WebFrameImpl::executeScript(const WebScriptSource& source) ScriptSourceCode(source.code, source.url, source.startLine)); } -void WebFrameImpl::executeScriptInNewContext( - const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup) -{ - Vector<ScriptSourceCode> sources; - - for (unsigned i = 0; i < numSources; ++i) { - sources.append(ScriptSourceCode( - sourcesIn[i].code, sourcesIn[i].url, sourcesIn[i].startLine)); - } - - m_frame->script()->evaluateInNewContext(sources, extensionGroup); -} - void WebFrameImpl::executeScriptInIsolatedWorld( int worldId, const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup) @@ -1037,7 +1061,7 @@ WebString WebFrameImpl::selectionAsText() const return WebString(); String text = range->text(); -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) replaceNewlinesWithWindowsStyleNewlines(text); #endif replaceNBSPWithSpace(text); @@ -1087,10 +1111,10 @@ float WebFrameImpl::printPage(int page, WebCanvas* canvas) return 0; } -#if PLATFORM(WIN_OS) || PLATFORM(LINUX) || PLATFORM(FREEBSD) +#if OS(WINDOWS) || OS(LINUX) || OS(FREEBSD) PlatformContextSkia context(canvas); GraphicsContext spool(&context); -#elif PLATFORM(DARWIN) +#elif OS(DARWIN) GraphicsContext spool(canvas); LocalCurrentGraphicsContext localContext(&spool); #endif @@ -1212,8 +1236,7 @@ void WebFrameImpl::stopFinding(bool clearSelection) cancelPendingScopingEffort(); // Remove all markers for matches found and turn off the highlighting. - if (!parent()) - frame()->document()->removeMarkers(DocumentMarker::TextMatch); + frame()->document()->removeMarkers(DocumentMarker::TextMatch); frame()->setMarkedTextMatchesAreHighlighted(false); // Let the frame know that we don't want tickmarks or highlighting anymore. @@ -1456,9 +1479,24 @@ WebString WebFrameImpl::contentAsMarkup() const return createFullMarkup(m_frame->document()); } -// WebFrameImpl public --------------------------------------------------------- +WebString WebFrameImpl::renderTreeAsText() const +{ + return externalRepresentation(m_frame); +} + +WebString WebFrameImpl::counterValueForElementById(const WebString& id) const +{ + if (!m_frame) + return WebString(); + + Element* element = m_frame->document()->getElementById(id); + if (!element) + return WebString(); -int WebFrameImpl::m_liveObjectCount = 0; + return counterValueForElement(element); +} + +// WebFrameImpl public --------------------------------------------------------- PassRefPtr<WebFrameImpl> WebFrameImpl::create(WebFrameClient* client) { @@ -1477,15 +1515,16 @@ WebFrameImpl::WebFrameImpl(WebFrameClient* client) , m_framesScopingCount(-1) , m_scopingComplete(false) , m_nextInvalidateAfter(0) + , m_animationController(this) { ChromiumBridge::incrementStatsCounter(webFrameActiveCount); - m_liveObjectCount++; + frameCount++; } WebFrameImpl::~WebFrameImpl() { ChromiumBridge::decrementStatsCounter(webFrameActiveCount); - m_liveObjectCount--; + frameCount--; cancelPendingScopingEffort(); clearPasswordListeners(); @@ -1631,6 +1670,19 @@ WebFrameImpl* WebFrameImpl::fromFrame(Frame* frame) return static_cast<FrameLoaderClientImpl*>(frame->loader()->client())->webFrame(); } +WebFrameImpl* WebFrameImpl::fromFrameOwnerElement(Element* element) +{ + if (!element + || !element->isFrameOwnerElement() + || (!element->hasTagName(HTMLNames::iframeTag) + && !element->hasTagName(HTMLNames::frameTag))) + return 0; + + HTMLFrameOwnerElement* frameElement = + static_cast<HTMLFrameOwnerElement*>(element); + return fromFrame(frameElement->contentFrame()); +} + WebViewImpl* WebFrameImpl::viewImpl() const { if (!m_frame) diff --git a/WebKit/chromium/src/WebFrameImpl.h b/WebKit/chromium/src/WebFrameImpl.h index 2cd332a..ba8d279 100644 --- a/WebKit/chromium/src/WebFrameImpl.h +++ b/WebKit/chromium/src/WebFrameImpl.h @@ -39,6 +39,8 @@ #include <wtf/OwnPtr.h> #include <wtf/RefCounted.h> +#include "WebAnimationControllerImpl.h" + namespace WebCore { class HistoryItem; class KURL; @@ -62,9 +64,11 @@ class WebFrameImpl : public WebFrame, public RefCounted<WebFrameImpl> { public: // WebFrame methods: virtual WebString name() const; + virtual void clearName(); virtual WebURL url() const; virtual WebURL favIconURL() const; virtual WebURL openSearchDescriptionURL() const; + virtual WebString encoding() const; virtual WebSize scrollOffset() const; virtual WebSize contentsSize() const; virtual int contentsPreferredWidth() const; @@ -82,14 +86,14 @@ public: virtual WebFrame* traversePrevious(bool wrap) const; virtual WebFrame* findChildByName(const WebString&) const; virtual WebFrame* findChildByExpression(const WebString&) const; + virtual WebDocument document() const; virtual void forms(WebVector<WebFormElement>&) const; + virtual WebAnimationController* animationController(); virtual WebSecurityOrigin securityOrigin() const; virtual void grantUniversalAccess(); virtual NPObject* windowObject() const; virtual void bindToWindowObject(const WebString& name, NPObject*); virtual void executeScript(const WebScriptSource&); - virtual void executeScriptInNewContext( - const WebScriptSource* sources, unsigned numSources, int extensionGroup); virtual void executeScriptInIsolatedWorld( int worldId, const WebScriptSource* sources, unsigned numSources, int extensionGroup); @@ -157,12 +161,12 @@ public: virtual WebURL completeURL(const WebString& url) const; virtual WebString contentAsText(size_t maxChars) const; virtual WebString contentAsMarkup() const; + virtual WebString renderTreeAsText() const; + virtual WebString counterValueForElementById(const WebString& id) const; static PassRefPtr<WebFrameImpl> create(WebFrameClient* client); ~WebFrameImpl(); - static int liveObjectCount() { return m_liveObjectCount; } - // Called by the WebViewImpl to initialize its main frame: void initializeAsMainFrame(WebViewImpl*); @@ -174,6 +178,7 @@ public: void createFrameView(); static WebFrameImpl* fromFrame(WebCore::Frame* frame); + static WebFrameImpl* fromFrameOwnerElement(WebCore::Element* element); WebViewImpl* viewImpl() const; @@ -276,9 +281,6 @@ private: void loadJavaScriptURL(const WebCore::KURL&); - // Used to check for leaks of this object. - static int m_liveObjectCount; - FrameLoaderClientImpl m_frameLoaderClient; WebFrameClient* m_client; @@ -348,6 +350,9 @@ private: typedef HashMap<RefPtr<WebCore::HTMLInputElement>, WebPasswordAutocompleteListener*> PasswordListenerMap; PasswordListenerMap m_passwordListeners; + + // Keeps a reference to the frame's WebAnimationController. + WebAnimationControllerImpl m_animationController; }; } // namespace WebKit diff --git a/WebKit/chromium/src/WebGlyphCache.cpp b/WebKit/chromium/src/WebGlyphCache.cpp new file mode 100644 index 0000000..272c6cd --- /dev/null +++ b/WebKit/chromium/src/WebGlyphCache.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebGlyphCache.h" + +#include "GlyphPageTreeNode.h" + +using namespace WebCore; + +namespace WebKit { + +size_t WebGlyphCache::pageCount() +{ + return GlyphPageTreeNode::treeGlyphPageCount(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebHistoryItem.cpp b/WebKit/chromium/src/WebHistoryItem.cpp index d4ee50a..4ca8cc7 100644 --- a/WebKit/chromium/src/WebHistoryItem.cpp +++ b/WebKit/chromium/src/WebHistoryItem.cpp @@ -218,6 +218,18 @@ void WebHistoryItem::setDocumentState(const WebVector<WebString>& state) m_private->setDocumentState(ds); } +long long WebHistoryItem::documentSequenceNumber() const +{ + ASSERT(!isNull()); + return m_private->documentSequenceNumber(); +} + +void WebHistoryItem::setDocumentSequenceNumber(long long documentSequenceNumber) +{ + ensureMutable(); + m_private->setDocumentSequenceNumber(documentSequenceNumber); +} + WebString WebHistoryItem::httpContentType() const { ASSERT(!isNull()); diff --git a/WebKit/chromium/src/WebInputElement.cpp b/WebKit/chromium/src/WebInputElement.cpp index d403120..ee799f6 100644 --- a/WebKit/chromium/src/WebInputElement.cpp +++ b/WebKit/chromium/src/WebInputElement.cpp @@ -56,6 +56,11 @@ WebInputElement::operator WTF::PassRefPtr<HTMLInputElement>() const return PassRefPtr<HTMLInputElement>(static_cast<HTMLInputElement*>(m_private)); } +bool WebInputElement::autoComplete() const +{ + return constUnwrap<HTMLInputElement>()->autoComplete(); +} + bool WebInputElement::isEnabledFormControl() const { return constUnwrap<HTMLInputElement>()->isEnabledFormControl(); diff --git a/WebKit/chromium/src/WebKit.cpp b/WebKit/chromium/src/WebKit.cpp index a129f85..a8e1851 100644 --- a/WebKit/chromium/src/WebKit.cpp +++ b/WebKit/chromium/src/WebKit.cpp @@ -33,6 +33,7 @@ #include "AtomicString.h" #include "DOMTimer.h" +#include "Logging.h" #include "Page.h" #include "RuntimeEnabledFeatures.h" #include "TextEncoding.h" @@ -94,6 +95,13 @@ bool layoutTestMode() return s_layoutTestMode; } +void enableLogChannel(const char* name) +{ + WTFLogChannel* channel = WebCore::getChannelFromName(name); + if (channel) + channel->state = WTFLogChannelOn; +} + void resetPluginCache(bool reloadPages) { WebCore::Page::refreshPlugins(reloadPages); diff --git a/WebKit/chromium/src/WebMutationEvent.cpp b/WebKit/chromium/src/WebMutationEvent.cpp new file mode 100644 index 0000000..511b615 --- /dev/null +++ b/WebKit/chromium/src/WebMutationEvent.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebMutationEvent.h" + +#include "MutationEvent.h" + +using namespace WebCore; + +namespace WebKit { + +WebNode WebMutationEvent::relatedNode() const +{ + return WebNode(constUnwrap<MutationEvent>()->relatedNode()); +} + +WebString WebMutationEvent::prevValue() const +{ + return WebString(constUnwrap<MutationEvent>()->prevValue()); +} + +WebString WebMutationEvent::newValue() const +{ + return WebString(constUnwrap<MutationEvent>()->newValue()); +} + +WebString WebMutationEvent::attrName() const +{ + return WebString(constUnwrap<MutationEvent>()->attrName()); +} + +WebMutationEvent::AttrChangeType WebMutationEvent::attrChange() const +{ + return static_cast<AttrChangeType>(constUnwrap<MutationEvent>()->attrChange()); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebNode.cpp b/WebKit/chromium/src/WebNode.cpp index 965c412..9fbf573 100644 --- a/WebKit/chromium/src/WebNode.cpp +++ b/WebKit/chromium/src/WebNode.cpp @@ -35,9 +35,18 @@ #include "Frame.h" #include "FrameLoaderClientImpl.h" #include "Node.h" +#include "NodeList.h" +#include "EventListenerWrapper.h" +#include "WebDocument.h" +#include "WebEvent.h" +#include "WebEventListener.h" #include "WebFrameImpl.h" +#include "WebNodeList.h" #include "WebString.h" +#include "WebVector.h" + +#include "markup.h" #include <wtf/PassRefPtr.h> @@ -61,6 +70,11 @@ void WebNode::assign(const WebNode& other) assign(p); } +WebNode::NodeType WebNode::nodeType() const +{ + return static_cast<NodeType>(m_private->nodeType()); +} + WebNode WebNode::parentNode() const { return PassRefPtr<Node>(const_cast<Node*>(m_private->parentNode())); @@ -71,18 +85,30 @@ WebString WebNode::nodeName() const return m_private->nodeName(); } -WebNode::WebNode(const WTF::PassRefPtr<WebCore::Node>& node) +WebString WebNode::nodeValue() const +{ + return m_private->nodeValue(); +} + +bool WebNode::setNodeValue(const WebString& value) +{ + ExceptionCode exceptionCode = 0; + m_private->setNodeValue(value, exceptionCode); + return !exceptionCode; +} + +WebNode::WebNode(const PassRefPtr<Node>& node) : m_private(static_cast<WebNodePrivate*>(node.releaseRef())) { } -WebNode& WebNode::operator=(const WTF::PassRefPtr<WebCore::Node>& node) +WebNode& WebNode::operator=(const PassRefPtr<Node>& node) { assign(static_cast<WebNodePrivate*>(node.releaseRef())); return *this; } -WebNode::operator WTF::PassRefPtr<WebCore::Node>() const +WebNode::operator PassRefPtr<Node>() const { return PassRefPtr<Node>(const_cast<WebNodePrivate*>(m_private)); } @@ -100,4 +126,72 @@ WebFrame* WebNode::frame() const return WebFrameImpl::fromFrame(m_private->document()->frame()); } +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); +} + +bool WebNode::isTextNode() const +{ + return m_private->isTextNode(); +} + +bool WebNode::isElementNode() const +{ + return m_private->isElementNode(); +} + +void WebNode::addEventListener(const WebString& eventType, WebEventListener* listener, bool useCapture) +{ + EventListenerWrapper* listenerWrapper = + listener->createEventListenerWrapper(eventType, useCapture, m_private); + // The listenerWrapper is only referenced by the actual Node. Once it goes + // away, the wrapper notifies the WebEventListener so it can clear its + // pointer to it. + m_private->addEventListener(eventType, adoptRef(listenerWrapper), useCapture); +} + +void WebNode::removeEventListener(const WebString& eventType, WebEventListener* listener, bool useCapture) +{ + EventListenerWrapper* listenerWrapper = + listener->getEventListenerWrapper(eventType, useCapture, m_private); + m_private->removeEventListener(eventType, listenerWrapper, useCapture); + // listenerWrapper is now deleted. +} + } // namespace WebKit diff --git a/WebKit/chromium/src/WebNodeCollection.cpp b/WebKit/chromium/src/WebNodeCollection.cpp new file mode 100644 index 0000000..a9e532f --- /dev/null +++ b/WebKit/chromium/src/WebNodeCollection.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebNodeCollection.h" + +#include "HTMLCollection.h" +#include "Node.h" +#include <wtf/PassRefPtr.h> + +#include "WebNode.h" + +using namespace WebCore; + +namespace WebKit { + +void WebNodeCollection::reset() +{ + assign(0); +} + +void WebNodeCollection::assign(const WebNodeCollection& other) +{ + HTMLCollection* p = const_cast<HTMLCollection*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +WebNodeCollection::WebNodeCollection(const PassRefPtr<HTMLCollection>& col) + : m_private(static_cast<HTMLCollection*>(col.releaseRef())) +{ +} + +void WebNodeCollection::assign(HTMLCollection* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +unsigned WebNodeCollection::length() const +{ + return m_private->length(); +} + +WebNode WebNodeCollection::nextItem() const +{ + return WebNode(m_private->nextItem()); +} + +WebNode WebNodeCollection::firstItem() const +{ + return WebNode(m_private->firstItem()); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebNodeList.cpp b/WebKit/chromium/src/WebNodeList.cpp new file mode 100644 index 0000000..f68f961 --- /dev/null +++ b/WebKit/chromium/src/WebNodeList.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebNodeList.h" + +#include "Node.h" +#include "NodeList.h" +#include <wtf/PassRefPtr.h> + +#include "WebNode.h" + +using namespace WebCore; + +namespace WebKit { + +void WebNodeList::reset() +{ + assign(0); +} + +void WebNodeList::assign(const WebNodeList& other) +{ + NodeList* p = const_cast<NodeList*>(other.m_private); + if (p) + p->ref(); + assign(p); +} + +WebNodeList::WebNodeList(const PassRefPtr<NodeList>& col) + : m_private(static_cast<NodeList*>(col.releaseRef())) +{ +} + +void WebNodeList::assign(NodeList* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +unsigned WebNodeList::length() const +{ + return m_private->length(); +} + +WebNode WebNodeList::item(size_t index) const +{ + return WebNode(m_private->item(index)); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebPageSerializer.cpp b/WebKit/chromium/src/WebPageSerializer.cpp new file mode 100644 index 0000000..1010285 --- /dev/null +++ b/WebKit/chromium/src/WebPageSerializer.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebPageSerializer.h" + +#include "KURL.h" +#include "PlatformString.h" + +#include "WebFrame.h" +#include "WebPageSerializerClient.h" +#include "WebPageSerializerImpl.h" +#include "WebString.h" +#include "WebURL.h" +#include "WebVector.h" + +using namespace WebCore; + +namespace WebKit { + +bool WebPageSerializer::serialize(WebFrame* frame, + bool recursive, + WebPageSerializerClient* client, + const WebVector<WebURL>& links, + const WebVector<WebString>& localPaths, + const WebString& localDirectoryName) +{ + WebPageSerializerImpl serializerImpl( + frame, recursive, client, links, localPaths, localDirectoryName); + return serializerImpl.serialize(); +} + +WebString WebPageSerializer::generateMetaCharsetDeclaration(const WebString& charset) +{ + return String::format("<META http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">", + charset.utf8().data()); +} + +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) +{ + String targetDeclaration; + if (!baseTarget.isEmpty()) + targetDeclaration = String::format(" target=\"%s\"", baseTarget.utf8().data()); + return String::format("<BASE href=\".\"%s>", targetDeclaration.utf8().data()); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebPageSerializerImpl.cpp b/WebKit/chromium/src/WebPageSerializerImpl.cpp new file mode 100644 index 0000000..d5b2b7f --- /dev/null +++ b/WebKit/chromium/src/WebPageSerializerImpl.cpp @@ -0,0 +1,547 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// How we handle the base tag better. +// Current status: +// At now the normal way we use to handling base tag is +// a) For those links which have corresponding local saved files, such as +// savable CSS, JavaScript files, they will be written to relative URLs which +// point to local saved file. Why those links can not be resolved as absolute +// file URLs, because if they are resolved as absolute URLs, after moving the +// file location from one directory to another directory, the file URLs will +// be dead links. +// b) For those links which have not corresponding local saved files, such as +// links in A, AREA tags, they will be resolved as absolute URLs. +// c) We comment all base tags when serialzing DOM for the page. +// FireFox also uses above way to handle base tag. +// +// Problem: +// This way can not handle the following situation: +// the base tag is written by JavaScript. +// For example. The page "www.yahoo.com" use +// "document.write('<base href="http://www.yahoo.com/"...');" to setup base URL +// of page when loading page. So when saving page as completed-HTML, we assume +// that we save "www.yahoo.com" to "c:\yahoo.htm". After then we load the saved +// completed-HTML page, then the JavaScript will insert a base tag +// <base href="http://www.yahoo.com/"...> to DOM, so all URLs which point to +// local saved resource files will be resolved as +// "http://www.yahoo.com/yahoo_files/...", which will cause all saved resource +// files can not be loaded correctly. Also the page will be rendered ugly since +// all saved sub-resource files (such as CSS, JavaScript files) and sub-frame +// files can not be fetched. +// Now FireFox, IE and WebKit based Browser all have this problem. +// +// Solution: +// My solution is that we comment old base tag and write new base tag: +// <base href="." ...> after the previous commented base tag. In WebKit, it +// always uses the latest "href" attribute of base tag to set document's base +// URL. Based on this behavior, when we encounter a base tag, we comment it and +// write a new base tag <base href="."> after the previous commented base tag. +// The new added base tag can help engine to locate correct base URL for +// correctly loading local saved resource files. Also I think we need to inherit +// the base target value from document object when appending new base tag. +// If there are multiple base tags in original document, we will comment all old +// base tags and append new base tag after each old base tag because we do not +// know those old base tags are original content or added by JavaScript. If +// they are added by JavaScript, it means when loading saved page, the script(s) +// will still insert base tag(s) to DOM, so the new added base tag(s) can +// override the incorrect base URL and make sure we alway load correct local +// saved resource files. + +#include "config.h" +#include "WebPageSerializerImpl.h" + +#include "Document.h" +#include "DocumentType.h" +#include "Element.h" +#include "FrameLoader.h" +#include "HTMLAllCollection.h" +#include "HTMLElement.h" +#include "HTMLFormElement.h" +#include "HTMLMetaElement.h" +#include "HTMLNames.h" +#include "KURL.h" +#include "PlatformString.h" +#include "StringBuilder.h" +#include "TextEncoding.h" +#include "markup.h" + +#include "DOMUtilitiesPrivate.h" +#include "WebFrameImpl.h" +#include "WebURL.h" +#include "WebVector.h" + +using namespace WebCore; + +namespace WebKit { + +// Maximum length of data buffer which is used to temporary save generated +// html content data. This is a soft limit which might be passed if a very large +// contegious string is found in the page. +static const unsigned dataBufferCapacity = 65536; + +WebPageSerializerImpl::SerializeDomParam::SerializeDomParam(const KURL& currentFrameURL, + const TextEncoding& textEncoding, + Document* doc, + const String& directoryName) + : currentFrameURL(currentFrameURL) + , textEncoding(textEncoding) + , doc(doc) + , directoryName(directoryName) + , hasDoctype(false) + , hasCheckedMeta(false) + , skipMetaElement(0) + , isInScriptOrStyleTag(false) + , hasDocDeclaration(false) +{ + // Cache the value since we check it lots of times. + isHTMLDocument = doc->isHTMLDocument(); +} + +String WebPageSerializerImpl::preActionBeforeSerializeOpenTag( + const Element* element, SerializeDomParam* param, bool* needSkip) +{ + StringBuilder result; + + *needSkip = false; + if (param->isHTMLDocument) { + // Skip the open tag of original META tag which declare charset since we + // have overrided the META which have correct charset declaration after + // serializing open tag of HEAD element. + if (element->hasTagName(HTMLNames::metaTag)) { + const HTMLMetaElement* meta = static_cast<const HTMLMetaElement*>(element); + // Check whether the META tag has declared charset or not. + String equiv = meta->httpEquiv(); + if (equalIgnoringCase(equiv, "content-type")) { + String content = meta->content(); + if (content.length() && content.contains("charset", false)) { + // Find META tag declared charset, we need to skip it when + // serializing DOM. + param->skipMetaElement = element; + *needSkip = true; + } + } + } else if (element->hasTagName(HTMLNames::htmlTag)) { + // Check something before processing the open tag of HEAD element. + // First we add doc type declaration if original doc has it. + if (!param->hasDoctype) { + param->hasDoctype = true; + result.append(createMarkup(param->doc->doctype())); + } + + // Add MOTW declaration before html tag. + // See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx. + result.append(WebPageSerializer::generateMarkOfTheWebDeclaration(param->currentFrameURL)); + } else if (element->hasTagName(HTMLNames::baseTag)) { + // Comment the BASE tag when serializing dom. + result.append("<!--"); + } + } else { + // Write XML declaration. + if (!param->hasDocDeclaration) { + param->hasDocDeclaration = true; + // Get encoding info. + String xmlEncoding = param->doc->xmlEncoding(); + if (xmlEncoding.isEmpty()) + xmlEncoding = param->doc->frame()->loader()->encoding(); + if (xmlEncoding.isEmpty()) + xmlEncoding = UTF8Encoding().name(); + result.append("<?xml version=\""); + result.append(param->doc->xmlVersion()); + result.append("\" encoding=\""); + result.append(xmlEncoding); + if (param->doc->xmlStandalone()) + result.append("\" standalone=\"yes"); + result.append("\"?>\n"); + } + // Add doc type declaration if original doc has it. + if (!param->hasDoctype) { + param->hasDoctype = true; + result.append(createMarkup(param->doc->doctype())); + } + } + return result.toString(); +} + +String WebPageSerializerImpl::postActionAfterSerializeOpenTag( + const Element* element, SerializeDomParam* param) +{ + StringBuilder result; + + param->hasAddedContentsBeforeEnd = false; + if (!param->isHTMLDocument) + return result.toString(); + // Check after processing the open tag of HEAD element + if (!param->hasCheckedMeta + && element->hasTagName(HTMLNames::headTag)) { + param->hasCheckedMeta = 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->hasAddedContentsBeforeEnd = 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->doc->baseTarget())); + } + + return result.toString(); +} + +void WebPageSerializerImpl::saveHTMLContentToBuffer( + const String& result, SerializeDomParam* param) +{ + m_dataBuffer.append(result); + encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsNotFinished, + param, + 0); +} + +void WebPageSerializerImpl::encodeAndFlushBuffer( + WebPageSerializerClient::PageSerializationStatus status, + SerializeDomParam* param, + bool force) +{ + // Data buffer is not full nor do we want to force flush. + if (!force && m_dataBuffer.length() <= dataBufferCapacity) + return; + + String content = m_dataBuffer.toString(); + m_dataBuffer.clear(); + + // Convert the unicode content to target encoding + CString encodedContent = param->textEncoding.encode( + content.characters(), content.length(), EntitiesForUnencodables); + + // Send result to the client. + m_client->didSerializeDataForFrame(param->currentFrameURL, + WebCString(encodedContent.data(), encodedContent.length()), + status); +} + +void WebPageSerializerImpl::openTagToString(const Element* element, + SerializeDomParam* param) +{ + // FIXME: use StringBuilder instead of String. + bool needSkip; + // Do pre action for open tag. + String result = preActionBeforeSerializeOpenTag(element, param, &needSkip); + if (needSkip) + return; + // Add open tag + result += "<" + element->nodeName(); + // Go through all attributes and serialize them. + const NamedNodeMap *attrMap = element->attributes(true); + if (attrMap) { + unsigned numAttrs = attrMap->length(); + for (unsigned i = 0; i < numAttrs; i++) { + result += " "; + // Add attribute pair + const Attribute *attribute = attrMap->attributeItem(i); + result += attribute->name().toString(); + result += "=\""; + if (!attribute->value().isEmpty()) { + const String& attrValue = attribute->value(); + + // Check whether we need to replace some resource links + // with local resource paths. + const QualifiedName& attrName = attribute->name(); + if (elementHasLegalLinkAttribute(element, attrName)) { + // For links start with "javascript:", we do not change it. + if (attrValue.startsWith("javascript:", false)) + result += attrValue; + else { + // Get the absolute link + String completeURL = param->doc->completeURL(attrValue); + // Check whether we have local files for those link. + if (m_localLinks.contains(completeURL)) { + if (!m_localDirectoryName.isEmpty()) + result += "./" + m_localDirectoryName + "/"; + result += m_localLinks.get(completeURL); + } else + result += completeURL; + } + } else { + if (param->isHTMLDocument) + result += m_htmlEntities.convertEntitiesInString(attrValue); + else + result += m_xmlEntities.convertEntitiesInString(attrValue); + } + } + result += "\""; + } + } + + // Do post action for open tag. + String addedContents = postActionAfterSerializeOpenTag(element, param); + // Complete the open tag for element when it has child/children. + if (element->hasChildNodes() || param->hasAddedContentsBeforeEnd) + result += ">"; + // Append the added contents generate in post action of open tag. + result += addedContents; + // Save the result to data buffer. + saveHTMLContentToBuffer(result, param); +} + +// Serialize end tag of an specified element. +void WebPageSerializerImpl::endTagToString(const Element* element, + SerializeDomParam* param) +{ + bool needSkip; + // Do pre action for end tag. + String result = preActionBeforeSerializeEndTag(element, + param, + &needSkip); + if (needSkip) + return; + // Write end tag when element has child/children. + if (element->hasChildNodes() || param->hasAddedContentsBeforeEnd) { + result += "</"; + result += element->nodeName(); + result += ">"; + } else { + // Check whether we have to write end tag for empty element. + if (param->isHTMLDocument) { + result += ">"; + const HTMLElement* htmlElement = + static_cast<const HTMLElement*>(element); + if (htmlElement->endTagRequirement() == TagStatusRequired) { + // We need to write end tag when it is required. + result += "</"; + result += element->nodeName(); + result += ">"; + } + } else { + // For xml base document. + result += " />"; + } + } + // Do post action for end tag. + result += postActionAfterSerializeEndTag(element, param); + // Save the result to data buffer. + saveHTMLContentToBuffer(result, param); +} + +void WebPageSerializerImpl::buildContentForNode(const Node* node, + SerializeDomParam* param) +{ + switch (node->nodeType()) { + case Node::ELEMENT_NODE: + // Process open tag of element. + openTagToString(static_cast<const Element*>(node), param); + // Walk through the children nodes and process it. + for (const Node *child = node->firstChild(); child; child = child->nextSibling()) + buildContentForNode(child, param); + // Process end tag of element. + endTagToString(static_cast<const Element*>(node), param); + break; + case Node::TEXT_NODE: + saveHTMLContentToBuffer(createMarkup(node), param); + break; + case Node::ATTRIBUTE_NODE: + case Node::DOCUMENT_NODE: + case Node::DOCUMENT_FRAGMENT_NODE: + // Should not exist. + ASSERT_NOT_REACHED(); + break; + // Document type node can be in DOM? + case Node::DOCUMENT_TYPE_NODE: + param->hasDoctype = 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.length()); +} + +void WebPageSerializerImpl::collectTargetFrames() +{ + ASSERT(!m_framesCollected); + m_framesCollected = true; + + // First, process main frame. + m_frames.append(m_specifiedWebFrameImpl); + // Return now if user only needs to serialize specified frame, not including + // all sub-frames. + if (!m_recursiveSerialization) + return; + // Collect all frames inside the specified frame. + for (int i = 0; i < static_cast<int>(m_frames.size()); ++i) { + WebFrameImpl* currentFrame = m_frames[i]; + // Get current using document. + Document* currentDoc = currentFrame->frame()->document(); + // Go through sub-frames. + RefPtr<HTMLAllCollection> all = currentDoc->all(); + for (Node* node = all->firstItem(); node; node = all->nextItem()) { + if (!node->isHTMLElement()) + continue; + Element* element = static_cast<Element*>(node); + WebFrameImpl* webFrame = + WebFrameImpl::fromFrameOwnerElement(element); + if (webFrame) + m_frames.append(webFrame); + } + } +} + +bool WebPageSerializerImpl::serialize() +{ + // Collect target frames. + if (!m_framesCollected) + collectTargetFrames(); + bool didSerialization = false; + // Get KURL for main frame. + KURL mainPageURL = m_specifiedWebFrameImpl->frame()->loader()->url(); + + // Go through all frames for serializing DOM for whole page, include + // sub-frames. + for (int i = 0; i < static_cast<int>(m_frames.size()); ++i) { + // Get current serializing frame. + WebFrameImpl* currentFrame = m_frames[i]; + // Get current using document. + Document* currentDoc = currentFrame->frame()->document(); + // Get current frame's URL. + const KURL& currentFrameURL = currentFrame->frame()->loader()->url(); + + // Check whether we have done this document. + if (m_localLinks.contains(currentFrameURL.string())) { + // A new document, we will serialize it. + didSerialization = true; + // Get target encoding for current document. + String encoding = currentFrame->frame()->loader()->encoding(); + // Create the text encoding object with target encoding. + TextEncoding textEncoding(encoding); + // Construct serialize parameter for late processing document. + SerializeDomParam param(currentFrameURL, + encoding.length() ? textEncoding : UTF8Encoding(), + currentDoc, + currentFrameURL == mainPageURL ? m_localDirectoryName : ""); + + // Process current document. + Element* rootElement = currentDoc->documentElement(); + if (rootElement) + buildContentForNode(rootElement, ¶m); + + // Flush the remainder data and finish serializing current frame. + encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, + ¶m, + 1); + } + } + + // We have done call frames, so we send message to embedder to tell it that + // frames are finished serializing. + ASSERT(!m_dataBuffer.length()); + m_client->didSerializeDataForFrame(KURL(), + WebCString("", 0), + WebPageSerializerClient::AllFramesAreFinished); + return didSerialization; +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebPageSerializerImpl.h b/WebKit/chromium/src/WebPageSerializerImpl.h new file mode 100644 index 0000000..8f6a99f --- /dev/null +++ b/WebKit/chromium/src/WebPageSerializerImpl.h @@ -0,0 +1,199 @@ +/* + * 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 "PlatformString.h" +#include "StringBuilder.h" +#include "StringHash.h" +#include <wtf/HashMap.h> +#include <wtf/Vector.h> + +#include "WebEntities.h" +#include "WebPageSerializer.h" +#include "WebPageSerializerClient.h" +#include "WebString.h" +#include "WebURL.h" + +namespace WebCore { +class Document; +class Element; +class Node; +class String; +class TextEncoding; +} + +namespace WebKit { +class WebFrameImpl; + +// Get html data by serializing all frames of current page with lists +// which contain all resource links that have local copy. +// contain all saved auxiliary files included all sub frames and resources. +// This function will find out all frames and serialize them to HTML data. +// We have a data buffer to temporary saving generated html data. We will +// sequentially call WebViewDelegate::SendSerializedHtmlData once the data +// buffer is full. See comments of WebViewDelegate::SendSerializedHtmlData +// for getting more information. +class WebPageSerializerImpl { +public: + // Do serialization action. Return false means no available frame has been + // serialized, otherwise return true. + bool serialize(); + + // The parameter specifies which frame need to be serialized. + // The parameter recursive_serialization specifies whether we need to + // serialize all sub frames of the specified frame or not. + // The parameter delegate specifies the pointer of interface + // DomSerializerDelegate provide sink interface which can receive the + // individual chunks of data to be saved. + // The parameter links contain original URLs of all saved links. + // The parameter local_paths contain corresponding local file paths of all + // saved links, which matched with vector:links one by one. + // The parameter local_directory_name is relative path of directory which + // contain all saved auxiliary files included all sub frames and resources. + WebPageSerializerImpl(WebFrame* frame, + bool recursive, + WebPageSerializerClient* client, + const WebVector<WebURL>& links, + const WebVector<WebString>& localPaths, + const WebString& localDirectoryName); + +private: + // Specified frame which need to be serialized; + WebFrameImpl* m_specifiedWebFrameImpl; + // Pointer of WebPageSerializerClient + WebPageSerializerClient* m_client; + // This hash map is used to map resource URL of original link to its local + // file path. + typedef HashMap<WebCore::String, WebCore::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. + WebCore::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. + WebCore::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 { + // Frame URL of current processing document presented by GURL + const WebCore::KURL& currentFrameURL; + // Current using text encoding object. + const WebCore::TextEncoding& textEncoding; + + // Document object of current frame. + WebCore::Document* doc; + // Local directory name of all local resource files. + const WebCore::String& directoryName; + + // Flag indicates current doc is html document or not. It's a cache value + // of Document.isHTMLDocument(). + bool isHTMLDocument; + // Flag which indicate whether we have met document type declaration. + bool hasDoctype; + // Flag which indicate whether will process meta issue. + bool hasCheckedMeta; + // 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; + // Flag indicates whether we have written xml document declaration. + // It is only used in xml document + bool hasDocDeclaration; + // 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 hasAddedContentsBeforeEnd; + + // Constructor. + SerializeDomParam(const WebCore::KURL& currentFrameURL, + const WebCore::TextEncoding& textEncoding, + WebCore::Document* doc, + const WebCore::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. + WebCore::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. + WebCore::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. + WebCore::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. + WebCore::String postActionAfterSerializeEndTag(const WebCore::Element* element, + SerializeDomParam* param); + // Save generated html content to data buffer. + void saveHTMLContentToBuffer(const WebCore::String& content, + SerializeDomParam* param); + // 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, + bool force); + // Serialize open tag of an specified element. + void openTagToString(const WebCore::Element* element, + SerializeDomParam* param); + // Serialize end tag of an specified element. + void endTagToString(const WebCore::Element* element, + SerializeDomParam* param); + // Build content for a specified node + void buildContentForNode(const WebCore::Node* node, + SerializeDomParam* param); +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebPluginContainerImpl.cpp b/WebKit/chromium/src/WebPluginContainerImpl.cpp index 43f3cef..86cac26 100644 --- a/WebKit/chromium/src/WebPluginContainerImpl.cpp +++ b/WebKit/chromium/src/WebPluginContainerImpl.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "WebPluginContainerImpl.h" +#include "Chrome.h" #include "ChromeClientImpl.h" #include "WebCursorInfo.h" #include "WebDataSourceImpl.h" @@ -353,7 +354,7 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) WebCursorInfo cursorInfo; bool handled = m_webPlugin->handleInputEvent(webEvent, cursorInfo); -#if !PLATFORM(DARWIN) +#if !OS(DARWIN) // TODO(pkasting): http://b/1119691 This conditional seems exactly // backwards, but if I reverse it, giving focus to a transparent // (windowless) plugin fails. @@ -389,7 +390,7 @@ void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) WebCursorInfo cursor_info; bool handled = m_webPlugin->handleInputEvent(webEvent, cursor_info); -#if !PLATFORM(DARWIN) +#if !OS(DARWIN) // TODO(pkasting): http://b/1119691 See above. handled = !handled; #endif diff --git a/WebKit/chromium/src/WebRuntimeFeatures.cpp b/WebKit/chromium/src/WebRuntimeFeatures.cpp index b630a09..0ef8b9b 100644 --- a/WebKit/chromium/src/WebRuntimeFeatures.cpp +++ b/WebKit/chromium/src/WebRuntimeFeatures.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "WebRuntimeFeatures.h" +#include "Database.h" #include "RuntimeEnabledFeatures.h" #include "WebMediaPlayerClientImpl.h" #include "WebSocket.h" @@ -42,14 +43,14 @@ namespace WebKit { void WebRuntimeFeatures::enableDatabase(bool enable) { #if ENABLE(DATABASE) - RuntimeEnabledFeatures::setDatabaseEnabled(enable); + Database::setIsAvailable(enable); #endif } bool WebRuntimeFeatures::isDatabaseEnabled() { #if ENABLE(DATABASE) - return RuntimeEnabledFeatures::databaseEnabled(); + return Database::isAvailable(); #else return false; #endif @@ -151,4 +152,36 @@ bool WebRuntimeFeatures::isApplicationCacheEnabled() #endif } +void WebRuntimeFeatures::enableGeolocation(bool enable) +{ +#if ENABLE(GEOLOCATION) + RuntimeEnabledFeatures::setGeolocationEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isGeolocationEnabled() +{ +#if ENABLE(GEOLOCATION) + return RuntimeEnabledFeatures::geolocationEnabled(); +#else + return false; +#endif +} + +void WebRuntimeFeatures::enableIndexedDatabase(bool enable) +{ +#if ENABLE(INDEXED_DATABASE) + RuntimeEnabledFeatures::setIndexedDatabaseEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isIndexedDatabaseEnabled() +{ +#if ENABLE(INDEXED_DATABASE) + return RuntimeEnabledFeatures::indexedDatabaseEnabled(); +#else + return false; +#endif +} + } // namespace WebKit diff --git a/WebKit/chromium/src/WebSecurityOrigin.cpp b/WebKit/chromium/src/WebSecurityOrigin.cpp index 3cf7364..87916ca 100644 --- a/WebKit/chromium/src/WebSecurityOrigin.cpp +++ b/WebKit/chromium/src/WebSecurityOrigin.cpp @@ -42,6 +42,11 @@ namespace WebKit { class WebSecurityOriginPrivate : public SecurityOrigin { }; +WebSecurityOrigin* WebSecurityOrigin::createFromDatabaseIdentifier(const WebString& databaseIdentifier) +{ + return new WebSecurityOrigin(SecurityOrigin::createFromDatabaseIdentifier(databaseIdentifier)); +} + void WebSecurityOrigin::reset() { assign(0); diff --git a/WebKit/chromium/src/WebSecurityPolicy.cpp b/WebKit/chromium/src/WebSecurityPolicy.cpp index c66c805..48b445c 100644 --- a/WebKit/chromium/src/WebSecurityPolicy.cpp +++ b/WebKit/chromium/src/WebSecurityPolicy.cpp @@ -66,4 +66,9 @@ void WebSecurityPolicy::resetOriginAccessWhiteLists() SecurityOrigin::resetOriginAccessWhiteLists(); } +bool WebSecurityPolicy::shouldHideReferrer(const WebURL& url, const WebString& referrer) +{ + return SecurityOrigin::shouldHideReferrer(url, referrer); +} + } // namespace WebKit diff --git a/WebKit/chromium/src/WebSettingsImpl.cpp b/WebKit/chromium/src/WebSettingsImpl.cpp index e019653..5cfbd4f 100644 --- a/WebKit/chromium/src/WebSettingsImpl.cpp +++ b/WebKit/chromium/src/WebSettingsImpl.cpp @@ -130,6 +130,11 @@ void WebSettingsImpl::setLoadsImagesAutomatically(bool loadsImagesAutomatically) m_settings->setLoadsImagesAutomatically(loadsImagesAutomatically); } +void WebSettingsImpl::setImagesEnabled(bool enabled) +{ + m_settings->setImagesEnabled(enabled); +} + void WebSettingsImpl::setPluginsEnabled(bool enabled) { m_settings->setPluginsEnabled(enabled); diff --git a/WebKit/chromium/src/WebSettingsImpl.h b/WebKit/chromium/src/WebSettingsImpl.h index 9c0f9f4..3b69fe6 100644 --- a/WebKit/chromium/src/WebSettingsImpl.h +++ b/WebKit/chromium/src/WebSettingsImpl.h @@ -60,6 +60,7 @@ public: virtual void setWebSecurityEnabled(bool); virtual void setJavaScriptCanOpenWindowsAutomatically(bool); virtual void setLoadsImagesAutomatically(bool); + virtual void setImagesEnabled(bool); virtual void setPluginsEnabled(bool); virtual void setDOMPasteAllowed(bool); virtual void setDeveloperExtrasEnabled(bool); diff --git a/WebKit/chromium/src/WebStorageAreaImpl.cpp b/WebKit/chromium/src/WebStorageAreaImpl.cpp index f24bee3..92a923a 100644 --- a/WebKit/chromium/src/WebStorageAreaImpl.cpp +++ b/WebKit/chromium/src/WebStorageAreaImpl.cpp @@ -66,12 +66,12 @@ WebString WebStorageAreaImpl::getItem(const WebString& key) return m_storageArea->getItem(key); } -void WebStorageAreaImpl::setItem(const WebString& key, const WebString& value, const WebURL& url, bool& quotaException) +void WebStorageAreaImpl::setItem(const WebString& key, const WebString& value, const WebURL& url, bool& quotaException, WebString& oldValue) { int exceptionCode = 0; ScopedStorageEventURL scope(url); - m_storageArea->setItem(key, value, exceptionCode, 0); + oldValue = m_storageArea->setItem(key, value, exceptionCode, 0); if (exceptionCode) { ASSERT(exceptionCode == WebCore::QUOTA_EXCEEDED_ERR); @@ -80,16 +80,16 @@ void WebStorageAreaImpl::setItem(const WebString& key, const WebString& value, c quotaException = false; } -void WebStorageAreaImpl::removeItem(const WebString& key, const WebURL& url) +void WebStorageAreaImpl::removeItem(const WebString& key, const WebURL& url, WebString& oldValue) { ScopedStorageEventURL scope(url); - m_storageArea->removeItem(key, 0); + oldValue = m_storageArea->removeItem(key, 0); } -void WebStorageAreaImpl::clear(const WebURL& url) +void WebStorageAreaImpl::clear(const WebURL& url, bool& somethingCleared) { ScopedStorageEventURL scope(url); - m_storageArea->clear(0); + somethingCleared = m_storageArea->clear(0); } } // namespace WebKit diff --git a/WebKit/chromium/src/WebStorageAreaImpl.h b/WebKit/chromium/src/WebStorageAreaImpl.h index e1f74e0..7e90531 100644 --- a/WebKit/chromium/src/WebStorageAreaImpl.h +++ b/WebKit/chromium/src/WebStorageAreaImpl.h @@ -45,9 +45,9 @@ public: virtual unsigned length(); virtual WebString key(unsigned index); virtual WebString getItem(const WebString& key); - virtual void setItem(const WebString& key, const WebString& value, const WebURL& url, bool& quotaException); - virtual void removeItem(const WebString& key, const WebURL& url); - virtual void clear(const WebURL& url); + virtual void setItem(const WebString& key, const WebString& value, const WebURL& url, bool& quotaException, WebString& oldValue); + virtual void removeItem(const WebString& key, const WebURL& url, WebString& oldValue); + virtual void clear(const WebURL& url, bool& somethingCleared); // For storage events in single-process mode and test shell. static const WebURL* currentStorageEventURL() { return storageEventURL; } diff --git a/WebKit/chromium/src/WebString.cpp b/WebKit/chromium/src/WebString.cpp index f45e05f..36d5f86 100644 --- a/WebKit/chromium/src/WebString.cpp +++ b/WebKit/chromium/src/WebString.cpp @@ -86,6 +86,11 @@ WebString WebString::fromUTF8(const char* data) return WebCore::String::fromUTF8(data); } +bool WebString::equals(const WebString& s) const +{ + return equal(m_private, s.m_private); +} + WebString::WebString(const WebCore::String& s) : m_private(static_cast<WebStringPrivate*>(s.impl())) { diff --git a/WebKit/chromium/src/WebURLResponse.cpp b/WebKit/chromium/src/WebURLResponse.cpp index 49f07f9..95e0be2 100644 --- a/WebKit/chromium/src/WebURLResponse.cpp +++ b/WebKit/chromium/src/WebURLResponse.cpp @@ -255,6 +255,16 @@ const ResourceResponse& WebURLResponse::toResourceResponse() const return *m_private->m_resourceResponse; } +bool WebURLResponse::wasFetchedViaSPDY() const +{ + return m_private->m_resourceResponse->wasFetchedViaSPDY(); +} + +void WebURLResponse::setWasFetchedViaSPDY(bool value) +{ + m_private->m_resourceResponse->setWasFetchedViaSPDY(value); +} + void WebURLResponse::assign(WebURLResponsePrivate* p) { // Subclasses may call this directly so a self-assignment check is needed diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp index 030c4bd..97825e9 100644 --- a/WebKit/chromium/src/WebViewImpl.cpp +++ b/WebKit/chromium/src/WebViewImpl.cpp @@ -33,6 +33,7 @@ #include "AutocompletePopupMenuClient.h" #include "AXObjectCache.h" +#include "Chrome.h" #include "ContextMenu.h" #include "ContextMenuController.h" #include "ContextMenuItem.h" @@ -65,6 +66,7 @@ #include "NodeRenderStyle.h" #include "Page.h" #include "PageGroup.h" +#include "PageGroupLoadDeferrer.h" #include "Pasteboard.h" #include "PlatformContextSkia.h" #include "PlatformKeyboardEvent.h" @@ -96,11 +98,11 @@ #include "WebVector.h" #include "WebViewClient.h" -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) #include "KeyboardCodesWin.h" #include "RenderThemeChromiumWin.h" #else -#if PLATFORM(LINUX) +#if OS(LINUX) #include "RenderThemeChromiumLinux.h" #endif #include "KeyboardCodesPosix.h" @@ -129,6 +131,10 @@ static const double maxTextSizeMultiplier = 3.0; // one page group. const char* pageGroupName = "default"; +// Used to defer all page activity in cases where the embedder wishes to run +// a nested event loop. +static PageGroupLoadDeferrer* pageGroupLoadDeferrer; + // Ensure that the WebDragOperation enum values stay in sync with the original // DragOperation constants. #define COMPILE_ASSERT_MATCHING_ENUM(coreName) \ @@ -174,6 +180,28 @@ void WebView::resetVisitedLinkState() Page::allVisitedStateChanged(PageGroup::pageGroup(pageGroupName)); } +void WebView::willEnterModalLoop() +{ + // It is not valid to nest more than once. + ASSERT(!pageGroupLoadDeferrer); + + PageGroup* pageGroup = PageGroup::pageGroup(pageGroupName); + ASSERT(pageGroup); + ASSERT(!pageGroup->pages().isEmpty()); + + // Pick any page in the page group since we are deferring all pages. + pageGroupLoadDeferrer = new PageGroupLoadDeferrer(*pageGroup->pages().begin(), true); +} + +void WebView::didExitModalLoop() +{ + // The embedder must have called willEnterNestedEventLoop. + ASSERT(pageGroupLoadDeferrer); + + delete pageGroupLoadDeferrer; + pageGroupLoadDeferrer = 0; +} + void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient) { // NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame @@ -327,12 +355,12 @@ void WebViewImpl::mouseDown(const WebMouseEvent& event) // Dispatch the contextmenu event regardless of if the click was swallowed. // On Windows, we handle it on mouse up, not down. -#if PLATFORM(DARWIN) +#if OS(DARWIN) if (event.button == WebMouseEvent::ButtonRight || (event.button == WebMouseEvent::ButtonLeft && event.modifiers & WebMouseEvent::ControlKey)) mouseContextMenu(event); -#elif PLATFORM(LINUX) +#elif OS(LINUX) if (event.button == WebMouseEvent::ButtonRight) mouseContextMenu(event); #endif @@ -355,7 +383,7 @@ void WebViewImpl::mouseContextMenu(const WebMouseEvent& event) else targetFrame = m_page->focusController()->focusedOrMainFrame(); -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) targetFrame->view()->setCursor(pointerCursor()); #endif @@ -371,7 +399,7 @@ void WebViewImpl::mouseUp(const WebMouseEvent& event) if (!mainFrameImpl() || !mainFrameImpl()->frameView()) return; -#if PLATFORM(LINUX) +#if OS(LINUX) // If the event was a middle click, attempt to copy text into the focused // frame. We execute this before we let the page have a go at the event // because the page may change what is focused during in its event handler. @@ -390,14 +418,14 @@ void WebViewImpl::mouseUp(const WebMouseEvent& event) // handleMouseReleaseEvent() earlier in this function if (event.button == WebMouseEvent::ButtonMiddle) { Frame* focused = focusedWebCoreFrame(); + FrameView* view = m_page->mainFrame()->view(); IntPoint clickPoint(m_lastMouseDownPoint.x, m_lastMouseDownPoint.y); - clickPoint = m_page->mainFrame()->view()->windowToContents(clickPoint); - HitTestResult hitTestResult = - focused->eventHandler()->hitTestResultAtPoint(clickPoint, false, false, - ShouldHitTestScrollbars); + IntPoint contentPoint = view->windowToContents(clickPoint); + HitTestResult hitTestResult = focused->eventHandler()->hitTestResultAtPoint(contentPoint, false, false, ShouldHitTestScrollbars); // We don't want to send a paste when middle clicking a scroll bar or a - // link (which will navigate later in the code). - if (!hitTestResult.scrollbar() && !hitTestResult.isLiveLink() && focused) { + // link (which will navigate later in the code). The main scrollbars + // have to be handled separately. + if (!hitTestResult.scrollbar() && !hitTestResult.isLiveLink() && focused && !view->scrollbarAtPoint(clickPoint)) { Editor* editor = focused->editor(); Pasteboard* pasteboard = Pasteboard::generalPasteboard(); bool oldSelectionMode = pasteboard->isSelectionMode(); @@ -412,7 +440,7 @@ void WebViewImpl::mouseUp(const WebMouseEvent& event) mainFrameImpl()->frame()->eventHandler()->handleMouseReleaseEvent( PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event)); -#if PLATFORM(WIN_OS) +#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) @@ -452,9 +480,17 @@ bool WebViewImpl::keyEvent(const WebKeyboardEvent& event) if (!handler) return keyEventDefault(event); -#if PLATFORM(WIN_OS) || PLATFORM(LINUX) - if ((!event.modifiers && (event.windowsKeyCode == VKEY_APPS)) - || ((event.modifiers == WebInputEvent::ShiftKey) && (event.windowsKeyCode == VKEY_F10))) { +#if OS(WINDOWS) || OS(LINUX) + const WebInputEvent::Type contextMenuTriggeringEventType = +#if OS(WINDOWS) + WebInputEvent::KeyUp; +#elif OS(LINUX) + WebInputEvent::RawKeyDown; +#endif + + if (((!event.modifiers && (event.windowsKeyCode == VKEY_APPS)) + || ((event.modifiers == WebInputEvent::ShiftKey) && (event.windowsKeyCode == VKEY_F10))) + && event.type == contextMenuTriggeringEventType) { sendContextMenuEvent(event); return true; } @@ -574,7 +610,7 @@ bool WebViewImpl::charEvent(const WebKeyboardEvent& event) // // This function is an ugly copy/paste and should be cleaned up when the // WebKitWin version is cleaned: https://bugs.webkit.org/show_bug.cgi?id=20438 -#if PLATFORM(WIN_OS) || PLATFORM(LINUX) +#if OS(WINDOWS) || OS(LINUX) // FIXME: implement on Mac bool WebViewImpl::sendContextMenuEvent(const WebKeyboardEvent& event) { @@ -585,22 +621,19 @@ bool WebViewImpl::sendContextMenuEvent(const WebKeyboardEvent& event) return false; IntPoint coords(-1, -1); -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); #else int rightAligned = 0; #endif IntPoint location; - // The context menu event was generated from the keyboard, so show the - // context menu by the current selection. - Position start = mainFrameImpl->selection()->selection().start(); - Position end = mainFrameImpl->selection()->selection().end(); Frame* focusedFrame = page()->focusController()->focusedOrMainFrame(); Node* focusedNode = focusedFrame->document()->focusedNode(); + Position start = mainFrameImpl->selection()->selection().start(); - if (start.node() && end.node()) { + if (focusedFrame->editor() && focusedFrame->editor()->canEdit() && start.node()) { RenderObject* renderer = start.node()->renderer(); if (!renderer) return false; @@ -1641,13 +1674,26 @@ bool WebViewImpl::isActive() const void WebViewImpl::setScrollbarColors(unsigned inactiveColor, unsigned activeColor, unsigned trackColor) { -#if PLATFORM(LINUX) +#if OS(LINUX) RenderThemeChromiumLinux::setScrollbarColors(inactiveColor, activeColor, trackColor); #endif } +void WebViewImpl::setSelectionColors(unsigned activeBackgroundColor, + unsigned activeForegroundColor, + unsigned inactiveBackgroundColor, + unsigned inactiveForegroundColor) { +#if OS(LINUX) + RenderThemeChromiumLinux::setSelectionColors(activeBackgroundColor, + activeForegroundColor, + inactiveBackgroundColor, + inactiveForegroundColor); + theme()->platformColorsDidChange(); +#endif +} + void WebViewImpl::didCommitLoad(bool* isNewNavigation) { if (isNewNavigation) @@ -1666,9 +1712,9 @@ bool WebViewImpl::navigationPolicyFromMouseEvent(unsigned short button, bool alt, bool meta, WebNavigationPolicy* policy) { -#if PLATFORM(WIN_OS) || PLATFORM(LINUX) || PLATFORM(FREEBSD) +#if OS(WINDOWS) || OS(LINUX) || OS(FREEBSD) const bool newTabModifier = (button == 1) || ctrl; -#elif PLATFORM(DARWIN) +#elif OS(DARWIN) const bool newTabModifier = (button == 1) || meta; #endif if (!newTabModifier && !shift && !alt) diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h index dd5191e..ed5cc5f 100644 --- a/WebKit/chromium/src/WebViewImpl.h +++ b/WebKit/chromium/src/WebViewImpl.h @@ -157,6 +157,10 @@ public: virtual void setScrollbarColors(unsigned inactiveColor, unsigned activeColor, unsigned trackColor); + virtual void setSelectionColors(unsigned activeBackgroundColor, + unsigned activeForegroundColor, + unsigned inactiveBackgroundColor, + unsigned inactiveForegroundColor); virtual void performCustomContextMenuAction(unsigned action); // WebViewImpl diff --git a/WebKit/chromium/src/WebWorkerBase.cpp b/WebKit/chromium/src/WebWorkerBase.cpp index 85a263b..7fd3749 100644 --- a/WebKit/chromium/src/WebWorkerBase.cpp +++ b/WebKit/chromium/src/WebWorkerBase.cpp @@ -132,8 +132,7 @@ void WebWorkerBase::initializeLoader(const WebURL& url) int len = static_cast<int>(content.length()); RefPtr<SharedBuffer> buf(SharedBuffer::create(content.data(), len)); SubstituteData substData(buf, String("text/html"), String("UTF-8"), KURL()); - ResourceRequest request(url, CString()); - webFrame->frame()->loader()->load(request, substData, false); + webFrame->frame()->loader()->load(ResourceRequest(url), substData, false); // This document will be used as 'loading context' for the worker. m_loadingDocument = webFrame->frame()->document(); @@ -158,7 +157,7 @@ void WebWorkerBase::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> PassOwnPtr<MessagePortChannelArray> channels) { dispatchTaskToMainThread(createCallbackTask(&postMessageTask, this, - message->toString(), channels)); + message->toWireString(), channels)); } void WebWorkerBase::postMessageTask(ScriptExecutionContext* context, diff --git a/WebKit/chromium/src/WebWorkerClientImpl.cpp b/WebKit/chromium/src/WebWorkerClientImpl.cpp index 6be03a7..598a078 100644 --- a/WebKit/chromium/src/WebWorkerClientImpl.cpp +++ b/WebKit/chromium/src/WebWorkerClientImpl.cpp @@ -173,7 +173,7 @@ void WebWorkerClientImpl::postMessageToWorkerContext( if (!isMainThread()) { WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postMessageToWorkerContextTask, this, - message->toString(), + message->toWireString(), channels)); return; } @@ -184,7 +184,7 @@ void WebWorkerClientImpl::postMessageToWorkerContext( webchannel->setClient(0); webChannels[i] = webchannel; } - m_webWorker->postMessageToWorkerContext(message->toString(), webChannels); + m_webWorker->postMessageToWorkerContext(message->toWireString(), webChannels); } bool WebWorkerClientImpl::hasPendingActivity() const @@ -356,7 +356,7 @@ void WebWorkerClientImpl::postMessageToWorkerObjectTask( OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*context, channels.release()); RefPtr<SerializedScriptValue> serializedMessage = - SerializedScriptValue::create(message); + SerializedScriptValue::createFromWire(message); thisPtr->m_worker->dispatchEvent(MessageEvent::create(ports.release(), serializedMessage.release())); } diff --git a/WebKit/chromium/src/WebWorkerImpl.cpp b/WebKit/chromium/src/WebWorkerImpl.cpp index 744be30..5b5e053 100644 --- a/WebKit/chromium/src/WebWorkerImpl.cpp +++ b/WebKit/chromium/src/WebWorkerImpl.cpp @@ -88,7 +88,7 @@ void WebWorkerImpl::postMessageToWorkerContextTask(WebCore::ScriptExecutionConte OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*context, channels.release()); RefPtr<SerializedScriptValue> serializedMessage = - SerializedScriptValue::create(message); + SerializedScriptValue::createFromWire(message); workerContext->dispatchEvent(MessageEvent::create( ports.release(), serializedMessage.release())); thisPtr->confirmMessageFromWorkerObject(workerContext->hasPendingActivity()); diff --git a/WebKit/chromium/src/mac/WebInputEventFactory.mm b/WebKit/chromium/src/mac/WebInputEventFactory.mm index d618228..46b0afe 100644 --- a/WebKit/chromium/src/mac/WebInputEventFactory.mm +++ b/WebKit/chromium/src/mac/WebInputEventFactory.mm @@ -92,6 +92,9 @@ static bool isKeypadEvent(NSEvent* event) return false; } + if ([event modifierFlags] & NSNumericPadKeyMask) + return true; + switch ([event keyCode]) { case 71: // Clear case 81: // = diff --git a/WebKit/chromium/tests/KURLTest.cpp b/WebKit/chromium/tests/KURLTest.cpp new file mode 100644 index 0000000..b316683 --- /dev/null +++ b/WebKit/chromium/tests/KURLTest.cpp @@ -0,0 +1,611 @@ +/* + * 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. + */ + +// Basic tests that verify our KURL's interface behaves the same as the +// original KURL's. + +#include "config.h" + +#include <gtest/gtest.h> + +#include "KURL.h" + +namespace { + +// Output stream operator so gTest's macros work with WebCore strings. +std::ostream& operator<<(std::ostream& out, const WebCore::String& str) +{ + return str.isEmpty() ? out : out << str.utf8().data(); +} + +struct ComponentCase { + const char* url; + const char* protocol; + const char* host; + const int port; + const char* user; + const char* pass; + const char* path; + const char* lastPath; + const char* query; + const char* ref; +}; + +// Test the cases where we should be the same as WebKit's old KURL. +TEST(KURLTest, SameGetters) +{ + struct GetterCase { + const char* url; + const char* protocol; + const char* host; + int port; + const char* user; + const char* pass; + const char* lastPathComponent; + const char* query; + const char* ref; + bool hasRef; + } cases[] = { + {"http://www.google.com/foo/blah?bar=baz#ref", "http", "www.google.com", 0, "", 0, "blah", "bar=baz", "ref", true}, + {"http://foo.com:1234/foo/bar/", "http", "foo.com", 1234, "", 0, "bar", 0, 0, false}, + {"http://www.google.com?#", "http", "www.google.com", 0, "", 0, 0, "", "", true}, + {"https://me:pass@google.com:23#foo", "https", "google.com", 23, "me", "pass", 0, 0, "foo", true}, + {"javascript:hello!//world", "javascript", "", 0, "", 0, "world", 0, 0, false}, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { + // UTF-8 + WebCore::KURL kurl(WebCore::ParsedURLString, cases[i].url); + + EXPECT_EQ(cases[i].protocol, kurl.protocol()); + EXPECT_EQ(cases[i].host, kurl.host()); + EXPECT_EQ(cases[i].port, kurl.port()); + EXPECT_EQ(cases[i].user, kurl.user()); + EXPECT_EQ(cases[i].pass, kurl.pass()); + EXPECT_EQ(cases[i].lastPathComponent, kurl.lastPathComponent()); + EXPECT_EQ(cases[i].query, kurl.query()); + EXPECT_EQ(cases[i].ref, kurl.fragmentIdentifier()); + EXPECT_EQ(cases[i].hasRef, kurl.hasFragmentIdentifier()); + + // UTF-16 + WebCore::String utf16(cases[i].url); + kurl = WebCore::KURL(WebCore::ParsedURLString, utf16); + + EXPECT_EQ(cases[i].protocol, kurl.protocol()); + EXPECT_EQ(cases[i].host, kurl.host()); + EXPECT_EQ(cases[i].port, kurl.port()); + EXPECT_EQ(cases[i].user, kurl.user()); + EXPECT_EQ(cases[i].pass, kurl.pass()); + EXPECT_EQ(cases[i].lastPathComponent, kurl.lastPathComponent()); + EXPECT_EQ(cases[i].query, kurl.query()); + EXPECT_EQ(cases[i].ref, kurl.fragmentIdentifier()); + EXPECT_EQ(cases[i].hasRef, kurl.hasFragmentIdentifier()); + } +} + +// Test a few cases where we're different just to make sure we give reasonable +// output. +TEST(KURLTest, DifferentGetters) +{ + ComponentCase cases[] = { + // url protocol host port user pass path lastPath query ref + + // Old WebKit allows references and queries in what we call "path" URLs + // like javascript, so the path here will only consist of "hello!". + {"javascript:hello!?#/\\world", "javascript", "", 0, "", 0, "hello!?#/\\world", "world", 0, 0}, + + // Old WebKit doesn't handle "parameters" in paths, so will + // disagree with us about where the path is for this URL. + {"http://a.com/hello;world", "http", "a.com", 0, "", 0, "/hello;world", "hello", 0, 0}, + + // WebKit doesn't like UTF-8 or UTF-16 input. + {"http://\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xbd\xa0\xe5\xa5\xbd/", "http", "xn--6qqa088eba", 0, "", 0, "/", 0, 0, 0}, + + // WebKit %-escapes non-ASCII characters in reference, but we don't. + {"http://www.google.com/foo/blah?bar=baz#\xce\xb1\xce\xb2", "http", "www.google.com", 0, "", 0, "/foo/blah/", "blah", "bar=baz", "\xce\xb1\xce\xb2"}, + }; + + for (size_t i = 0; i < arraysize(cases); i++) { + WebCore::KURL kurl(WebCore::ParsedURLString, cases[i].url); + + EXPECT_EQ(cases[i].protocol, kurl.protocol()); + EXPECT_EQ(cases[i].host, kurl.host()); + EXPECT_EQ(cases[i].port, kurl.port()); + EXPECT_EQ(cases[i].user, kurl.user()); + EXPECT_EQ(cases[i].pass, kurl.pass()); + EXPECT_EQ(cases[i].lastPath, kurl.lastPathComponent()); + EXPECT_EQ(cases[i].query, kurl.query()); + // Want to compare UCS-16 refs (or to null). + if (cases[i].ref) + EXPECT_EQ(WebCore::String::fromUTF8(cases[i].ref), kurl.fragmentIdentifier()); + else + EXPECT_TRUE(kurl.fragmentIdentifier().isNull()); + } +} + +// Ensures that both ASCII and UTF-8 canonical URLs are handled properly and we +// get the correct string object out. +TEST(KURLTest, UTF8) +{ + const char asciiURL[] = "http://foo/bar#baz"; + WebCore::KURL asciiKURL(WebCore::ParsedURLString, asciiURL); + EXPECT_TRUE(asciiKURL.string() == WebCore::String(asciiURL)); + + // When the result is ASCII, we should get an ASCII String. Some + // code depends on being able to compare the result of the .string() + // getter with another String, and the isASCIIness of the two + // strings must match for these functions (like equalIgnoringCase). + EXPECT_TRUE(WebCore::equalIgnoringCase(asciiKURL, WebCore::String(asciiURL))); + + // Reproduce code path in FrameLoader.cpp -- equalIgnoringCase implicitly + // expects gkurl.protocol() to have been created as ascii. + WebCore::KURL mailto(WebCore::ParsedURLString, "mailto:foo@foo.com"); + EXPECT_TRUE(WebCore::equalIgnoringCase(mailto.protocol(), "mailto")); + + const char utf8URL[] = "http://foo/bar#\xe4\xbd\xa0\xe5\xa5\xbd"; + WebCore::KURL utf8KURL(WebCore::ParsedURLString, utf8URL); + + EXPECT_TRUE(utf8KURL.string() == WebCore::String::fromUTF8(utf8URL)); +} + +TEST(KURLTest, Setters) +{ + // Replace the starting URL with the given components one at a time and + // verify that we're always the same as the old KURL. + // + // Note that old KURL won't canonicalize the default port away, so we + // can't set setting the http port to "80" (or even "0"). + // + // We also can't test clearing the query. + // + // The format is every other row is a test, and the row that follows it is the + // expected result. + struct ExpectedComponentCase { + const char* url; + const char* protocol; + const char* host; + const int port; + const char* user; + const char* pass; + const char* path; + const char* query; + const char* ref; + + // The full expected URL with the given "set" applied. + const char* expectedProtocol; + const char* expectedHost; + const char* expectedPort; + const char* expectedUser; + const char* expectedPass; + const char* expectedPath; + const char* expectedQuery; + const char* expectedRef; + } cases[] = { + // url protocol host port user pass path query ref + {"http://www.google.com/", "https", "news.google.com", 8888, "me", "pass", "/foo", "?q=asdf", "heehee", + "https://www.google.com/", + "https://news.google.com/", + "https://news.google.com:8888/", + "https://me@news.google.com:8888/", + "https://me:pass@news.google.com:8888/", + "https://me:pass@news.google.com:8888/foo", + "https://me:pass@news.google.com:8888/foo?q=asdf", + "https://me:pass@news.google.com:8888/foo?q=asdf#heehee"}, + + {"https://me:pass@google.com:88/a?f#b", "http", "goo.com", 92, "", "", "/", 0, "", + "http://me:pass@google.com:88/a?f#b", + "http://me:pass@goo.com:88/a?f#b", + "http://me:pass@goo.com:92/a?f#b", + "http://:pass@goo.com:92/a?f#b", + "http://goo.com:92/a?f#b", + "http://goo.com:92/?f#b", + "http://goo.com:92/#b", + "https://goo.com:92/"}, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { + WebCore::KURL kurl(WebCore::ParsedURLString, cases[i].url); + + kurl.setProtocol(cases[i].protocol); + EXPECT_STREQ(cases[i].expectedProtocol, kurl.string().utf8().data()); + + kurl.setHost(cases[i].host); + EXPECT_STREQ(cases[i].expectedHost, kurl.string().utf8().data()); + + kurl.setPort(cases[i].port); + EXPECT_STREQ(cases[i].expectedPort, kurl.string().utf8().data()); + + kurl.setUser(cases[i].user); + EXPECT_STREQ(cases[i].expectedUser, kurl.string().utf8().data()); + + kurl.setPass(cases[i].pass); + EXPECT_STREQ(cases[i].expectedPass, kurl.string().utf8().data()); + + kurl.setPath(cases[i].path); + EXPECT_STREQ(cases[i].expectedPath, kurl.string().utf8().data()); + + kurl.setQuery(cases[i].query); + EXPECT_STREQ(cases[i].expectedQuery, kurl.string().utf8().data()); + + // Refs are tested below. On the Safari 3.1 branch, we don't match their + // KURL since we integrated a fix from their trunk. + } +} + +// Tests that KURL::decodeURLEscapeSequences works as expected +#if USE(GOOGLEURL) +TEST(KURLTest, Decode) +{ + struct DecodeCase { + const char* input; + const char* output; + } decodeCases[] = { + {"hello, world", "hello, world"}, + {"%01%02%03%04%05%06%07%08%09%0a%0B%0C%0D%0e%0f/", "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0B\x0C\x0D\x0e\x0f/"}, + {"%10%11%12%13%14%15%16%17%18%19%1a%1B%1C%1D%1e%1f/", "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1B\x1C\x1D\x1e\x1f/"}, + {"%20%21%22%23%24%25%26%27%28%29%2a%2B%2C%2D%2e%2f/", " !\"#$%&'()*+,-.//"}, + {"%30%31%32%33%34%35%36%37%38%39%3a%3B%3C%3D%3e%3f/", "0123456789:;<=>?/"}, + {"%40%41%42%43%44%45%46%47%48%49%4a%4B%4C%4D%4e%4f/", "@ABCDEFGHIJKLMNO/"}, + {"%50%51%52%53%54%55%56%57%58%59%5a%5B%5C%5D%5e%5f/", "PQRSTUVWXYZ[\\]^_/"}, + {"%60%61%62%63%64%65%66%67%68%69%6a%6B%6C%6D%6e%6f/", "`abcdefghijklmno/"}, + {"%70%71%72%73%74%75%76%77%78%79%7a%7B%7C%7D%7e%7f/", "pqrstuvwxyz{|}~\x7f/"}, + // Test un-UTF-8-ization. + {"%e4%bd%a0%e5%a5%bd", "\xe4\xbd\xa0\xe5\xa5\xbd"}, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(decodeCases); i++) { + WebCore::String input(decodeCases[i].input); + WebCore::String str = WebCore::decodeURLEscapeSequences(input); + EXPECT_STREQ(decodeCases[i].output, str.utf8().data()); + } + + // Our decode should decode %00 + WebCore::String zero = WebCore::decodeURLEscapeSequences("%00"); + EXPECT_STRNE("%00", zero.utf8().data()); + + // Test the error behavior for invalid UTF-8 (we differ from WebKit here). + WebCore::String invalid = WebCore::decodeURLEscapeSequences( + "%e4%a0%e5%a5%bd"); + char16 invalidExpectedHelper[4] = { 0x00e4, 0x00a0, 0x597d, 0 }; + WebCore::String invalidExpected( + reinterpret_cast<const ::UChar*>(invalidExpectedHelper), + 3); + EXPECT_EQ(invalidExpected, invalid); +} +#endif + +TEST(KURLTest, Encode) +{ + // Also test that it gets converted to UTF-8 properly. + char16 wideInputHelper[3] = { 0x4f60, 0x597d, 0 }; + WebCore::String wideInput( + reinterpret_cast<const ::UChar*>(wideInputHelper), 2); + WebCore::String wideReference("\xe4\xbd\xa0\xe5\xa5\xbd", 6); + WebCore::String wideOutput = + WebCore::encodeWithURLEscapeSequences(wideInput); + EXPECT_EQ(wideReference, wideOutput); + + // Our encode only escapes NULLs for safety (see the implementation for + // more), so we only bother to test a few cases. + WebCore::String input( + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", 16); + WebCore::String reference( + "%00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", 18); + WebCore::String output = WebCore::encodeWithURLEscapeSequences(input); + EXPECT_EQ(reference, output); +} + +TEST(KURLTest, ResolveEmpty) +{ + WebCore::KURL emptyBase; + + // WebKit likes to be able to resolve absolute input agains empty base URLs, + // which would normally be invalid since the base URL is invalid. + const char abs[] = "http://www.google.com/"; + WebCore::KURL resolveAbs(emptyBase, abs); + EXPECT_TRUE(resolveAbs.isValid()); + EXPECT_STREQ(abs, resolveAbs.string().utf8().data()); + + // Resolving a non-relative URL agains the empty one should still error. + const char rel[] = "foo.html"; + WebCore::KURL resolveErr(emptyBase, rel); + EXPECT_FALSE(resolveErr.isValid()); +} + +// WebKit will make empty URLs and set components on them. kurl doesn't allow +// replacements on invalid URLs, but here we do. +TEST(KURLTest, ReplaceInvalid) +{ + WebCore::KURL kurl; + + EXPECT_FALSE(kurl.isValid()); + EXPECT_TRUE(kurl.isEmpty()); + EXPECT_STREQ("", kurl.string().utf8().data()); + + kurl.setProtocol("http"); + // GKURL will say that a URL with just a scheme is invalid, KURL will not. +#if USE(GOOGLEURL) + EXPECT_FALSE(kurl.isValid()); +#else + EXPECT_TRUE(kurl.isValid()); +#endif + EXPECT_FALSE(kurl.isEmpty()); + // At this point, we do things slightly differently if there is only a scheme. + // We check the results here to make it more obvious what is going on, but it + // shouldn't be a big deal if these change. +#if USE(GOOGLEURL) + EXPECT_STREQ("http:", kurl.string().utf8().data()); +#else + EXPECT_STREQ("http:/", kurl.string().utf8().data()); +#endif + + kurl.setHost("www.google.com"); + EXPECT_TRUE(kurl.isValid()); + EXPECT_FALSE(kurl.isEmpty()); + EXPECT_STREQ("http://www.google.com/", kurl.string().utf8().data()); + + kurl.setPort(8000); + EXPECT_TRUE(kurl.isValid()); + EXPECT_FALSE(kurl.isEmpty()); + EXPECT_STREQ("http://www.google.com:8000/", kurl.string().utf8().data()); + + kurl.setPath("/favicon.ico"); + EXPECT_TRUE(kurl.isValid()); + EXPECT_FALSE(kurl.isEmpty()); + EXPECT_STREQ("http://www.google.com:8000/favicon.ico", kurl.string().utf8().data()); + + // Now let's test that giving an invalid replacement still fails. +#if USE(GOOGLEURL) + kurl.setProtocol("f/sj#@"); + EXPECT_FALSE(kurl.isValid()); +#endif +} + +TEST(KURLTest, Path) +{ + const char initial[] = "http://www.google.com/path/foo"; + WebCore::KURL kurl(WebCore::ParsedURLString, initial); + + // Clear by setting a null string. + WebCore::String nullString; + EXPECT_TRUE(nullString.isNull()); + kurl.setPath(nullString); + EXPECT_STREQ("http://www.google.com/", kurl.string().utf8().data()); +} + +// Test that setting the query to different things works. Thq query is handled +// a littler differently than some of the other components. +TEST(KURLTest, Query) +{ + const char initial[] = "http://www.google.com/search?q=awesome"; + WebCore::KURL kurl(WebCore::ParsedURLString, initial); + + // Clear by setting a null string. + WebCore::String nullString; + EXPECT_TRUE(nullString.isNull()); + kurl.setQuery(nullString); + EXPECT_STREQ("http://www.google.com/search", kurl.string().utf8().data()); + + // Clear by setting an empty string. + kurl = WebCore::KURL(WebCore::ParsedURLString, initial); + WebCore::String emptyString(""); + EXPECT_FALSE(emptyString.isNull()); + kurl.setQuery(emptyString); + EXPECT_STREQ("http://www.google.com/search?", kurl.string().utf8().data()); + + // Set with something that begins in a question mark. + const char question[] = "?foo=bar"; + kurl.setQuery(question); + EXPECT_STREQ("http://www.google.com/search?foo=bar", + kurl.string().utf8().data()); + + // Set with something that doesn't begin in a question mark. + const char query[] = "foo=bar"; + kurl.setQuery(query); + EXPECT_STREQ("http://www.google.com/search?foo=bar", + kurl.string().utf8().data()); +} + +TEST(KURLTest, Ref) +{ + WebCore::KURL kurl(WebCore::ParsedURLString, "http://foo/bar#baz"); + + // Basic ref setting. + WebCore::KURL cur(WebCore::ParsedURLString, "http://foo/bar"); + cur.setFragmentIdentifier("asdf"); + EXPECT_STREQ("http://foo/bar#asdf", cur.string().utf8().data()); + cur = kurl; + cur.setFragmentIdentifier("asdf"); + EXPECT_STREQ("http://foo/bar#asdf", cur.string().utf8().data()); + + // Setting a ref to the empty string will set it to "#". + cur = WebCore::KURL(WebCore::ParsedURLString, "http://foo/bar"); + cur.setFragmentIdentifier(""); + EXPECT_STREQ("http://foo/bar#", cur.string().utf8().data()); + cur = kurl; + cur.setFragmentIdentifier(""); + EXPECT_STREQ("http://foo/bar#", cur.string().utf8().data()); + + // Setting the ref to the null string will clear it altogether. + cur = WebCore::KURL(WebCore::ParsedURLString, "http://foo/bar"); + cur.setFragmentIdentifier(WebCore::String()); + EXPECT_STREQ("http://foo/bar", cur.string().utf8().data()); + cur = kurl; + cur.setFragmentIdentifier(WebCore::String()); + EXPECT_STREQ("http://foo/bar", cur.string().utf8().data()); +} + +TEST(KURLTest, Empty) +{ + WebCore::KURL kurl; + + // First test that regular empty URLs are the same. + EXPECT_TRUE(kurl.isEmpty()); + EXPECT_FALSE(kurl.isValid()); + EXPECT_TRUE(kurl.isNull()); + EXPECT_TRUE(kurl.string().isNull()); + EXPECT_TRUE(kurl.string().isEmpty()); + + // Test resolving a null URL on an empty string. + WebCore::KURL kurl2(kurl, ""); + EXPECT_FALSE(kurl2.isNull()); + EXPECT_TRUE(kurl2.isEmpty()); + EXPECT_FALSE(kurl2.isValid()); + EXPECT_FALSE(kurl2.string().isNull()); + EXPECT_TRUE(kurl2.string().isEmpty()); + EXPECT_FALSE(kurl2.string().isNull()); + EXPECT_TRUE(kurl2.string().isEmpty()); + + // Resolve the null URL on a null string. + WebCore::KURL kurl22(kurl, WebCore::String()); + EXPECT_FALSE(kurl22.isNull()); + EXPECT_TRUE(kurl22.isEmpty()); + EXPECT_FALSE(kurl22.isValid()); + EXPECT_FALSE(kurl22.string().isNull()); + EXPECT_TRUE(kurl22.string().isEmpty()); + EXPECT_FALSE(kurl22.string().isNull()); + EXPECT_TRUE(kurl22.string().isEmpty()); + + // Test non-hierarchical schemes resolving. The actual URLs will be different. + // WebKit's one will set the string to "something.gif" and we'll set it to an + // empty string. I think either is OK, so we just check our behavior. +#if USE(GOOGLEURL) + WebCore::KURL kurl3(WebCore::KURL(WebCore::ParsedURLString, "data:foo"), + "something.gif"); + EXPECT_TRUE(kurl3.isEmpty()); + EXPECT_FALSE(kurl3.isValid()); +#endif + + // Test for weird isNull string input, + // see: http://bugs.webkit.org/show_bug.cgi?id=16487 + WebCore::KURL kurl4(WebCore::ParsedURLString, kurl.string()); + EXPECT_TRUE(kurl4.isEmpty()); + EXPECT_FALSE(kurl4.isValid()); + EXPECT_TRUE(kurl4.string().isNull()); + EXPECT_TRUE(kurl4.string().isEmpty()); + + // Resolving an empty URL on an invalid string. + WebCore::KURL kurl5(WebCore::KURL(), "foo.js"); + // We'll be empty in this case, but KURL won't be. Should be OK. + // EXPECT_EQ(kurl5.isEmpty(), kurl5.isEmpty()); + // EXPECT_EQ(kurl5.string().isEmpty(), kurl5.string().isEmpty()); + EXPECT_FALSE(kurl5.isValid()); + EXPECT_FALSE(kurl5.string().isNull()); + + // Empty string as input + WebCore::KURL kurl6(WebCore::ParsedURLString, ""); + EXPECT_TRUE(kurl6.isEmpty()); + EXPECT_FALSE(kurl6.isValid()); + EXPECT_FALSE(kurl6.string().isNull()); + EXPECT_TRUE(kurl6.string().isEmpty()); + + // Non-empty but invalid C string as input. + WebCore::KURL kurl7(WebCore::ParsedURLString, "foo.js"); + // WebKit will actually say this URL has the string "foo.js" but is invalid. + // We don't do that. + // EXPECT_EQ(kurl7.isEmpty(), kurl7.isEmpty()); + EXPECT_FALSE(kurl7.isValid()); + EXPECT_FALSE(kurl7.string().isNull()); +} + +TEST(KURLTest, UserPass) +{ + const char* src = "http://user:pass@google.com/"; + WebCore::KURL kurl(WebCore::ParsedURLString, src); + + // Clear just the username. + kurl.setUser(""); + EXPECT_EQ("http://:pass@google.com/", kurl.string()); + + // Clear just the password. + kurl = WebCore::KURL(WebCore::ParsedURLString, src); + kurl.setPass(""); + EXPECT_EQ("http://user@google.com/", kurl.string()); + + // Now clear both. + kurl.setUser(""); + EXPECT_EQ("http://google.com/", kurl.string()); +} + +TEST(KURLTest, Offsets) +{ + const char* src1 = "http://user:pass@google.com/foo/bar.html?baz=query#ref"; + WebCore::KURL kurl1(WebCore::ParsedURLString, src1); + + EXPECT_EQ(17u, kurl1.hostStart()); + EXPECT_EQ(27u, kurl1.hostEnd()); + EXPECT_EQ(27u, kurl1.pathStart()); + EXPECT_EQ(40u, kurl1.pathEnd()); + EXPECT_EQ(32u, kurl1.pathAfterLastSlash()); + + const char* src2 = "http://google.com/foo/"; + WebCore::KURL kurl2(WebCore::ParsedURLString, src2); + + EXPECT_EQ(7u, kurl2.hostStart()); + EXPECT_EQ(17u, kurl2.hostEnd()); + EXPECT_EQ(17u, kurl2.pathStart()); + EXPECT_EQ(22u, kurl2.pathEnd()); + EXPECT_EQ(22u, kurl2.pathAfterLastSlash()); + + const char* src3 = "javascript:foobar"; + WebCore::KURL kurl3(WebCore::ParsedURLString, src3); + + EXPECT_EQ(11u, kurl3.hostStart()); + EXPECT_EQ(11u, kurl3.hostEnd()); + EXPECT_EQ(11u, kurl3.pathStart()); + EXPECT_EQ(17u, kurl3.pathEnd()); + EXPECT_EQ(11u, kurl3.pathAfterLastSlash()); +} + +TEST(KURLTest, DeepCopy) +{ + const char url[] = "http://www.google.com/"; + WebCore::KURL src(WebCore::ParsedURLString, url); + EXPECT_TRUE(src.string() == url); // This really just initializes the cache. + WebCore::KURL dest = src.copy(); + EXPECT_TRUE(dest.string() == url); // This really just initializes the cache. + + // The pointers should be different for both UTF-8 and UTF-16. + EXPECT_NE(dest.string().characters(), src.string().characters()); + EXPECT_NE(dest.utf8String().data(), src.utf8String().data()); +} + +TEST(KURLTest, ProtocolIs) +{ + WebCore::KURL url1(WebCore::ParsedURLString, "foo://bar"); + EXPECT_TRUE(url1.protocolIs("foo")); + EXPECT_FALSE(url1.protocolIs("foo-bar")); + + WebCore::KURL url2(WebCore::ParsedURLString, "foo-bar:"); + EXPECT_TRUE(url2.protocolIs("foo-bar")); + EXPECT_FALSE(url2.protocolIs("foo")); +} + +} // namespace diff --git a/WebKit/chromium/tests/KeyboardTest.cpp b/WebKit/chromium/tests/KeyboardTest.cpp new file mode 100644 index 0000000..07bed3c --- /dev/null +++ b/WebKit/chromium/tests/KeyboardTest.cpp @@ -0,0 +1,213 @@ +/* + * 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 <gtest/gtest.h> + +#include "EditorClientImpl.h" +#include "EventTarget.h" +#include "KeyboardCodes.h" +#include "KeyboardEvent.h" +#include "WebInputEvent.h" +#include "WebInputEventConversion.h" + +using namespace WebCore; +using namespace WebKit; + +namespace { + +class KeyboardTest : public testing::Test { +public: + + // Pass a WebKeyboardEvent into the EditorClient and get back the string + // name of which editing event that key causes. + // E.g., sending in the enter key gives back "InsertNewline". + const char* interpretKeyEvent( + const WebKeyboardEvent& webKeyboardEvent, + PlatformKeyboardEvent::Type keyType) + { + EditorClientImpl editorImpl(0); + PlatformKeyboardEventBuilder evt(webKeyboardEvent); + evt.setKeyType(keyType); + RefPtr<KeyboardEvent> keyboardEvent = KeyboardEvent::create(evt, 0); + return editorImpl.interpretKeyEvent(keyboardEvent.get()); + } + + // Set up a WebKeyboardEvent KEY_DOWN event with key code and modifiers. + void setupKeyDownEvent(WebKeyboardEvent* keyboardEvent, + char keyCode, + int modifiers) + { + keyboardEvent->windowsKeyCode = keyCode; + keyboardEvent->modifiers = modifiers; + keyboardEvent->type = WebInputEvent::KeyDown; + keyboardEvent->text[0] = keyCode; + keyboardEvent->setKeyIdentifierFromWindowsKeyCode(); + } + + // Like interpretKeyEvent, but with pressing down OSModifier+|keyCode|. + // OSModifier is the platform's standard modifier key: control on most + // platforms, but meta (command) on Mac. + const char* interpretOSModifierKeyPress(char keyCode) + { + WebKeyboardEvent keyboardEvent; +#if OS(DARWIN) + WebInputEvent::Modifiers osModifier = WebInputEvent::MetaKey; +#else + WebInputEvent::Modifiers osModifier = WebInputEvent::ControlKey; +#endif + setupKeyDownEvent(&keyboardEvent, keyCode, osModifier); + return interpretKeyEvent(keyboardEvent, PlatformKeyboardEvent::RawKeyDown); + } + + // Like interpretKeyEvent, but with pressing down ctrl+|keyCode|. + const char* interpretCtrlKeyPress(char keyCode) + { + WebKeyboardEvent keyboardEvent; + setupKeyDownEvent(&keyboardEvent, keyCode, WebInputEvent::ControlKey); + return interpretKeyEvent(keyboardEvent, PlatformKeyboardEvent::RawKeyDown); + } + + // Like interpretKeyEvent, but with typing a tab. + const char* interpretTab(int modifiers) + { + WebKeyboardEvent keyboardEvent; + setupKeyDownEvent(&keyboardEvent, '\t', modifiers); + return interpretKeyEvent(keyboardEvent, PlatformKeyboardEvent::Char); + } + + // Like interpretKeyEvent, but with typing a newline. + const char* interpretNewLine(int modifiers) + { + WebKeyboardEvent keyboardEvent; + setupKeyDownEvent(&keyboardEvent, '\r', modifiers); + return interpretKeyEvent(keyboardEvent, PlatformKeyboardEvent::Char); + } + + // A name for "no modifiers set". + static const int noModifiers = 0; +}; + +TEST_F(KeyboardTest, TestCtrlReturn) +{ + EXPECT_STREQ("InsertNewline", interpretCtrlKeyPress(0xD)); +} + +TEST_F(KeyboardTest, TestOSModifierZ) +{ +#if !OS(DARWIN) + EXPECT_STREQ("Undo", interpretOSModifierKeyPress('Z')); +#endif +} + +TEST_F(KeyboardTest, TestOSModifierY) +{ +#if !OS(DARWIN) + EXPECT_STREQ("Redo", interpretOSModifierKeyPress('Y')); +#endif +} + +TEST_F(KeyboardTest, TestOSModifierA) +{ +#if !OS(DARWIN) + EXPECT_STREQ("SelectAll", interpretOSModifierKeyPress('A')); +#endif +} + +TEST_F(KeyboardTest, TestOSModifierX) +{ +#if !OS(DARWIN) + EXPECT_STREQ("Cut", interpretOSModifierKeyPress('X')); +#endif +} + +TEST_F(KeyboardTest, TestOSModifierC) +{ +#if !OS(DARWIN) + EXPECT_STREQ("Copy", interpretOSModifierKeyPress('C')); +#endif +} + +TEST_F(KeyboardTest, TestOSModifierV) +{ +#if !OS(DARWIN) + EXPECT_STREQ("Paste", interpretOSModifierKeyPress('V')); +#endif +} + +TEST_F(KeyboardTest, TestEscape) +{ + WebKeyboardEvent keyboardEvent; + setupKeyDownEvent(&keyboardEvent, WebCore::VKEY_ESCAPE, noModifiers); + + const char* result = interpretKeyEvent(keyboardEvent, + PlatformKeyboardEvent::RawKeyDown); + EXPECT_STREQ("Cancel", result); +} + +TEST_F(KeyboardTest, TestInsertTab) +{ + EXPECT_STREQ("InsertTab", interpretTab(noModifiers)); +} + +TEST_F(KeyboardTest, TestInsertBackTab) +{ + EXPECT_STREQ("InsertBacktab", interpretTab(WebInputEvent::ShiftKey)); +} + +TEST_F(KeyboardTest, TestInsertNewline) +{ + EXPECT_STREQ("InsertNewline", interpretNewLine(noModifiers)); +} + +TEST_F(KeyboardTest, TestInsertNewline2) +{ + EXPECT_STREQ("InsertNewline", interpretNewLine(WebInputEvent::ControlKey)); +} + +TEST_F(KeyboardTest, TestInsertLineBreak) +{ + EXPECT_STREQ("InsertLineBreak", interpretNewLine(WebInputEvent::ShiftKey)); +} + +TEST_F(KeyboardTest, TestInsertNewline3) +{ + EXPECT_STREQ("InsertNewline", interpretNewLine(WebInputEvent::AltKey)); +} + +TEST_F(KeyboardTest, TestInsertNewline4) +{ + int modifiers = WebInputEvent::AltKey | WebInputEvent::ShiftKey; + const char* result = interpretNewLine(modifiers); + EXPECT_STREQ("InsertNewline", result); +} + +} // empty namespace diff --git a/WebKit/chromium/tests/RunAllTests.cpp b/WebKit/chromium/tests/RunAllTests.cpp new file mode 100644 index 0000000..0f3f82f --- /dev/null +++ b/WebKit/chromium/tests/RunAllTests.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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// FIXME: Avoid this source dependency on Chromium's base module. +#include <base/test/test_suite.h> + +#include "WebKit.h" +#include "WebKitClient.h" + +// WebKitClient has a protected destructor, so we need to subclass. +class DummyWebKitClient : public WebKit::WebKitClient { +}; + +int main(int argc, char** argv) +{ + DummyWebKitClient dummyClient; + WebKit::initialize(&dummyClient); + + int result = TestSuite(argc, argv).Run(); + + WebKit::shutdown(); + return result; +} |