diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
commit | 49233e234e5c787396cadb2cea33b31ae0cd65c1 (patch) | |
tree | 5410cb9a8fd53168bb60d62c54b654d86f03c38d /Source/WebKit/chromium/src | |
parent | b211c645d8ab690f713515dfdc84d80b11c27d2c (diff) | |
download | qtwebkit-49233e234e5c787396cadb2cea33b31ae0cd65c1.tar.gz |
Imported WebKit commit 3a8c29f35d00659d2ce7a0ccdfa8304f14e82327 (http://svn.webkit.org/repository/webkit/trunk@120813)
New snapshot with Windows build fixes
Diffstat (limited to 'Source/WebKit/chromium/src')
74 files changed, 1189 insertions, 2310 deletions
diff --git a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp index c323d10ab..403088bc9 100644 --- a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp +++ b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp @@ -581,3 +581,7 @@ COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::Unknown, ResourceResponse::Unknown) COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_0_9, ResourceResponse::HTTP_0_9); COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_1_0, ResourceResponse::HTTP_1_0); COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_1_1, ResourceResponse::HTTP_1_1); + +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeUnspecified, MediaPlayerClient::Unspecified); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeAnonymous, MediaPlayerClient::Anonymous); +COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeUseCredentials, MediaPlayerClient::UseCredentials); diff --git a/Source/WebKit/chromium/src/AssociatedURLLoader.cpp b/Source/WebKit/chromium/src/AssociatedURLLoader.cpp index f1c2aab30..086e79e7d 100644 --- a/Source/WebKit/chromium/src/AssociatedURLLoader.cpp +++ b/Source/WebKit/chromium/src/AssociatedURLLoader.cpp @@ -209,7 +209,9 @@ void AssociatedURLLoader::ClientAdapter::didReceiveResponse(unsigned long, const // Try to use the original ResourceResponse if possible. WebURLResponse validatedResponse = WrappedResourceResponse(response); HTTPResponseHeaderValidator validator(m_options.crossOriginRequestPolicy == WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl); - validatedResponse.visitHTTPHeaderFields(&validator); + if (!m_options.exposeAllResponseHeaders) + validatedResponse.visitHTTPHeaderFields(&validator); + // If there are blocked headers, copy the response so we can remove them. const HTTPHeaderSet& blockedHeaders = validator.blockedHeaders(); if (!blockedHeaders.isEmpty()) { diff --git a/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp b/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp index eb5021003..5f608a3d9 100644 --- a/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp +++ b/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp @@ -91,12 +91,16 @@ private: } // namespace -// static bool AsyncFileSystem::isAvailable() { return true; } +PassOwnPtr<AsyncFileSystem> AsyncFileSystem::create() +{ + return AsyncFileSystemChromium::create(); +} + AsyncFileSystemChromium::AsyncFileSystemChromium() : m_webFileSystem(WebKit::webKitPlatformSupport()->fileSystem()) { diff --git a/Source/WebKit/chromium/src/AudioDestinationChromium.cpp b/Source/WebKit/chromium/src/AudioDestinationChromium.cpp index 44558de87..cadb2e3a9 100644 --- a/Source/WebKit/chromium/src/AudioDestinationChromium.cpp +++ b/Source/WebKit/chromium/src/AudioDestinationChromium.cpp @@ -58,8 +58,7 @@ PassOwnPtr<AudioDestination> AudioDestination::create(AudioSourceProvider& provi } AudioDestinationChromium::AudioDestinationChromium(AudioSourceProvider& provider, float sampleRate) - : m_provider(provider) - , m_renderBus(numberOfChannels, renderBufferSize, false) + : m_renderBus(numberOfChannels, renderBufferSize, false) , m_sampleRate(sampleRate) , m_isPlaying(false) { diff --git a/Source/WebKit/chromium/src/AudioDestinationChromium.h b/Source/WebKit/chromium/src/AudioDestinationChromium.h index dfe5ebd7c..be4cc4b84 100644 --- a/Source/WebKit/chromium/src/AudioDestinationChromium.h +++ b/Source/WebKit/chromium/src/AudioDestinationChromium.h @@ -58,7 +58,6 @@ public: virtual void render(const WebKit::WebVector<float*>& audioData, size_t numberOfFrames); private: - AudioSourceProvider& m_provider; AudioBus m_renderBus; float m_sampleRate; bool m_isPlaying; diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.cpp b/Source/WebKit/chromium/src/ChromeClientImpl.cpp index 467d6389d..dd1e2104b 100644 --- a/Source/WebKit/chromium/src/ChromeClientImpl.cpp +++ b/Source/WebKit/chromium/src/ChromeClientImpl.cpp @@ -521,7 +521,6 @@ void ChromeClientImpl::invalidateContentsAndRootView(const IntRect& updateRect, void ChromeClientImpl::invalidateContentsForSlowScroll(const IntRect& updateRect, bool immediate) { - m_webView->hidePopups(); invalidateContentsAndRootView(updateRect, immediate); } @@ -536,7 +535,6 @@ void ChromeClientImpl::scroll( const IntSize& scrollDelta, const IntRect& scrollRect, const IntRect& clipRect) { - m_webView->hidePopups(); #if USE(ACCELERATED_COMPOSITING) if (!m_webView->isAcceleratedCompositingActive()) { #endif @@ -636,12 +634,10 @@ void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportArgumen if (!m_webView->settings()->viewportEnabled() || !m_webView->isFixedLayoutModeEnabled() || !m_webView->client() || !m_webView->page()) return; - bool useDefaultDeviceScaleFactor = false; ViewportArguments args; if (arguments == args) { // Default viewport arguments passed in. This is a signal to reset the viewport. args.width = ViewportArguments::ValueDesktopWidth; - useDefaultDeviceScaleFactor = true; } else args = arguments; @@ -666,10 +662,7 @@ void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportArgumen m_webView->setFixedLayoutSize(IntSize(layoutWidth, layoutHeight)); bool needInitializePageScale = !m_webView->isPageScaleFactorSet(); - if (useDefaultDeviceScaleFactor && settings->defaultDeviceScaleFactor()) - m_webView->setDeviceScaleFactor(settings->defaultDeviceScaleFactor()); - else - m_webView->setDeviceScaleFactor(computed.devicePixelRatio); + m_webView->setDeviceScaleFactor(computed.devicePixelRatio); m_webView->setPageScaleFactorLimits(computed.minimumScale, computed.maximumScale); if (needInitializePageScale) m_webView->setPageScaleFactorPreservingScrollOffset(computed.initialScale * computed.devicePixelRatio); @@ -725,8 +718,7 @@ void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileCh #else params.directory = false; #endif - params.acceptTypes = fileChooser->settings().acceptMIMETypes; - params.acceptMIMETypes = fileChooser->settings().acceptMIMETypes; // FIXME: Remove this once https://chromiumcodereview.appspot.com/10414085 lands. + params.acceptTypes = fileChooser->settings().acceptTypes(); params.selectedFiles = fileChooser->settings().selectedFiles; if (params.selectedFiles.size() > 0) params.initialValue = params.selectedFiles[0]; diff --git a/Source/WebKit/chromium/src/ContextFeaturesClientImpl.cpp b/Source/WebKit/chromium/src/ContextFeaturesClientImpl.cpp new file mode 100644 index 000000000..aada07787 --- /dev/null +++ b/Source/WebKit/chromium/src/ContextFeaturesClientImpl.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ContextFeaturesClientImpl.h" + +#include "Document.h" +#include "WebDocument.h" +#include "WebPermissionClient.h" + +namespace WebKit { + +bool ContextFeaturesClientImpl::isEnabled(WebCore::Document* document, WebCore::ContextFeatures::FeatureType type, bool defaultValue) +{ + if (!m_client) + return defaultValue; + + switch (type) { + case WebCore::ContextFeatures::ShadowDOM: + case WebCore::ContextFeatures::StyleScoped: + return m_client->allowWebComponents(WebDocument(document), defaultValue); + default: + return defaultValue; + } +} + +} // namespace WebKit diff --git a/Source/WebKit/chromium/src/ContextFeaturesClientImpl.h b/Source/WebKit/chromium/src/ContextFeaturesClientImpl.h new file mode 100644 index 000000000..ea1f9548d --- /dev/null +++ b/Source/WebKit/chromium/src/ContextFeaturesClientImpl.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ContextFeaturesClientImpl_h +#define ContextFeaturesClientImpl_h + +#include "ContextFeatures.h" + +namespace WebKit { + +class WebPermissionClient; + +class ContextFeaturesClientImpl : public WebCore::ContextFeaturesClient { +public: + ContextFeaturesClientImpl() + : m_client(0) + { } + + virtual bool isEnabled(WebCore::Document*, WebCore::ContextFeatures::FeatureType, bool defaultValue) OVERRIDE; + void setPermissionClient(WebPermissionClient* client) { m_client = client; } + +private: + WebPermissionClient* m_client; +}; + +} // namespace WebKit + +#endif // ContextFeaturesClientImpl_h diff --git a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp index d400e7c2b..a32a182a4 100644 --- a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp +++ b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp @@ -278,25 +278,27 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems( // words and attaches suggestions to these markers in the background. Therefore, when a user right-clicks // a mouse on a word, Chrome just needs to find a spelling marker on the word instread of spellchecking it. if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) { - RefPtr<Range> range = selectedFrame->selection()->toNormalizedRange(); - if (range.get()) { + VisibleSelection selection = selectedFrame->selection()->selection(); + if (selection.isCaretOrRange()) { + if (selection.isCaret()) + selection.expandUsingGranularity(WordGranularity); + RefPtr<Range> range = selection.toNormalizedRange(); Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::Grammar); - if (!markers.isEmpty()) { - Vector<String> suggestions; - for (size_t i = 0; i < markers.size(); ++i) { - if (!markers[i]->description().isEmpty()) { - Vector<String> descriptions; - markers[i]->description().split('\n', descriptions); - suggestions.append(descriptions); - } - } - data.misspelledWord = selectMisspelledWord(defaultMenu, selectedFrame); - if (!suggestions.isEmpty()) + if (markers.size() == 1) { + range->setStart(range->startContainer(), markers[0]->startOffset()); + range->setEnd(range->endContainer(), markers[0]->endOffset()); + data.misspelledWord = range->text(); + if (markers[0]->description().length()) { + Vector<String> suggestions; + markers[0]->description().split('\n', suggestions); data.dictionarySuggestions = suggestions; - else if (m_webView->spellCheckClient()) { + } else if (m_webView->spellCheckClient()) { int misspelledOffset, misspelledLength; m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions); } + selection = VisibleSelection(range.get()); + if (selectedFrame->selection()->shouldChangeSelection(selection)) + selectedFrame->selection()->setSelection(selection, WordGranularity); } } } else if (m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled()) { diff --git a/Source/WebKit/chromium/src/DeviceOrientationClientProxy.h b/Source/WebKit/chromium/src/DeviceOrientationClientProxy.h index e90d77fd9..73fd3e2a0 100644 --- a/Source/WebKit/chromium/src/DeviceOrientationClientProxy.h +++ b/Source/WebKit/chromium/src/DeviceOrientationClientProxy.h @@ -44,11 +44,11 @@ public: { } - void setController(WebCore::DeviceOrientationController*); - void startUpdating(); - void stopUpdating(); - WebCore::DeviceOrientation* lastOrientation() const; - virtual void deviceOrientationControllerDestroyed(); + virtual void setController(WebCore::DeviceOrientationController*) OVERRIDE; + virtual void startUpdating() OVERRIDE; + virtual void stopUpdating() OVERRIDE; + virtual WebCore::DeviceOrientation* lastOrientation() const OVERRIDE; + virtual void deviceOrientationControllerDestroyed() OVERRIDE; private: WebDeviceOrientationClient* m_client; diff --git a/Source/WebKit/chromium/src/EditorClientImpl.cpp b/Source/WebKit/chromium/src/EditorClientImpl.cpp index 417fe9429..b2d060f0e 100644 --- a/Source/WebKit/chromium/src/EditorClientImpl.cpp +++ b/Source/WebKit/chromium/src/EditorClientImpl.cpp @@ -170,7 +170,7 @@ void EditorClientImpl::toggleContinuousSpellChecking() bool EditorClientImpl::isGrammarCheckingEnabled() { const Frame* frame = m_webView->focusedWebCoreFrame(); - return frame && frame->settings() && frame->settings()->asynchronousSpellCheckingEnabled(); + return frame && frame->settings() && (frame->settings()->asynchronousSpellCheckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); } void EditorClientImpl::toggleGrammarChecking() @@ -703,7 +703,7 @@ void EditorClientImpl::textDidChangeInTextArea(Element*) bool EditorClientImpl::shouldEraseMarkersAfterChangeSelection(TextCheckingType type) const { const Frame* frame = m_webView->focusedWebCoreFrame(); - return !frame || !frame->settings() || !frame->settings()->asynchronousSpellCheckingEnabled(); + return !frame || !frame->settings() || (!frame->settings()->asynchronousSpellCheckingEnabled() && !frame->settings()->unifiedTextCheckerEnabled()); } void EditorClientImpl::ignoreWordInSpellDocument(const String&) @@ -766,16 +766,39 @@ String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String& return String(); } -void EditorClientImpl::checkGrammarOfString(const UChar*, int length, - WTF::Vector<GrammarDetail>&, - int* badGrammarLocation, - int* badGrammarLength) +void EditorClientImpl::checkGrammarOfString(const UChar* text, int length, WTF::Vector<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength) { - notImplemented(); if (badGrammarLocation) *badGrammarLocation = -1; if (badGrammarLength) *badGrammarLength = 0; + + if (!m_webView->spellCheckClient()) + return; + WebVector<WebTextCheckingResult> webResults; + m_webView->spellCheckClient()->checkTextOfParagraph(WebString(text, length), WebTextCheckingTypeGrammar, &webResults); + if (!webResults.size()) + return; + + // Convert a list of WebTextCheckingResults to a list of GrammarDetails. If + // the converted vector of GrammarDetails has grammar errors, we set + // badGrammarLocation and badGrammarLength to tell WebKit that the input + // text has grammar errors. + for (size_t i = 0; i < webResults.size(); ++i) { + if (webResults[i].type == WebTextCheckingTypeGrammar) { + GrammarDetail detail; + detail.location = webResults[i].location; + detail.length = webResults[i].length; + detail.userDescription = webResults[i].replacement; + details.append(detail); + } + } + if (!details.size()) + return; + if (badGrammarLocation) + *badGrammarLocation = 0; + if (badGrammarLength) + *badGrammarLength = length; } void EditorClientImpl::checkTextOfParagraph(const UChar* text, int length, diff --git a/Source/WebKit/chromium/src/Extensions3DChromium.cpp b/Source/WebKit/chromium/src/Extensions3DChromium.cpp deleted file mode 100644 index 84ad0f78a..000000000 --- a/Source/WebKit/chromium/src/Extensions3DChromium.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(WEBGL) - -#include "Extensions3DChromium.h" - -#include "GraphicsContext3D.h" -#include "GraphicsContext3DPrivate.h" - -namespace WebCore { - -Extensions3DChromium::Extensions3DChromium(GraphicsContext3DPrivate* priv) - : m_private(priv) -{ -} - -Extensions3DChromium::~Extensions3DChromium() -{ -} - -bool Extensions3DChromium::supports(const String& name) -{ - return m_private->supportsExtension(name); -} - -void Extensions3DChromium::ensureEnabled(const String& name) -{ -#ifndef NDEBUG - bool result = -#endif - m_private->ensureExtensionEnabled(name); - ASSERT(result); -} - -bool Extensions3DChromium::isEnabled(const String& name) -{ - return m_private->isExtensionEnabled(name); -} - -int Extensions3DChromium::getGraphicsResetStatusARB() -{ - return static_cast<int>(m_private->getGraphicsResetStatusARB()); -} - -void Extensions3DChromium::blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) -{ - m_private->blitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); -} - -void Extensions3DChromium::renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) -{ - m_private->renderbufferStorageMultisampleCHROMIUM(target, samples, internalformat, width, height); -} - -void Extensions3DChromium::postSubBufferCHROMIUM(int x, int y, int width, int height) -{ - m_private->postSubBufferCHROMIUM(x, y, width, height); -} - -void* Extensions3DChromium::mapBufferSubDataCHROMIUM(unsigned target, int offset, int size, unsigned access) -{ - return m_private->mapBufferSubDataCHROMIUM(target, offset, size, access); -} - -void Extensions3DChromium::unmapBufferSubDataCHROMIUM(const void* data) -{ - m_private->unmapBufferSubDataCHROMIUM(data); -} - -void* Extensions3DChromium::mapTexSubImage2DCHROMIUM(unsigned target, int level, int xoffset, int yoffset, int width, int height, unsigned format, unsigned type, unsigned access) -{ - return m_private->mapTexSubImage2DCHROMIUM(target, level, xoffset, yoffset, width, height, format, type, access); -} - -void Extensions3DChromium::unmapTexSubImage2DCHROMIUM(const void* data) -{ - m_private->unmapTexSubImage2DCHROMIUM(data); -} - -void Extensions3DChromium::setVisibilityCHROMIUM(bool visibility) -{ - m_private->setVisibilityCHROMIUM(visibility); -} - -void Extensions3DChromium::discardFramebufferEXT(GC3Denum target, GC3Dsizei numAttachments, const GC3Denum* attachments) -{ - m_private->discardFramebufferEXT(target, numAttachments, attachments); -} - -void Extensions3DChromium::ensureFramebufferCHROMIUM() -{ - m_private->ensureFramebufferCHROMIUM(); -} - -void Extensions3DChromium::setGpuMemoryAllocationChangedCallbackCHROMIUM(PassOwnPtr<GpuMemoryAllocationChangedCallbackCHROMIUM> callback) -{ - m_private->setGpuMemoryAllocationChangedCallbackCHROMIUM(callback); -} - -Platform3DObject Extensions3DChromium::createVertexArrayOES() -{ - return 0; -} - -void Extensions3DChromium::deleteVertexArrayOES(Platform3DObject) -{ -} - -GC3Dboolean Extensions3DChromium::isVertexArrayOES(Platform3DObject) -{ - return 0; -} - -void Extensions3DChromium::bindVertexArrayOES(Platform3DObject) -{ -} - -String Extensions3DChromium::getTranslatedShaderSourceANGLE(Platform3DObject shader) -{ - return m_private->getTranslatedShaderSourceANGLE(shader); -} - -void Extensions3DChromium::setSwapBuffersCompleteCallbackCHROMIUM(PassOwnPtr<SwapBuffersCompleteCallbackCHROMIUM> callback) -{ - m_private->setSwapBuffersCompleteCallbackCHROMIUM(callback); -} - -void Extensions3DChromium::rateLimitOffscreenContextCHROMIUM() -{ - m_private->rateLimitOffscreenContextCHROMIUM(); -} - -void Extensions3DChromium::paintFramebufferToCanvas(int framebuffer, int width, int height, bool premultiplyAlpha, ImageBuffer* imageBuffer) -{ - m_private->paintFramebufferToCanvas(framebuffer, width, height, premultiplyAlpha, imageBuffer); -} - -void Extensions3DChromium::texImageIOSurface2DCHROMIUM(unsigned target, int width, int height, uint32_t ioSurfaceId, unsigned plane) -{ - m_private->texImageIOSurface2DCHROMIUM(target, width, height, ioSurfaceId, plane); -} - -void Extensions3DChromium::texStorage2DEXT(unsigned int target, int levels, unsigned int internalFormat, int width, int height) -{ - m_private->texStorage2DEXT(target, levels, internalFormat, width, height); -} - -Platform3DObject Extensions3DChromium::createQueryEXT() -{ - return m_private->createQueryEXT(); -} - -void Extensions3DChromium::deleteQueryEXT(Platform3DObject query) -{ - m_private->deleteQueryEXT(query); -} - -GC3Dboolean Extensions3DChromium::isQueryEXT(Platform3DObject query) -{ - return m_private->isQueryEXT(query); -} - -void Extensions3DChromium::beginQueryEXT(GC3Denum target, Platform3DObject query) -{ - m_private->beginQueryEXT(target, query); -} - -void Extensions3DChromium::endQueryEXT(GC3Denum target) -{ - m_private->endQueryEXT(target); -} - -void Extensions3DChromium::getQueryivEXT(GC3Denum target, GC3Denum pname, GC3Dint* params) -{ - m_private->getQueryivEXT(target, pname, params); -} - -void Extensions3DChromium::getQueryObjectuivEXT(Platform3DObject query, GC3Denum pname, GC3Duint* params) -{ - m_private->getQueryObjectuivEXT(query, pname, params); -} - -} // namespace WebCore - -#endif // ENABLE(WEBGL) diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp index de3f22789..b67798e74 100644 --- a/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp +++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp @@ -239,24 +239,6 @@ bool FrameLoaderClientImpl::allowRunningInsecureContent(bool enabledPerSettings, return enabledPerSettings; } -bool FrameLoaderClientImpl::allowShadowDOM(bool enabledAsRuntimeFeature) -{ - WebViewImpl* webview = m_webFrame->viewImpl(); - if (webview && webview->permissionClient()) - return webview->permissionClient()->allowWebComponents(m_webFrame, enabledAsRuntimeFeature); - - return enabledAsRuntimeFeature; -} - -bool FrameLoaderClientImpl::allowStyleScoped(bool enabledAsRuntimeFeature) -{ - WebViewImpl* webview = m_webFrame->viewImpl(); - if (webview && webview->permissionClient()) - return webview->permissionClient()->allowWebComponents(m_webFrame, enabledAsRuntimeFeature); - - return enabledAsRuntimeFeature; -} - void FrameLoaderClientImpl::didNotAllowScript() { WebViewImpl* webview = m_webFrame->viewImpl(); @@ -1401,8 +1383,8 @@ void FrameLoaderClientImpl::setTitle(const StringWithDirection& title, const KUR String FrameLoaderClientImpl::userAgent(const KURL& url) { - WebString override; - if (m_webFrame->client()->userAgent(WebURL(url), &override)) + WebString override = m_webFrame->client()->userAgentOverride(m_webFrame, WebURL(url)); + if (!override.isEmpty()) return override; return WebKit::Platform::current()->userAgent(url); diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.h b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h index 236a01b65..ecb20a2fb 100644 --- a/Source/WebKit/chromium/src/FrameLoaderClientImpl.h +++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h @@ -199,8 +199,6 @@ public: virtual bool allowImage(bool enabledPerSettings, const WebCore::KURL& imageURL); virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, WebCore::SecurityOrigin*, const WebCore::KURL&); virtual bool allowRunningInsecureContent(bool enabledPerSettings, WebCore::SecurityOrigin*, const WebCore::KURL&); - virtual bool allowShadowDOM(bool enabledAsRuntimeFeature) OVERRIDE; - virtual bool allowStyleScoped(bool enabledAsRuntimeFeature) OVERRIDE; virtual void didNotAllowScript(); virtual void didNotAllowPlugins(); diff --git a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp deleted file mode 100644 index 3ef8cf8a2..000000000 --- a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp +++ /dev/null @@ -1,1353 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(WEBGL) - -#include "GraphicsContext3D.h" - -#include "DrawingBuffer.h" -#include "Extensions3DChromium.h" -#include "GrContext.h" -#include "GrGLInterface.h" -#include "GraphicsContext3DPrivate.h" -#include "ImageBuffer.h" -#include "ImageData.h" -#include <public/Platform.h> -#include <public/WebGraphicsContext3D.h> - -#include <stdio.h> -#include <wtf/FastMalloc.h> -#include <wtf/text/CString.h> -#include <wtf/text/StringHash.h> - - -namespace { - -// The limit of the number of textures we hold in the GrContext's bitmap->texture cache. -const int maxGaneshTextureCacheCount = 512; -// The limit of the bytes allocated toward textures in the GrContext's bitmap->texture cache. -const size_t maxGaneshTextureCacheBytes = 96 * 1024 * 1024; - -} - -// There are two levels of delegation in this file: -// -// 1. GraphicsContext3D delegates to GraphicsContext3DPrivate. This is done -// so that we have some place to store data members common among -// implementations; GraphicsContext3D only provides us the m_private -// pointer. We always delegate to the GraphicsContext3DPrivate. While we -// could sidestep it and go directly to the WebGraphicsContext3D in some -// cases, it is better for consistency to always delegate through it. -// -// 2. GraphicsContext3DPrivate delegates to an implementation of -// WebGraphicsContext3D. This is done so we have a place to inject an -// implementation which remotes the OpenGL calls across processes. - -namespace WebCore { - -//---------------------------------------------------------------------- -// GraphicsContext3DPrivate - -GraphicsContext3DPrivate::GraphicsContext3DPrivate(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, bool preserveDrawingBuffer) - : m_impl(webContext) - , m_initializedAvailableExtensions(false) - , m_layerComposited(false) - , m_preserveDrawingBuffer(preserveDrawingBuffer) - , m_resourceSafety(ResourceSafetyUnknown) - , m_grContext(0) -{ -} - -GraphicsContext3DPrivate::~GraphicsContext3DPrivate() -{ - if (m_grContext) { - m_grContext->contextDestroyed(); - GrSafeUnref(m_grContext); - } -} - -PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, GraphicsContext3D::RenderStyle renderStyle, bool preserveDrawingBuffer) -{ - bool renderDirectlyToHostWindow = renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow; - - RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0, renderDirectlyToHostWindow)); - - OwnPtr<GraphicsContext3DPrivate> priv = adoptPtr(new GraphicsContext3DPrivate(webContext, preserveDrawingBuffer)); - context->m_private = priv.release(); - return context.release(); -} - -namespace { - -void getDrawingParameters(DrawingBuffer* drawingBuffer, WebKit::WebGraphicsContext3D* graphicsContext3D, - Platform3DObject* frameBufferId, int* width, int* height) -{ - if (drawingBuffer) { - *frameBufferId = drawingBuffer->framebuffer(); - *width = drawingBuffer->size().width(); - *height = drawingBuffer->size().height(); - } else { - *frameBufferId = 0; - *width = graphicsContext3D->width(); - *height = graphicsContext3D->height(); - } -} - -} // anonymous namespace - -WebKit::WebGraphicsContext3D* GraphicsContext3DPrivate::extractWebGraphicsContext3D(GraphicsContext3D* context) -{ - if (!context) - return 0; - return context->m_private->m_impl.get(); -} - -PlatformGraphicsContext3D GraphicsContext3DPrivate::platformGraphicsContext3D() const -{ - return m_impl.get(); -} - -Platform3DObject GraphicsContext3DPrivate::platformTexture() const -{ - return m_impl->getPlatformTextureId(); -} - -class GrMemoryAllocationChangedCallback : public Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM { -public: - GrMemoryAllocationChangedCallback(GraphicsContext3DPrivate* context) - : m_context(context) - { - } - - virtual void onGpuMemoryAllocationChanged(Extensions3DChromium::GpuMemoryAllocationCHROMIUM allocation) - { - GrContext* context = m_context->grContext(); - if (!context) - return; - - if (!allocation.gpuResourceSizeInBytes) { - context->freeGpuResources(); - context->setTextureCacheLimits(0, 0); - } else - context->setTextureCacheLimits(maxGaneshTextureCacheCount, maxGaneshTextureCacheBytes); - } - -private: - GraphicsContext3DPrivate* m_context; -}; - -GrContext* GraphicsContext3DPrivate::grContext() -{ - if (!m_grContext) { - SkAutoTUnref<GrGLInterface> interface(m_impl->createGrGLInterface()); - m_grContext = GrContext::Create(kOpenGL_Shaders_GrEngine, reinterpret_cast<GrPlatform3DContext>(interface.get())); - if (m_grContext) { - m_grContext->setTextureCacheLimits(maxGaneshTextureCacheCount, maxGaneshTextureCacheBytes); - Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(getExtensions()); - if (extensions3DChromium->supports("GL_CHROMIUM_gpu_memory_manager")) - extensions3DChromium->setGpuMemoryAllocationChangedCallbackCHROMIUM(adoptPtr(new GrMemoryAllocationChangedCallback(this))); - } - } - return m_grContext; -} - -void GraphicsContext3DPrivate::prepareTexture() -{ - m_impl->prepareTexture(); -} - -void GraphicsContext3DPrivate::markContextChanged() -{ - m_layerComposited = false; -} - -void GraphicsContext3DPrivate::markLayerComposited() -{ - m_layerComposited = true; -} - -bool GraphicsContext3DPrivate::layerComposited() const -{ - return m_layerComposited; -} - -void GraphicsContext3DPrivate::paintFramebufferToCanvas(int framebuffer, int width, int height, bool premultiplyAlpha, ImageBuffer* imageBuffer) -{ - unsigned char* pixels = 0; - size_t bufferSize = 4 * width * height; - - const SkBitmap* canvasBitmap = imageBuffer->context()->platformContext()->bitmap(); - const SkBitmap* readbackBitmap = 0; - ASSERT(canvasBitmap->config() == SkBitmap::kARGB_8888_Config); - if (canvasBitmap->width() == width && canvasBitmap->height() == height) { - // This is the fastest and most common case. We read back - // directly into the canvas's backing store. - readbackBitmap = canvasBitmap; - m_resizingBitmap.reset(); - } else { - // We need to allocate a temporary bitmap for reading back the - // pixel data. We will then use Skia to rescale this bitmap to - // the size of the canvas's backing store. - if (m_resizingBitmap.width() != width || m_resizingBitmap.height() != height) { - m_resizingBitmap.setConfig(SkBitmap::kARGB_8888_Config, - width, - height); - if (!m_resizingBitmap.allocPixels()) - return; - } - readbackBitmap = &m_resizingBitmap; - } - - // Read back the frame buffer. - SkAutoLockPixels bitmapLock(*readbackBitmap); - pixels = static_cast<unsigned char*>(readbackBitmap->getPixels()); - - m_impl->readBackFramebuffer(pixels, 4 * width * height, framebuffer, width, height); - - if (premultiplyAlpha) { - for (size_t i = 0; i < bufferSize; i += 4) { - pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255); - pixels[i + 1] = std::min(255, pixels[i + 1] * pixels[i + 3] / 255); - pixels[i + 2] = std::min(255, pixels[i + 2] * pixels[i + 3] / 255); - } - } - - readbackBitmap->notifyPixelsChanged(); - if (m_resizingBitmap.readyToDraw()) { - // We need to draw the resizing bitmap into the canvas's backing store. - SkCanvas canvas(*canvasBitmap); - SkRect dst; - dst.set(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(canvasBitmap->width()), SkIntToScalar(canvasBitmap->height())); - canvas.drawBitmapRect(m_resizingBitmap, 0, dst); - } -} - -void GraphicsContext3DPrivate::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer, DrawingBuffer* drawingBuffer) -{ - Platform3DObject framebufferId; - int width, height; - getDrawingParameters(drawingBuffer, m_impl.get(), &framebufferId, &width, &height); - paintFramebufferToCanvas(framebufferId, width, height, !m_impl->getContextAttributes().premultipliedAlpha, imageBuffer); -} - -bool GraphicsContext3DPrivate::paintCompositedResultsToCanvas(ImageBuffer*) -{ - return false; -} - -PassRefPtr<ImageData> GraphicsContext3DPrivate::paintRenderingResultsToImageData(DrawingBuffer* drawingBuffer) -{ - if (m_impl->getContextAttributes().premultipliedAlpha) - return 0; - - Platform3DObject framebufferId; - int width, height; - getDrawingParameters(drawingBuffer, m_impl.get(), &framebufferId, &width, &height); - - RefPtr<ImageData> imageData = ImageData::create(IntSize(width, height)); - unsigned char* pixels = imageData->data()->data(); - size_t bufferSize = 4 * width * height; - - m_impl->readBackFramebuffer(pixels, bufferSize, framebufferId, width, height); - - for (size_t i = 0; i < bufferSize; i += 4) - std::swap(pixels[i], pixels[i + 2]); - - return imageData.release(); -} - -void GraphicsContext3DPrivate::reshape(int width, int height) -{ - if (width == m_impl->width() && height == m_impl->height()) - return; - - m_impl->reshape(width, height); -} - -IntSize GraphicsContext3DPrivate::getInternalFramebufferSize() const -{ - return IntSize(m_impl->width(), m_impl->height()); -} - -bool GraphicsContext3DPrivate::isContextLost() -{ - return m_impl->isContextLost(); -} - -// Macros to assist in delegating from GraphicsContext3DPrivate to -// WebGraphicsContext3D. - -#define DELEGATE_TO_IMPL(name) \ -void GraphicsContext3DPrivate::name() \ -{ \ - m_impl->name(); \ -} - -#define DELEGATE_TO_IMPL_R(name, rt) \ -rt GraphicsContext3DPrivate::name() \ -{ \ - return m_impl->name(); \ -} - -#define DELEGATE_TO_IMPL_1(name, t1) \ -void GraphicsContext3DPrivate::name(t1 a1) \ -{ \ - m_impl->name(a1); \ -} - -#define DELEGATE_TO_IMPL_1R(name, t1, rt) \ -rt GraphicsContext3DPrivate::name(t1 a1) \ -{ \ - return m_impl->name(a1); \ -} - -#define DELEGATE_TO_IMPL_2(name, t1, t2) \ -void GraphicsContext3DPrivate::name(t1 a1, t2 a2) \ -{ \ - m_impl->name(a1, a2); \ -} - -#define DELEGATE_TO_IMPL_2R(name, t1, t2, rt) \ -rt GraphicsContext3DPrivate::name(t1 a1, t2 a2) \ -{ \ - return m_impl->name(a1, a2); \ -} - -#define DELEGATE_TO_IMPL_3(name, t1, t2, t3) \ -void GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3) \ -{ \ - m_impl->name(a1, a2, a3); \ -} - -#define DELEGATE_TO_IMPL_3R(name, t1, t2, t3, rt) \ -rt GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3) \ -{ \ - return m_impl->name(a1, a2, a3); \ -} - -#define DELEGATE_TO_IMPL_4(name, t1, t2, t3, t4) \ -void GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4) \ -{ \ - m_impl->name(a1, a2, a3, a4); \ -} - -#define DELEGATE_TO_IMPL_4R(name, t1, t2, t3, t4, rt) \ -rt GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4) \ -{ \ - return m_impl->name(a1, a2, a3, a4); \ -} - -#define DELEGATE_TO_IMPL_5(name, t1, t2, t3, t4, t5) \ -void GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) \ -{ \ - m_impl->name(a1, a2, a3, a4, a5); \ -} - -#define DELEGATE_TO_IMPL_5R(name, t1, t2, t3, t4, t5, rt) \ -rt GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) \ -{ \ - return m_impl->name(a1, a2, a3, a4, a5); \ -} - -#define DELEGATE_TO_IMPL_6(name, t1, t2, t3, t4, t5, t6) \ -void GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \ -{ \ - m_impl->name(a1, a2, a3, a4, a5, a6); \ -} - -#define DELEGATE_TO_IMPL_6R(name, t1, t2, t3, t4, t5, t6, rt) \ -rt GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \ -{ \ - return m_impl->name(a1, a2, a3, a4, a5, a6); \ -} - -#define DELEGATE_TO_IMPL_7(name, t1, t2, t3, t4, t5, t6, t7) \ -void GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \ -{ \ - m_impl->name(a1, a2, a3, a4, a5, a6, a7); \ -} - -#define DELEGATE_TO_IMPL_7R(name, t1, t2, t3, t4, t5, t6, t7, rt) \ -rt GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \ -{ \ - return m_impl->name(a1, a2, a3, a4, a5, a6, a7); \ -} - -#define DELEGATE_TO_IMPL_8(name, t1, t2, t3, t4, t5, t6, t7, t8) \ -void GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) \ -{ \ - m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8); \ -} - -#define DELEGATE_TO_IMPL_9(name, t1, t2, t3, t4, t5, t6, t7, t8, t9) \ -void GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) \ -{ \ - m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \ -} - -#define DELEGATE_TO_IMPL_9R(name, t1, t2, t3, t4, t5, t6, t7, t8, t9, rt) \ -rt GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) \ -{ \ - return m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \ -} - -#define DELEGATE_TO_IMPL_10(name, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) \ -void GraphicsContext3DPrivate::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9, t10 a10) \ -{ \ - m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); \ -} - -DELEGATE_TO_IMPL_R(makeContextCurrent, bool) - -bool GraphicsContext3DPrivate::isGLES2Compliant() const -{ - return m_impl->isGLES2Compliant(); -} - -DELEGATE_TO_IMPL_1(activeTexture, GC3Denum) -DELEGATE_TO_IMPL_2(attachShader, Platform3DObject, Platform3DObject) - -void GraphicsContext3DPrivate::bindAttribLocation(Platform3DObject program, GC3Duint index, const String& name) -{ - m_impl->bindAttribLocation(program, index, name.utf8().data()); -} - -DELEGATE_TO_IMPL_2(bindBuffer, GC3Denum, Platform3DObject) -DELEGATE_TO_IMPL_2(bindFramebuffer, GC3Denum, Platform3DObject) -DELEGATE_TO_IMPL_2(bindRenderbuffer, GC3Denum, Platform3DObject) -DELEGATE_TO_IMPL_2(bindTexture, GC3Denum, Platform3DObject) -DELEGATE_TO_IMPL_4(blendColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dclampf) -DELEGATE_TO_IMPL_1(blendEquation, GC3Denum) -DELEGATE_TO_IMPL_2(blendEquationSeparate, GC3Denum, GC3Denum) -DELEGATE_TO_IMPL_2(blendFunc, GC3Denum, GC3Denum) -DELEGATE_TO_IMPL_4(blendFuncSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Denum) - -void GraphicsContext3DPrivate::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage) -{ - m_impl->bufferData(target, size, 0, usage); -} - -void GraphicsContext3DPrivate::bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage) -{ - m_impl->bufferData(target, size, data, usage); -} - -void GraphicsContext3DPrivate::bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data) -{ - m_impl->bufferSubData(target, offset, size, data); -} - -DELEGATE_TO_IMPL_1R(checkFramebufferStatus, GC3Denum, GC3Denum) -DELEGATE_TO_IMPL_1(clear, GC3Dbitfield) -DELEGATE_TO_IMPL_4(clearColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dclampf) -DELEGATE_TO_IMPL_1(clearDepth, GC3Dclampf) -DELEGATE_TO_IMPL_1(clearStencil, GC3Dint) -DELEGATE_TO_IMPL_4(colorMask, GC3Dboolean, GC3Dboolean, GC3Dboolean, GC3Dboolean) -DELEGATE_TO_IMPL_1(compileShader, Platform3DObject) - -DELEGATE_TO_IMPL_8(compressedTexImage2D, GC3Denum, GC3Dint, GC3Denum, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, const void*) -DELEGATE_TO_IMPL_9(compressedTexSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Denum, GC3Dsizei, const void*) -DELEGATE_TO_IMPL_8(copyTexImage2D, GC3Denum, GC3Dint, GC3Denum, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Dint) -DELEGATE_TO_IMPL_8(copyTexSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei) -DELEGATE_TO_IMPL_1(cullFace, GC3Denum) -DELEGATE_TO_IMPL_1(depthFunc, GC3Denum) -DELEGATE_TO_IMPL_1(depthMask, GC3Dboolean) -DELEGATE_TO_IMPL_2(depthRange, GC3Dclampf, GC3Dclampf) -DELEGATE_TO_IMPL_2(detachShader, Platform3DObject, Platform3DObject) -DELEGATE_TO_IMPL_1(disable, GC3Denum) -DELEGATE_TO_IMPL_1(disableVertexAttribArray, GC3Duint) -DELEGATE_TO_IMPL_3(drawArrays, GC3Denum, GC3Dint, GC3Dsizei) -DELEGATE_TO_IMPL_4(drawElements, GC3Denum, GC3Dsizei, GC3Denum, GC3Dsizeiptr) - -DELEGATE_TO_IMPL_1(enable, GC3Denum) -DELEGATE_TO_IMPL_1(enableVertexAttribArray, GC3Duint) -DELEGATE_TO_IMPL(finish) -DELEGATE_TO_IMPL(flush) -DELEGATE_TO_IMPL_4(framebufferRenderbuffer, GC3Denum, GC3Denum, GC3Denum, Platform3DObject) -DELEGATE_TO_IMPL_5(framebufferTexture2D, GC3Denum, GC3Denum, GC3Denum, Platform3DObject, GC3Dint) -DELEGATE_TO_IMPL_1(frontFace, GC3Denum) -DELEGATE_TO_IMPL_1(generateMipmap, GC3Denum) - -bool GraphicsContext3DPrivate::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo& info) -{ - WebKit::WebGraphicsContext3D::ActiveInfo webInfo; - if (!m_impl->getActiveAttrib(program, index, webInfo)) - return false; - info.name = webInfo.name; - info.type = webInfo.type; - info.size = webInfo.size; - return true; -} - -bool GraphicsContext3DPrivate::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info) -{ - WebKit::WebGraphicsContext3D::ActiveInfo webInfo; - if (!m_impl->getActiveUniform(program, index, webInfo)) - return false; - info.name = webInfo.name; - info.type = webInfo.type; - info.size = webInfo.size; - return true; -} - -DELEGATE_TO_IMPL_4(getAttachedShaders, Platform3DObject, GC3Dsizei, GC3Dsizei*, Platform3DObject*) - -GC3Dint GraphicsContext3DPrivate::getAttribLocation(Platform3DObject program, const String& name) -{ - return m_impl->getAttribLocation(program, name.utf8().data()); -} - -DELEGATE_TO_IMPL_2(getBooleanv, GC3Denum, GC3Dboolean*) - -DELEGATE_TO_IMPL_3(getBufferParameteriv, GC3Denum, GC3Denum, GC3Dint*) - -GraphicsContext3D::Attributes GraphicsContext3DPrivate::getContextAttributes() -{ - WebKit::WebGraphicsContext3D::Attributes webAttributes = m_impl->getContextAttributes(); - GraphicsContext3D::Attributes attributes; - attributes.alpha = webAttributes.alpha; - attributes.depth = webAttributes.depth; - attributes.stencil = webAttributes.stencil; - attributes.antialias = webAttributes.antialias; - attributes.premultipliedAlpha = webAttributes.premultipliedAlpha; - attributes.preserveDrawingBuffer = m_preserveDrawingBuffer; - attributes.preferDiscreteGPU = webAttributes.preferDiscreteGPU; - return attributes; -} - -DELEGATE_TO_IMPL_R(getError, GC3Denum) - -DELEGATE_TO_IMPL_2(getFloatv, GC3Denum, GC3Dfloat*) - -DELEGATE_TO_IMPL_4(getFramebufferAttachmentParameteriv, GC3Denum, GC3Denum, GC3Denum, GC3Dint*) - -DELEGATE_TO_IMPL_2(getIntegerv, GC3Denum, GC3Dint*) - -DELEGATE_TO_IMPL_3(getProgramiv, Platform3DObject, GC3Denum, GC3Dint*) - -String GraphicsContext3DPrivate::getProgramInfoLog(Platform3DObject program) -{ - return m_impl->getProgramInfoLog(program); -} - -DELEGATE_TO_IMPL_3(getRenderbufferParameteriv, GC3Denum, GC3Denum, GC3Dint*) - -DELEGATE_TO_IMPL_3(getShaderiv, Platform3DObject, GC3Denum, GC3Dint*) - -String GraphicsContext3DPrivate::getShaderInfoLog(Platform3DObject shader) -{ - return m_impl->getShaderInfoLog(shader); -} - -DELEGATE_TO_IMPL_4(getShaderPrecisionFormat, GC3Denum, GC3Denum, GC3Dint*, GC3Dint*) - -String GraphicsContext3DPrivate::getShaderSource(Platform3DObject shader) -{ - return m_impl->getShaderSource(shader); -} - -String GraphicsContext3DPrivate::getString(GC3Denum name) -{ - return m_impl->getString(name); -} - -DELEGATE_TO_IMPL_3(getTexParameterfv, GC3Denum, GC3Denum, GC3Dfloat*) -DELEGATE_TO_IMPL_3(getTexParameteriv, GC3Denum, GC3Denum, GC3Dint*) - -DELEGATE_TO_IMPL_3(getUniformfv, Platform3DObject, GC3Dint, GC3Dfloat*) -DELEGATE_TO_IMPL_3(getUniformiv, Platform3DObject, GC3Dint, GC3Dint*) - -GC3Dint GraphicsContext3DPrivate::getUniformLocation(Platform3DObject program, const String& name) -{ - return m_impl->getUniformLocation(program, name.utf8().data()); -} - -DELEGATE_TO_IMPL_3(getVertexAttribfv, GC3Duint, GC3Denum, GC3Dfloat*) -DELEGATE_TO_IMPL_3(getVertexAttribiv, GC3Duint, GC3Denum, GC3Dint*) - -DELEGATE_TO_IMPL_2R(getVertexAttribOffset, GC3Duint, GC3Denum, GC3Dsizeiptr) - -DELEGATE_TO_IMPL_2(hint, GC3Denum, GC3Denum) -DELEGATE_TO_IMPL_1R(isBuffer, Platform3DObject, GC3Dboolean) -DELEGATE_TO_IMPL_1R(isEnabled, GC3Denum, GC3Dboolean) -DELEGATE_TO_IMPL_1R(isFramebuffer, Platform3DObject, GC3Dboolean) -DELEGATE_TO_IMPL_1R(isProgram, Platform3DObject, GC3Dboolean) -DELEGATE_TO_IMPL_1R(isRenderbuffer, Platform3DObject, GC3Dboolean) -DELEGATE_TO_IMPL_1R(isShader, Platform3DObject, GC3Dboolean) -DELEGATE_TO_IMPL_1R(isTexture, Platform3DObject, GC3Dboolean) -DELEGATE_TO_IMPL_1(lineWidth, GC3Dfloat) -DELEGATE_TO_IMPL_1(linkProgram, Platform3DObject) -DELEGATE_TO_IMPL_2(pixelStorei, GC3Denum, GC3Dint) -DELEGATE_TO_IMPL_2(polygonOffset, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_IMPL_7(readPixels, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Denum, GC3Denum, void*) -DELEGATE_TO_IMPL(releaseShaderCompiler) -DELEGATE_TO_IMPL_4(renderbufferStorage, GC3Denum, GC3Denum, GC3Dsizei, GC3Dsizei) -DELEGATE_TO_IMPL_2(sampleCoverage, GC3Dclampf, GC3Dboolean) -DELEGATE_TO_IMPL_4(scissor, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei) - -void GraphicsContext3DPrivate::shaderSource(Platform3DObject shader, const String& string) -{ - m_impl->shaderSource(shader, string.utf8().data()); -} - -DELEGATE_TO_IMPL_3(stencilFunc, GC3Denum, GC3Dint, GC3Duint) -DELEGATE_TO_IMPL_4(stencilFuncSeparate, GC3Denum, GC3Denum, GC3Dint, GC3Duint) -DELEGATE_TO_IMPL_1(stencilMask, GC3Duint) -DELEGATE_TO_IMPL_2(stencilMaskSeparate, GC3Denum, GC3Duint) -DELEGATE_TO_IMPL_3(stencilOp, GC3Denum, GC3Denum, GC3Denum) -DELEGATE_TO_IMPL_4(stencilOpSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Denum) - -bool GraphicsContext3DPrivate::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) -{ - m_impl->texImage2D(target, level, internalformat, width, height, border, format, type, pixels); - return true; -} - -DELEGATE_TO_IMPL_3(texParameterf, GC3Denum, GC3Denum, GC3Dfloat) -DELEGATE_TO_IMPL_3(texParameteri, GC3Denum, GC3Denum, GC3Dint) - -void GraphicsContext3DPrivate::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels) -{ - m_impl->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); -} - -DELEGATE_TO_IMPL_2(uniform1f, GC3Dint, GC3Dfloat) - -void GraphicsContext3DPrivate::uniform1fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* v) -{ - m_impl->uniform1fv(location, size, v); -} - -DELEGATE_TO_IMPL_2(uniform1i, GC3Dint, GC3Dint) - -void GraphicsContext3DPrivate::uniform1iv(GC3Dint location, GC3Dsizei size, GC3Dint* v) -{ - m_impl->uniform1iv(location, size, v); -} - -DELEGATE_TO_IMPL_3(uniform2f, GC3Dint, GC3Dfloat, GC3Dfloat) - -void GraphicsContext3DPrivate::uniform2fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* v) -{ - m_impl->uniform2fv(location, size, v); -} - -DELEGATE_TO_IMPL_3(uniform2i, GC3Dint, GC3Dint, GC3Dint) - -void GraphicsContext3DPrivate::uniform2iv(GC3Dint location, GC3Dsizei size, GC3Dint* v) -{ - m_impl->uniform2iv(location, size, v); -} - -DELEGATE_TO_IMPL_4(uniform3f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat) - -void GraphicsContext3DPrivate::uniform3fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* v) -{ - m_impl->uniform3fv(location, size, v); -} - -DELEGATE_TO_IMPL_4(uniform3i, GC3Dint, GC3Dint, GC3Dint, GC3Dint) - -void GraphicsContext3DPrivate::uniform3iv(GC3Dint location, GC3Dsizei size, GC3Dint* v) -{ - m_impl->uniform3iv(location, size, v); -} - -DELEGATE_TO_IMPL_5(uniform4f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat) - -void GraphicsContext3DPrivate::uniform4fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* v) -{ - m_impl->uniform4fv(location, size, v); -} - -DELEGATE_TO_IMPL_5(uniform4i, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint) - -void GraphicsContext3DPrivate::uniform4iv(GC3Dint location, GC3Dsizei size, GC3Dint* v) -{ - m_impl->uniform4iv(location, size, v); -} - -void GraphicsContext3DPrivate::uniformMatrix2fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value) -{ - m_impl->uniformMatrix2fv(location, size, transpose, value); -} - -void GraphicsContext3DPrivate::uniformMatrix3fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value) -{ - m_impl->uniformMatrix3fv(location, size, transpose, value); -} - -void GraphicsContext3DPrivate::uniformMatrix4fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value) -{ - m_impl->uniformMatrix4fv(location, size, transpose, value); -} - -DELEGATE_TO_IMPL_1(useProgram, Platform3DObject) -DELEGATE_TO_IMPL_1(validateProgram, Platform3DObject) - -DELEGATE_TO_IMPL_2(vertexAttrib1f, GC3Duint, GC3Dfloat) -DELEGATE_TO_IMPL_2(vertexAttrib1fv, GC3Duint, GC3Dfloat*) -DELEGATE_TO_IMPL_3(vertexAttrib2f, GC3Duint, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_IMPL_2(vertexAttrib2fv, GC3Duint, GC3Dfloat*) -DELEGATE_TO_IMPL_4(vertexAttrib3f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_IMPL_2(vertexAttrib3fv, GC3Duint, GC3Dfloat*) -DELEGATE_TO_IMPL_5(vertexAttrib4f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_IMPL_2(vertexAttrib4fv, GC3Duint, GC3Dfloat*) -DELEGATE_TO_IMPL_6(vertexAttribPointer, GC3Duint, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dsizeiptr) - -DELEGATE_TO_IMPL_4(viewport, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei) - -DELEGATE_TO_IMPL_R(createBuffer, Platform3DObject) -DELEGATE_TO_IMPL_R(createFramebuffer, Platform3DObject) -DELEGATE_TO_IMPL_R(createProgram, Platform3DObject) -DELEGATE_TO_IMPL_R(createRenderbuffer, Platform3DObject) -DELEGATE_TO_IMPL_1R(createShader, GC3Denum, Platform3DObject) -DELEGATE_TO_IMPL_R(createTexture, Platform3DObject) - -DELEGATE_TO_IMPL_1(deleteBuffer, Platform3DObject) -DELEGATE_TO_IMPL_1(deleteFramebuffer, Platform3DObject) -DELEGATE_TO_IMPL_1(deleteProgram, Platform3DObject) -DELEGATE_TO_IMPL_1(deleteRenderbuffer, Platform3DObject) -DELEGATE_TO_IMPL_1(deleteShader, Platform3DObject) -DELEGATE_TO_IMPL_1(deleteTexture, Platform3DObject) - -DELEGATE_TO_IMPL_1(synthesizeGLError, GC3Denum) - -Extensions3D* GraphicsContext3DPrivate::getExtensions() -{ - if (!m_extensions) - m_extensions = adoptPtr(new Extensions3DChromium(this)); - return m_extensions.get(); -} - -bool GraphicsContext3DPrivate::isResourceSafe() -{ - if (m_resourceSafety == ResourceSafetyUnknown) - m_resourceSafety = getExtensions()->isEnabled("GL_CHROMIUM_resource_safe") ? ResourceSafe : ResourceUnsafe; - return m_resourceSafety == ResourceSafe; -} - -namespace { - -void splitStringHelper(const String& str, HashSet<String>& set) -{ - Vector<String> substrings; - str.split(" ", substrings); - for (size_t i = 0; i < substrings.size(); ++i) - set.add(substrings[i]); -} - -String mapExtensionName(const String& name) -{ - if (name == "GL_ANGLE_framebuffer_blit" - || name == "GL_ANGLE_framebuffer_multisample") - return "GL_CHROMIUM_framebuffer_multisample"; - return name; -} - -} // anonymous namespace - -void GraphicsContext3DPrivate::initializeExtensions() -{ - if (m_initializedAvailableExtensions) - return; - - m_initializedAvailableExtensions = true; - bool success = makeContextCurrent(); - ASSERT(success); - if (!success) - return; - - String extensionsString = getString(GraphicsContext3D::EXTENSIONS); - splitStringHelper(extensionsString, m_enabledExtensions); - - String requestableExtensionsString = m_impl->getRequestableExtensionsCHROMIUM(); - splitStringHelper(requestableExtensionsString, m_requestableExtensions); -} - - -bool GraphicsContext3DPrivate::supportsExtension(const String& name) -{ - initializeExtensions(); - String mappedName = mapExtensionName(name); - return m_enabledExtensions.contains(mappedName) || m_requestableExtensions.contains(mappedName); -} - -bool GraphicsContext3DPrivate::ensureExtensionEnabled(const String& name) -{ - initializeExtensions(); - - String mappedName = mapExtensionName(name); - if (m_enabledExtensions.contains(mappedName)) - return true; - - if (m_requestableExtensions.contains(mappedName)) { - m_impl->requestExtensionCHROMIUM(mappedName.ascii().data()); - m_enabledExtensions.clear(); - m_requestableExtensions.clear(); - m_initializedAvailableExtensions = false; - } - - initializeExtensions(); - return m_enabledExtensions.contains(mappedName); -} - -bool GraphicsContext3DPrivate::isExtensionEnabled(const String& name) -{ - initializeExtensions(); - String mappedName = mapExtensionName(name); - return m_enabledExtensions.contains(mappedName); -} - -DELEGATE_TO_IMPL_4(postSubBufferCHROMIUM, int, int, int, int) - -DELEGATE_TO_IMPL_4R(mapBufferSubDataCHROMIUM, GC3Denum, GC3Dsizeiptr, GC3Dsizei, GC3Denum, void*) -DELEGATE_TO_IMPL_1(unmapBufferSubDataCHROMIUM, const void*) -DELEGATE_TO_IMPL_9R(mapTexSubImage2DCHROMIUM, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Denum, GC3Denum, GC3Denum, void*) -DELEGATE_TO_IMPL_1(unmapTexSubImage2DCHROMIUM, const void*) - -DELEGATE_TO_IMPL_1(setVisibilityCHROMIUM, bool); - -DELEGATE_TO_IMPL_3(discardFramebufferEXT, GC3Denum, GC3Dsizei, const GC3Denum*); -DELEGATE_TO_IMPL(ensureFramebufferCHROMIUM); - -DELEGATE_TO_IMPL_10(blitFramebufferCHROMIUM, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dbitfield, GC3Denum) -DELEGATE_TO_IMPL_5(renderbufferStorageMultisampleCHROMIUM, GC3Denum, GC3Dsizei, GC3Denum, GC3Dsizei, GC3Dsizei) - -DELEGATE_TO_IMPL(rateLimitOffscreenContextCHROMIUM) -DELEGATE_TO_IMPL_R(getGraphicsResetStatusARB, GC3Denum) - -DELEGATE_TO_IMPL_1R(getTranslatedShaderSourceANGLE, Platform3DObject, String) -DELEGATE_TO_IMPL_5(texImageIOSurface2DCHROMIUM, GC3Denum, GC3Dint, GC3Dint, GC3Duint, GC3Duint) -DELEGATE_TO_IMPL_5(texStorage2DEXT, GC3Denum, GC3Dint, GC3Duint, GC3Dint, GC3Dint) - -DELEGATE_TO_IMPL_R(createQueryEXT, Platform3DObject) -DELEGATE_TO_IMPL_1(deleteQueryEXT, Platform3DObject) -DELEGATE_TO_IMPL_1R(isQueryEXT, Platform3DObject, GC3Dboolean) -DELEGATE_TO_IMPL_2(beginQueryEXT, GC3Denum, Platform3DObject) -DELEGATE_TO_IMPL_1(endQueryEXT, GC3Denum) -DELEGATE_TO_IMPL_3(getQueryivEXT, GC3Denum, GC3Denum, GC3Dint*) -DELEGATE_TO_IMPL_3(getQueryObjectuivEXT, Platform3DObject, GC3Denum, GC3Duint*) - -//---------------------------------------------------------------------- -// GraphicsContext3D -// - -// Macros to assist in delegating from GraphicsContext3D to -// GraphicsContext3DPrivate. - -#define DELEGATE_TO_INTERNAL(name) \ -void GraphicsContext3D::name() \ -{ \ - m_private->name(); \ -} - -#define DELEGATE_TO_INTERNAL_R(name, rt) \ -rt GraphicsContext3D::name() \ -{ \ - return m_private->name(); \ -} - -#define DELEGATE_TO_INTERNAL_1(name, t1) \ -void GraphicsContext3D::name(t1 a1) \ -{ \ - m_private->name(a1); \ -} - -#define DELEGATE_TO_INTERNAL_1R(name, t1, rt) \ -rt GraphicsContext3D::name(t1 a1) \ -{ \ - return m_private->name(a1); \ -} - -#define DELEGATE_TO_INTERNAL_2(name, t1, t2) \ -void GraphicsContext3D::name(t1 a1, t2 a2) \ -{ \ - m_private->name(a1, a2); \ -} - -#define DELEGATE_TO_INTERNAL_2R(name, t1, t2, rt) \ -rt GraphicsContext3D::name(t1 a1, t2 a2) \ -{ \ - return m_private->name(a1, a2); \ -} - -#define DELEGATE_TO_INTERNAL_3(name, t1, t2, t3) \ -void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3) \ -{ \ - m_private->name(a1, a2, a3); \ -} - -#define DELEGATE_TO_INTERNAL_3R(name, t1, t2, t3, rt) \ -rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3) \ -{ \ - return m_private->name(a1, a2, a3); \ -} - -#define DELEGATE_TO_INTERNAL_4(name, t1, t2, t3, t4) \ -void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4) \ -{ \ - m_private->name(a1, a2, a3, a4); \ -} - -#define DELEGATE_TO_INTERNAL_4R(name, t1, t2, t3, t4, rt) \ -rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4) \ -{ \ - return m_private->name(a1, a2, a3, a4); \ -} - -#define DELEGATE_TO_INTERNAL_5(name, t1, t2, t3, t4, t5) \ -void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) \ -{ \ - m_private->name(a1, a2, a3, a4, a5); \ -} - -#define DELEGATE_TO_INTERNAL_6(name, t1, t2, t3, t4, t5, t6) \ -void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \ -{ \ - m_private->name(a1, a2, a3, a4, a5, a6); \ -} - -#define DELEGATE_TO_INTERNAL_6R(name, t1, t2, t3, t4, t5, t6, rt) \ -rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \ -{ \ - return m_private->name(a1, a2, a3, a4, a5, a6); \ -} - -#define DELEGATE_TO_INTERNAL_7(name, t1, t2, t3, t4, t5, t6, t7) \ -void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \ -{ \ - m_private->name(a1, a2, a3, a4, a5, a6, a7); \ -} - -#define DELEGATE_TO_INTERNAL_7R(name, t1, t2, t3, t4, t5, t6, t7, rt) \ -rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \ -{ \ - return m_private->name(a1, a2, a3, a4, a5, a6, a7); \ -} - -#define DELEGATE_TO_INTERNAL_8(name, t1, t2, t3, t4, t5, t6, t7, t8) \ -void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) \ -{ \ - m_private->name(a1, a2, a3, a4, a5, a6, a7, a8); \ -} - -#define DELEGATE_TO_INTERNAL_9(name, t1, t2, t3, t4, t5, t6, t7, t8, t9) \ -void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) \ -{ \ - m_private->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \ -} - -#define DELEGATE_TO_INTERNAL_9R(name, t1, t2, t3, t4, t5, t6, t7, t8, t9, rt) \ -rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) \ -{ \ - return m_private->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \ -} - -GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, bool) -{ -} - -GraphicsContext3D::~GraphicsContext3D() -{ - m_private->setContextLostCallback(nullptr); - m_private->setErrorMessageCallback(nullptr); - m_private->setSwapBuffersCompleteCallbackCHROMIUM(nullptr); - m_private->setGpuMemoryAllocationChangedCallbackCHROMIUM(nullptr); -} - -PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow*, GraphicsContext3D::RenderStyle renderStyle) -{ - ASSERT(renderStyle != GraphicsContext3D::RenderDirectlyToHostWindow); - - WebKit::WebGraphicsContext3D::Attributes webAttributes; - webAttributes.alpha = attrs.alpha; - webAttributes.depth = attrs.depth; - webAttributes.stencil = attrs.stencil; - webAttributes.antialias = attrs.antialias; - webAttributes.premultipliedAlpha = attrs.premultipliedAlpha; - webAttributes.noExtensions = attrs.noExtensions; - webAttributes.shareResources = attrs.shareResources; - webAttributes.preferDiscreteGPU = attrs.preferDiscreteGPU; - - OwnPtr<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::Platform::current()->createOffscreenGraphicsContext3D(webAttributes)); - if (!webContext) - return 0; - - return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), renderStyle, attrs.preserveDrawingBuffer); -} - -PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() const -{ - return m_private->platformGraphicsContext3D(); -} - -Platform3DObject GraphicsContext3D::platformTexture() const -{ - return m_private->platformTexture(); -} - -GrContext* GraphicsContext3D::grContext() -{ - return m_private->grContext(); -} - -void GraphicsContext3D::prepareTexture() -{ - return m_private->prepareTexture(); -} - -IntSize GraphicsContext3D::getInternalFramebufferSize() const -{ - return m_private->getInternalFramebufferSize(); -} - -bool GraphicsContext3D::isResourceSafe() -{ - return m_private->isResourceSafe(); -} - -#if USE(ACCELERATED_COMPOSITING) -PlatformLayer* GraphicsContext3D::platformLayer() const -{ - return 0; -} -#endif - -DELEGATE_TO_INTERNAL_R(makeContextCurrent, bool) -DELEGATE_TO_INTERNAL_2(reshape, int, int) - -DELEGATE_TO_INTERNAL_1(activeTexture, GC3Denum) -DELEGATE_TO_INTERNAL_2(attachShader, Platform3DObject, Platform3DObject) -DELEGATE_TO_INTERNAL_3(bindAttribLocation, Platform3DObject, GC3Duint, const String&) - -DELEGATE_TO_INTERNAL_2(bindBuffer, GC3Denum, Platform3DObject) -DELEGATE_TO_INTERNAL_2(bindFramebuffer, GC3Denum, Platform3DObject) -DELEGATE_TO_INTERNAL_2(bindRenderbuffer, GC3Denum, Platform3DObject) -DELEGATE_TO_INTERNAL_2(bindTexture, GC3Denum, Platform3DObject) -DELEGATE_TO_INTERNAL_4(blendColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dclampf) -DELEGATE_TO_INTERNAL_1(blendEquation, GC3Denum) -DELEGATE_TO_INTERNAL_2(blendEquationSeparate, GC3Denum, GC3Denum) -DELEGATE_TO_INTERNAL_2(blendFunc, GC3Denum, GC3Denum) -DELEGATE_TO_INTERNAL_4(blendFuncSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Denum) - -DELEGATE_TO_INTERNAL_3(bufferData, GC3Denum, GC3Dsizeiptr, GC3Denum) -DELEGATE_TO_INTERNAL_4(bufferData, GC3Denum, GC3Dsizeiptr, const void*, GC3Denum) -DELEGATE_TO_INTERNAL_4(bufferSubData, GC3Denum, GC3Dintptr, GC3Dsizeiptr, const void*) - -DELEGATE_TO_INTERNAL_1R(checkFramebufferStatus, GC3Denum, GC3Denum) -DELEGATE_TO_INTERNAL_1(clear, GC3Dbitfield) -DELEGATE_TO_INTERNAL_4(clearColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dclampf) -DELEGATE_TO_INTERNAL_1(clearDepth, GC3Dclampf) -DELEGATE_TO_INTERNAL_1(clearStencil, GC3Dint) -DELEGATE_TO_INTERNAL_4(colorMask, GC3Dboolean, GC3Dboolean, GC3Dboolean, GC3Dboolean) -DELEGATE_TO_INTERNAL_1(compileShader, Platform3DObject) - -DELEGATE_TO_INTERNAL_8(compressedTexImage2D, GC3Denum, GC3Dint, GC3Denum, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, const void*) -DELEGATE_TO_INTERNAL_9(compressedTexSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Denum, GC3Dsizei, const void*) -DELEGATE_TO_INTERNAL_8(copyTexImage2D, GC3Denum, GC3Dint, GC3Denum, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Dint) -DELEGATE_TO_INTERNAL_8(copyTexSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei) -DELEGATE_TO_INTERNAL_1(cullFace, GC3Denum) -DELEGATE_TO_INTERNAL_1(depthFunc, GC3Denum) -DELEGATE_TO_INTERNAL_1(depthMask, GC3Dboolean) -DELEGATE_TO_INTERNAL_2(depthRange, GC3Dclampf, GC3Dclampf) -DELEGATE_TO_INTERNAL_2(detachShader, Platform3DObject, Platform3DObject) -DELEGATE_TO_INTERNAL_1(disable, GC3Denum) -DELEGATE_TO_INTERNAL_1(disableVertexAttribArray, GC3Duint) -DELEGATE_TO_INTERNAL_3(drawArrays, GC3Denum, GC3Dint, GC3Dsizei) -DELEGATE_TO_INTERNAL_4(drawElements, GC3Denum, GC3Dsizei, GC3Denum, GC3Dintptr) - -DELEGATE_TO_INTERNAL_1(enable, GC3Denum) -DELEGATE_TO_INTERNAL_1(enableVertexAttribArray, GC3Duint) -DELEGATE_TO_INTERNAL(finish) -DELEGATE_TO_INTERNAL(flush) -DELEGATE_TO_INTERNAL_4(framebufferRenderbuffer, GC3Denum, GC3Denum, GC3Denum, Platform3DObject) -DELEGATE_TO_INTERNAL_5(framebufferTexture2D, GC3Denum, GC3Denum, GC3Denum, Platform3DObject, GC3Dint) -DELEGATE_TO_INTERNAL_1(frontFace, GC3Denum) -DELEGATE_TO_INTERNAL_1(generateMipmap, GC3Denum) - -DELEGATE_TO_INTERNAL_3R(getActiveAttrib, Platform3DObject, GC3Duint, ActiveInfo&, bool) -DELEGATE_TO_INTERNAL_3R(getActiveUniform, Platform3DObject, GC3Duint, ActiveInfo&, bool) -DELEGATE_TO_INTERNAL_4(getAttachedShaders, Platform3DObject, GC3Dsizei, GC3Dsizei*, Platform3DObject*) -DELEGATE_TO_INTERNAL_2R(getAttribLocation, Platform3DObject, const String&, GC3Dint) -DELEGATE_TO_INTERNAL_2(getBooleanv, GC3Denum, GC3Dboolean*) -DELEGATE_TO_INTERNAL_3(getBufferParameteriv, GC3Denum, GC3Denum, GC3Dint*) -DELEGATE_TO_INTERNAL_R(getContextAttributes, GraphicsContext3D::Attributes) -DELEGATE_TO_INTERNAL_R(getError, GC3Denum) -DELEGATE_TO_INTERNAL_2(getFloatv, GC3Denum, GC3Dfloat*) -DELEGATE_TO_INTERNAL_4(getFramebufferAttachmentParameteriv, GC3Denum, GC3Denum, GC3Denum, GC3Dint*) -DELEGATE_TO_INTERNAL_2(getIntegerv, GC3Denum, GC3Dint*) -DELEGATE_TO_INTERNAL_3(getProgramiv, Platform3DObject, GC3Denum, GC3Dint*) -DELEGATE_TO_INTERNAL_1R(getProgramInfoLog, Platform3DObject, String) -DELEGATE_TO_INTERNAL_3(getRenderbufferParameteriv, GC3Denum, GC3Denum, GC3Dint*) -DELEGATE_TO_INTERNAL_3(getShaderiv, Platform3DObject, GC3Denum, GC3Dint*) -DELEGATE_TO_INTERNAL_1R(getShaderInfoLog, Platform3DObject, String) -DELEGATE_TO_INTERNAL_4(getShaderPrecisionFormat, GC3Denum, GC3Denum, GC3Dint*, GC3Dint*) -DELEGATE_TO_INTERNAL_1R(getShaderSource, Platform3DObject, String) -DELEGATE_TO_INTERNAL_1R(getString, GC3Denum, String) -DELEGATE_TO_INTERNAL_3(getTexParameterfv, GC3Denum, GC3Denum, GC3Dfloat*) -DELEGATE_TO_INTERNAL_3(getTexParameteriv, GC3Denum, GC3Denum, GC3Dint*) -DELEGATE_TO_INTERNAL_3(getUniformfv, Platform3DObject, GC3Dint, GC3Dfloat*) -DELEGATE_TO_INTERNAL_3(getUniformiv, Platform3DObject, GC3Dint, GC3Dint*) -DELEGATE_TO_INTERNAL_2R(getUniformLocation, Platform3DObject, const String&, GC3Dint) -DELEGATE_TO_INTERNAL_3(getVertexAttribfv, GC3Duint, GC3Denum, GC3Dfloat*) -DELEGATE_TO_INTERNAL_3(getVertexAttribiv, GC3Duint, GC3Denum, GC3Dint*) -DELEGATE_TO_INTERNAL_2R(getVertexAttribOffset, GC3Duint, GC3Denum, GC3Dsizeiptr) - -DELEGATE_TO_INTERNAL_2(hint, GC3Denum, GC3Denum) -DELEGATE_TO_INTERNAL_1R(isBuffer, Platform3DObject, GC3Dboolean) -DELEGATE_TO_INTERNAL_1R(isEnabled, GC3Denum, GC3Dboolean) -DELEGATE_TO_INTERNAL_1R(isFramebuffer, Platform3DObject, GC3Dboolean) -DELEGATE_TO_INTERNAL_1R(isProgram, Platform3DObject, GC3Dboolean) -DELEGATE_TO_INTERNAL_1R(isRenderbuffer, Platform3DObject, GC3Dboolean) -DELEGATE_TO_INTERNAL_1R(isShader, Platform3DObject, GC3Dboolean) -DELEGATE_TO_INTERNAL_1R(isTexture, Platform3DObject, GC3Dboolean) -DELEGATE_TO_INTERNAL_1(lineWidth, GC3Dfloat) -DELEGATE_TO_INTERNAL_1(linkProgram, Platform3DObject) -DELEGATE_TO_INTERNAL_2(pixelStorei, GC3Denum, GC3Dint) -DELEGATE_TO_INTERNAL_2(polygonOffset, GC3Dfloat, GC3Dfloat) - -DELEGATE_TO_INTERNAL_7(readPixels, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Denum, GC3Denum, void*) - -DELEGATE_TO_INTERNAL(releaseShaderCompiler) -DELEGATE_TO_INTERNAL_4(renderbufferStorage, GC3Denum, GC3Denum, GC3Dsizei, GC3Dsizei) -DELEGATE_TO_INTERNAL_2(sampleCoverage, GC3Dclampf, GC3Dboolean) -DELEGATE_TO_INTERNAL_4(scissor, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei) -DELEGATE_TO_INTERNAL_2(shaderSource, Platform3DObject, const String&) -DELEGATE_TO_INTERNAL_3(stencilFunc, GC3Denum, GC3Dint, GC3Duint) -DELEGATE_TO_INTERNAL_4(stencilFuncSeparate, GC3Denum, GC3Denum, GC3Dint, GC3Duint) -DELEGATE_TO_INTERNAL_1(stencilMask, GC3Duint) -DELEGATE_TO_INTERNAL_2(stencilMaskSeparate, GC3Denum, GC3Duint) -DELEGATE_TO_INTERNAL_3(stencilOp, GC3Denum, GC3Denum, GC3Denum) -DELEGATE_TO_INTERNAL_4(stencilOpSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Denum) - -DELEGATE_TO_INTERNAL_9R(texImage2D, GC3Denum, GC3Dint, GC3Denum, GC3Dsizei, GC3Dsizei, GC3Dint, GC3Denum, GC3Denum, const void*, bool) -DELEGATE_TO_INTERNAL_3(texParameterf, GC3Denum, GC3Denum, GC3Dfloat) -DELEGATE_TO_INTERNAL_3(texParameteri, GC3Denum, GC3Denum, GC3Dint) -DELEGATE_TO_INTERNAL_9(texSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Denum, GC3Denum, const void*) - -DELEGATE_TO_INTERNAL_2(uniform1f, GC3Dint, GC3Dfloat) -DELEGATE_TO_INTERNAL_3(uniform1fv, GC3Dint, GC3Dsizei, GC3Dfloat*) -DELEGATE_TO_INTERNAL_2(uniform1i, GC3Dint, GC3Dint) -DELEGATE_TO_INTERNAL_3(uniform1iv, GC3Dint, GC3Dsizei, GC3Dint*) -DELEGATE_TO_INTERNAL_3(uniform2f, GC3Dint, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_INTERNAL_3(uniform2fv, GC3Dint, GC3Dsizei, GC3Dfloat*) -DELEGATE_TO_INTERNAL_3(uniform2i, GC3Dint, GC3Dint, GC3Dint) -DELEGATE_TO_INTERNAL_3(uniform2iv, GC3Dint, GC3Dsizei, GC3Dint*) -DELEGATE_TO_INTERNAL_4(uniform3f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_INTERNAL_3(uniform3fv, GC3Dint, GC3Dsizei, GC3Dfloat*) -DELEGATE_TO_INTERNAL_4(uniform3i, GC3Dint, GC3Dint, GC3Dint, GC3Dint) -DELEGATE_TO_INTERNAL_3(uniform3iv, GC3Dint, GC3Dsizei, GC3Dint*) -DELEGATE_TO_INTERNAL_5(uniform4f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_INTERNAL_3(uniform4fv, GC3Dint, GC3Dsizei, GC3Dfloat*) -DELEGATE_TO_INTERNAL_5(uniform4i, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint) -DELEGATE_TO_INTERNAL_3(uniform4iv, GC3Dint, GC3Dsizei, GC3Dint*) -DELEGATE_TO_INTERNAL_4(uniformMatrix2fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3Dfloat*) -DELEGATE_TO_INTERNAL_4(uniformMatrix3fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3Dfloat*) -DELEGATE_TO_INTERNAL_4(uniformMatrix4fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3Dfloat*) - -DELEGATE_TO_INTERNAL_1(useProgram, Platform3DObject) -DELEGATE_TO_INTERNAL_1(validateProgram, Platform3DObject) - -DELEGATE_TO_INTERNAL_2(vertexAttrib1f, GC3Duint, GC3Dfloat) -DELEGATE_TO_INTERNAL_2(vertexAttrib1fv, GC3Duint, GC3Dfloat*) -DELEGATE_TO_INTERNAL_3(vertexAttrib2f, GC3Duint, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_INTERNAL_2(vertexAttrib2fv, GC3Duint, GC3Dfloat*) -DELEGATE_TO_INTERNAL_4(vertexAttrib3f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_INTERNAL_2(vertexAttrib3fv, GC3Duint, GC3Dfloat*) -DELEGATE_TO_INTERNAL_5(vertexAttrib4f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat) -DELEGATE_TO_INTERNAL_2(vertexAttrib4fv, GC3Duint, GC3Dfloat*) -DELEGATE_TO_INTERNAL_6(vertexAttribPointer, GC3Duint, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dintptr) - -DELEGATE_TO_INTERNAL_4(viewport, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei) - -DELEGATE_TO_INTERNAL(markLayerComposited) -DELEGATE_TO_INTERNAL(markContextChanged) - -bool GraphicsContext3D::layerComposited() const -{ - return m_private->layerComposited(); -} - -void GraphicsContext3D::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer, DrawingBuffer* drawingBuffer) -{ - return m_private->paintRenderingResultsToCanvas(imageBuffer, drawingBuffer); -} - -PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData(DrawingBuffer* drawingBuffer) -{ - return m_private->paintRenderingResultsToImageData(drawingBuffer); -} - -DELEGATE_TO_INTERNAL_1R(paintCompositedResultsToCanvas, ImageBuffer*, bool) - -DELEGATE_TO_INTERNAL_R(createBuffer, Platform3DObject) -DELEGATE_TO_INTERNAL_R(createFramebuffer, Platform3DObject) -DELEGATE_TO_INTERNAL_R(createProgram, Platform3DObject) -DELEGATE_TO_INTERNAL_R(createRenderbuffer, Platform3DObject) -DELEGATE_TO_INTERNAL_1R(createShader, GC3Denum, Platform3DObject) -DELEGATE_TO_INTERNAL_R(createTexture, Platform3DObject) - -DELEGATE_TO_INTERNAL_1(deleteBuffer, Platform3DObject) -DELEGATE_TO_INTERNAL_1(deleteFramebuffer, Platform3DObject) -DELEGATE_TO_INTERNAL_1(deleteProgram, Platform3DObject) -DELEGATE_TO_INTERNAL_1(deleteRenderbuffer, Platform3DObject) -DELEGATE_TO_INTERNAL_1(deleteShader, Platform3DObject) -DELEGATE_TO_INTERNAL_1(deleteTexture, Platform3DObject) - -DELEGATE_TO_INTERNAL_1(synthesizeGLError, GC3Denum) -DELEGATE_TO_INTERNAL_R(getExtensions, Extensions3D*) - -DELEGATE_TO_INTERNAL_1(setContextLostCallback, PassOwnPtr<GraphicsContext3D::ContextLostCallback>) -DELEGATE_TO_INTERNAL_1(setErrorMessageCallback, PassOwnPtr<GraphicsContext3D::ErrorMessageCallback>) - -class GraphicsContextLostCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { -public: - virtual void onContextLost(); - static PassOwnPtr<GraphicsContextLostCallbackAdapter> create(PassOwnPtr<GraphicsContext3D::ContextLostCallback>); - virtual ~GraphicsContextLostCallbackAdapter() { } -private: - GraphicsContextLostCallbackAdapter(PassOwnPtr<GraphicsContext3D::ContextLostCallback> cb) : m_contextLostCallback(cb) { } - OwnPtr<GraphicsContext3D::ContextLostCallback> m_contextLostCallback; -}; - -void GraphicsContextLostCallbackAdapter::onContextLost() -{ - if (m_contextLostCallback) - m_contextLostCallback->onContextLost(); -} - -PassOwnPtr<GraphicsContextLostCallbackAdapter> GraphicsContextLostCallbackAdapter::create(PassOwnPtr<GraphicsContext3D::ContextLostCallback> cb) -{ - return adoptPtr(cb.get() ? new GraphicsContextLostCallbackAdapter(cb) : 0); -} - -void GraphicsContext3DPrivate::setContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallback> cb) -{ - m_contextLostCallbackAdapter = GraphicsContextLostCallbackAdapter::create(cb); - m_impl->setContextLostCallback(m_contextLostCallbackAdapter.get()); -} - -class GraphicsErrorMessageCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsErrorMessageCallback { -public: - virtual void onErrorMessage(const WebKit::WebString&, WebKit::WGC3Dint); - static PassOwnPtr<GraphicsErrorMessageCallbackAdapter> create(PassOwnPtr<GraphicsContext3D::ErrorMessageCallback>); - virtual ~GraphicsErrorMessageCallbackAdapter() { } -private: - GraphicsErrorMessageCallbackAdapter(PassOwnPtr<GraphicsContext3D::ErrorMessageCallback> cb) : m_errorMessageCallback(cb) { } - OwnPtr<GraphicsContext3D::ErrorMessageCallback> m_errorMessageCallback; -}; - -void GraphicsErrorMessageCallbackAdapter::onErrorMessage(const WebKit::WebString& message, WebKit::WGC3Dint id) -{ - if (m_errorMessageCallback) - m_errorMessageCallback->onErrorMessage(message, id); -} - -PassOwnPtr<GraphicsErrorMessageCallbackAdapter> GraphicsErrorMessageCallbackAdapter::create(PassOwnPtr<GraphicsContext3D::ErrorMessageCallback> cb) -{ - return adoptPtr(cb.get() ? new GraphicsErrorMessageCallbackAdapter(cb) : 0); -} - -void GraphicsContext3DPrivate::setErrorMessageCallback(PassOwnPtr<GraphicsContext3D::ErrorMessageCallback> cb) -{ - m_errorMessageCallbackAdapter = GraphicsErrorMessageCallbackAdapter::create(cb); - m_impl->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); -} - -bool GraphicsContext3D::isGLES2Compliant() const -{ - return m_private->isGLES2Compliant(); -} - -class GraphicsContext3DSwapBuffersCompleteCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM { -public: - virtual void onSwapBuffersComplete(); - static PassOwnPtr<GraphicsContext3DSwapBuffersCompleteCallbackAdapter> create(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM>); - virtual ~GraphicsContext3DSwapBuffersCompleteCallbackAdapter() { } - -private: - GraphicsContext3DSwapBuffersCompleteCallbackAdapter(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> cb) : m_swapBuffersCompleteCallback(cb) { } - OwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> m_swapBuffersCompleteCallback; -}; - -void GraphicsContext3DSwapBuffersCompleteCallbackAdapter::onSwapBuffersComplete() -{ - if (m_swapBuffersCompleteCallback) - m_swapBuffersCompleteCallback->onSwapBuffersComplete(); -} - -PassOwnPtr<GraphicsContext3DSwapBuffersCompleteCallbackAdapter> GraphicsContext3DSwapBuffersCompleteCallbackAdapter::create(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> cb) -{ - return adoptPtr(cb.get() ? new GraphicsContext3DSwapBuffersCompleteCallbackAdapter(cb) : 0); -} - -void GraphicsContext3DPrivate::setSwapBuffersCompleteCallbackCHROMIUM(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> cb) -{ - m_swapBuffersCompleteCallbackAdapter = GraphicsContext3DSwapBuffersCompleteCallbackAdapter::create(cb); - m_impl->setSwapBuffersCompleteCallbackCHROMIUM(m_swapBuffersCompleteCallbackAdapter.get()); -} - -class GraphicsContext3DMemoryAllocationChangedCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM { -public: - GraphicsContext3DMemoryAllocationChangedCallbackAdapter(PassOwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM> cb) - : m_memoryAllocationChangedCallback(cb) - { - } - - virtual ~GraphicsContext3DMemoryAllocationChangedCallbackAdapter() { } - - virtual void onMemoryAllocationChanged(size_t gpuResourceSizeInBytes) - { - // FIXME: Remove this once clients start using WebGraphicsMemoryAllocation exclusively. - onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation(gpuResourceSizeInBytes, true)); - } - - virtual void onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation allocation) - { - if (m_memoryAllocationChangedCallback) - m_memoryAllocationChangedCallback->onGpuMemoryAllocationChanged(Extensions3DChromium::GpuMemoryAllocationCHROMIUM(allocation.gpuResourceSizeInBytes, allocation.suggestHaveBackbuffer)); - } - -private: - OwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM> m_memoryAllocationChangedCallback; -}; - -void GraphicsContext3DPrivate::setGpuMemoryAllocationChangedCallbackCHROMIUM(PassOwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM> cb) -{ - m_memoryAllocationChangedCallbackAdapter = adoptPtr(new GraphicsContext3DMemoryAllocationChangedCallbackAdapter(cb)); - m_impl->setMemoryAllocationChangedCallbackCHROMIUM(m_memoryAllocationChangedCallbackAdapter.get()); -} - -} // namespace WebCore - -#endif // ENABLE(WEBGL) diff --git a/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h b/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h deleted file mode 100644 index a269192a4..000000000 --- a/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GraphicsContext3DPrivate_h -#define GraphicsContext3DPrivate_h - -#include "Extensions3DChromium.h" -#include "GraphicsContext3D.h" -#include "SkBitmap.h" -#include <wtf/HashSet.h> -#include <wtf/OwnArrayPtr.h> -#include <wtf/OwnPtr.h> - -class GrContext; - -namespace WebKit { -class WebGraphicsContext3D; -} - -namespace WebCore { - -class DrawingBuffer; -class Extensions3DChromium; -class GraphicsContextLostCallbackAdapter; -class GraphicsContext3DSwapBuffersCompleteCallbackAdapter; -class GraphicsErrorMessageCallbackAdapter; -class GraphicsContext3DMemoryAllocationChangedCallbackAdapter; - -class GraphicsContext3DPrivate { -public: - // Callers must make the context current before using it AND check that the context was created successfully - // via ContextLost before using the context in any way. Once made current on a thread, the context cannot - // be used on any other thread. - static PassRefPtr<GraphicsContext3D> createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D>, GraphicsContext3D::RenderStyle, bool preserveDrawingBuffer = false); - - virtual ~GraphicsContext3DPrivate(); - - // Helper function to provide access to the lower-level WebGraphicsContext3D, - // which is needed for subordinate contexts like WebGL's to share resources - // with the compositor's context. - static WebKit::WebGraphicsContext3D* extractWebGraphicsContext3D(GraphicsContext3D*); - - PlatformGraphicsContext3D platformGraphicsContext3D() const; - Platform3DObject platformTexture() const; - GrContext* grContext(); - - bool makeContextCurrent(); - - void reshape(int width, int height); - IntSize getInternalFramebufferSize() const; - bool isResourceSafe(); - - void markContextChanged(); - bool layerComposited() const; - void markLayerComposited(); - - void paintRenderingResultsToCanvas(ImageBuffer*, DrawingBuffer*); - void paintFramebufferToCanvas(int framebuffer, int width, int height, bool premultiplyAlpha, ImageBuffer*); - PassRefPtr<ImageData> paintRenderingResultsToImageData(DrawingBuffer*); - bool paintCompositedResultsToCanvas(ImageBuffer*); - - void prepareTexture(); - - // CHROMIUM_post_sub_buffer - void postSubBufferCHROMIUM(int x, int y, int width, int height); - - bool isGLES2Compliant() const; - - void releaseShaderCompiler(); - bool isContextLost(); - - //---------------------------------------------------------------------- - // Entry points for WebGL. - // - void activeTexture(GC3Denum texture); - void attachShader(Platform3DObject program, Platform3DObject shader); - void bindAttribLocation(Platform3DObject, GC3Duint index, const String& name); - void bindBuffer(GC3Denum target, Platform3DObject); - void bindFramebuffer(GC3Denum target, Platform3DObject); - void bindRenderbuffer(GC3Denum target, Platform3DObject); - void bindTexture(GC3Denum target, Platform3DObject); - void blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha); - void blendEquation(GC3Denum mode); - void blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha); - void blendFunc(GC3Denum sfactor, GC3Denum dfactor); - void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha); - - void bufferData(GC3Denum target, GC3Dsizeiptr, GC3Denum usage); - void bufferData(GC3Denum target, GC3Dsizeiptr, const void* data, GC3Denum usage); - void bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr, const void* data); - - GC3Denum checkFramebufferStatus(GC3Denum target); - void clear(GC3Dbitfield mask); - void clearColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha); - void clearDepth(GC3Dclampf depth); - void clearStencil(GC3Dint s); - void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha); - void compileShader(Platform3DObject); - - void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data); - void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data); - void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border); - void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height); - void cullFace(GC3Denum mode); - void depthFunc(GC3Denum func); - void depthMask(GC3Dboolean flag); - void depthRange(GC3Dclampf zNear, GC3Dclampf zFar); - void detachShader(Platform3DObject, Platform3DObject); - void disable(GC3Denum cap); - void disableVertexAttribArray(GC3Duint index); - void drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count); - void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset); - - void enable(GC3Denum cap); - void enableVertexAttribArray(GC3Duint index); - void finish(); - void flush(); - void framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject); - void framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject, GC3Dint level); - void frontFace(GC3Denum mode); - void generateMipmap(GC3Denum target); - - bool getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo&); - bool getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo&); - void getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders); - GC3Dint getAttribLocation(Platform3DObject, const String& name); - void getBooleanv(GC3Denum pname, GC3Dboolean* value); - void getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value); - GraphicsContext3D::Attributes getContextAttributes(); - GC3Denum getError(); - void getFloatv(GC3Denum pname, GC3Dfloat* value); - void getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value); - void getIntegerv(GC3Denum pname, GC3Dint* value); - void getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value); - String getProgramInfoLog(Platform3DObject); - void getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value); - void getShaderiv(Platform3DObject, GC3Denum pname, GC3Dint* value); - String getShaderInfoLog(Platform3DObject); - void getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision); - - String getShaderSource(Platform3DObject); - String getString(GC3Denum name); - void getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value); - void getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value); - void getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value); - void getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value); - GC3Dint getUniformLocation(Platform3DObject, const String& name); - void getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value); - void getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value); - GC3Dsizeiptr getVertexAttribOffset(GC3Duint index, GC3Denum pname); - - void hint(GC3Denum target, GC3Denum mode); - GC3Dboolean isBuffer(Platform3DObject); - GC3Dboolean isEnabled(GC3Denum cap); - GC3Dboolean isFramebuffer(Platform3DObject); - GC3Dboolean isProgram(Platform3DObject); - GC3Dboolean isRenderbuffer(Platform3DObject); - GC3Dboolean isShader(Platform3DObject); - GC3Dboolean isTexture(Platform3DObject); - void lineWidth(GC3Dfloat); - void linkProgram(Platform3DObject); - void pixelStorei(GC3Denum pname, GC3Dint param); - void polygonOffset(GC3Dfloat factor, GC3Dfloat units); - - void readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data); - - void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height); - void sampleCoverage(GC3Dclampf value, GC3Dboolean invert); - void scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height); - void shaderSource(Platform3DObject, const String&); - void stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask); - void stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask); - void stencilMask(GC3Duint mask); - void stencilMaskSeparate(GC3Denum face, GC3Duint mask); - void stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass); - void stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass); - - // texImage2D return false on any error rather than using an ExceptionCode. - bool texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels); - void texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat param); - void texParameteri(GC3Denum target, GC3Denum pname, GC3Dint param); - void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels); - - void uniform1f(GC3Dint location, GC3Dfloat x); - void uniform1fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v); - void uniform1i(GC3Dint location, GC3Dint x); - void uniform1iv(GC3Dint location, GC3Dsizei, GC3Dint* v); - void uniform2f(GC3Dint location, GC3Dfloat x, float y); - void uniform2fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v); - void uniform2i(GC3Dint location, GC3Dint x, GC3Dint y); - void uniform2iv(GC3Dint location, GC3Dsizei, GC3Dint* v); - void uniform3f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z); - void uniform3fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v); - void uniform3i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z); - void uniform3iv(GC3Dint location, GC3Dsizei, GC3Dint* v); - void uniform4f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w); - void uniform4fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v); - void uniform4i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w); - void uniform4iv(GC3Dint location, GC3Dsizei, GC3Dint* v); - void uniformMatrix2fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value); - void uniformMatrix3fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value); - void uniformMatrix4fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value); - - void useProgram(Platform3DObject); - void validateProgram(Platform3DObject); - - void vertexAttrib1f(GC3Duint index, GC3Dfloat x); - void vertexAttrib1fv(GC3Duint index, GC3Dfloat* values); - void vertexAttrib2f(GC3Duint index, GC3Dfloat x, GC3Dfloat y); - void vertexAttrib2fv(GC3Duint index, GC3Dfloat* values); - void vertexAttrib3f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z); - void vertexAttrib3fv(GC3Duint index, GC3Dfloat* values); - void vertexAttrib4f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w); - void vertexAttrib4fv(GC3Duint index, GC3Dfloat* values); - void vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, - GC3Dsizei stride, GC3Dintptr offset); - - void viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height); - - Platform3DObject createBuffer(); - Platform3DObject createFramebuffer(); - Platform3DObject createProgram(); - Platform3DObject createRenderbuffer(); - Platform3DObject createShader(GC3Denum); - Platform3DObject createTexture(); - - void deleteBuffer(Platform3DObject); - void deleteFramebuffer(Platform3DObject); - void deleteProgram(Platform3DObject); - void deleteRenderbuffer(Platform3DObject); - void deleteShader(Platform3DObject); - void deleteTexture(Platform3DObject); - - void synthesizeGLError(GC3Denum error); - - void setContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallback>); - void setErrorMessageCallback(PassOwnPtr<GraphicsContext3D::ErrorMessageCallback>); - - // Extensions3D support. - Extensions3D* getExtensions(); - bool supportsExtension(const String& name); - bool ensureExtensionEnabled(const String& name); - bool isExtensionEnabled(const String& name); - - // EXT_texture_format_BGRA8888 - bool supportsBGRA(); - - // GL_CHROMIUM_map_sub - bool supportsMapSubCHROMIUM(); - void* mapBufferSubDataCHROMIUM(GC3Denum target, GC3Dsizeiptr offset, GC3Dsizei, GC3Denum access); - void unmapBufferSubDataCHROMIUM(const void*); - void* mapTexSubImage2DCHROMIUM(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, GC3Denum access); - void unmapTexSubImage2DCHROMIUM(const void*); - - // GL_CHROMIUM_set_visibility - void setVisibilityCHROMIUM(bool); - - // GL_EXT_discard_framebuffer - virtual void discardFramebufferEXT(GC3Denum target, GC3Dsizei numAttachments, const GC3Denum* attachments); - virtual void ensureFramebufferCHROMIUM(); - - // GL_CHROMIUM_gpu_memory_manager - void setGpuMemoryAllocationChangedCallbackCHROMIUM(PassOwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM>); - - // GL_CHROMIUM_framebuffer_multisample - void blitFramebufferCHROMIUM(GC3Dint srcX0, GC3Dint srcY0, GC3Dint srcX1, GC3Dint srcY1, GC3Dint dstX0, GC3Dint dstY0, GC3Dint dstX1, GC3Dint dstY1, GC3Dbitfield mask, GC3Denum filter); - void renderbufferStorageMultisampleCHROMIUM(GC3Denum target, GC3Dsizei samples, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height); - - // GL_CHROMIUM_swapbuffers_complete_callback - void setSwapBuffersCompleteCallbackCHROMIUM(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM>); - - // GL_CHROMIUM_rate_limit_offscreen_context - void rateLimitOffscreenContextCHROMIUM(); - - // GL_ARB_robustness - GC3Denum getGraphicsResetStatusARB(); - - // GL_ANGLE_translated_shader_source - String getTranslatedShaderSourceANGLE(Platform3DObject shader); - - // GL_CHROMIUM_iosurface - void texImageIOSurface2DCHROMIUM(GC3Denum target, GC3Dint width, GC3Dint height, GC3Duint ioSurfaceId, GC3Duint plane); - - // GL_EXT_texture_storage - void texStorage2DEXT(GC3Denum target, GC3Dint levels, GC3Duint internalformat, GC3Dint width, GC3Dint height); - - // GL_EXT_occlusion_query - Platform3DObject createQueryEXT(); - void deleteQueryEXT(Platform3DObject); - GC3Dboolean isQueryEXT(Platform3DObject); - void beginQueryEXT(GC3Denum, Platform3DObject); - void endQueryEXT(GC3Denum); - void getQueryivEXT(GC3Denum, GC3Denum, GC3Dint*); - void getQueryObjectuivEXT(Platform3DObject, GC3Denum, GC3Duint*); - -private: - GraphicsContext3DPrivate(PassOwnPtr<WebKit::WebGraphicsContext3D>, bool preserveDrawingBuffer); - - void initializeExtensions(); - - OwnPtr<WebKit::WebGraphicsContext3D> m_impl; - OwnPtr<Extensions3DChromium> m_extensions; - OwnPtr<GraphicsContextLostCallbackAdapter> m_contextLostCallbackAdapter; - OwnPtr<GraphicsErrorMessageCallbackAdapter> m_errorMessageCallbackAdapter; - OwnPtr<GraphicsContext3DSwapBuffersCompleteCallbackAdapter> m_swapBuffersCompleteCallbackAdapter; - OwnPtr<GraphicsContext3DMemoryAllocationChangedCallbackAdapter> m_memoryAllocationChangedCallbackAdapter; - bool m_initializedAvailableExtensions; - HashSet<String> m_enabledExtensions; - HashSet<String> m_requestableExtensions; - bool m_layerComposited; - bool m_preserveDrawingBuffer; - - enum ResourceSafety { - ResourceSafetyUnknown, - ResourceSafe, - ResourceUnsafe - }; - ResourceSafety m_resourceSafety; - - // If the width and height of the Canvas's backing store don't - // match those that we were given in the most recent call to - // reshape(), then we need an intermediate bitmap to read back the - // frame buffer into. This seems to happen when CSS styles are - // used to resize the Canvas. - SkBitmap m_resizingBitmap; - - GrContext* m_grContext; -}; - -} // namespace WebCore - -#endif // GraphicsContext3DPrivate_h diff --git a/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp b/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp index 6e535499a..58661ebab 100644 --- a/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp +++ b/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp @@ -115,7 +115,7 @@ void IDBDatabaseBackendProxy::close(PassRefPtr<IDBDatabaseCallbacks>) m_webIDBDatabase->close(); } -void IDBDatabaseBackendProxy::open(PassRefPtr<IDBDatabaseCallbacks> databaseCallbacks) +void IDBDatabaseBackendProxy::registerFrontendCallbacks(PassRefPtr<IDBDatabaseCallbacks> databaseCallbacks) { m_webIDBDatabase->open(new WebIDBDatabaseCallbacksImpl(databaseCallbacks)); } diff --git a/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h b/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h index b78ac6992..e817edf19 100644 --- a/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h +++ b/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h @@ -52,7 +52,7 @@ public: virtual PassRefPtr<WebCore::IDBTransactionBackendInterface> transaction(WebCore::DOMStringList* storeNames, unsigned short mode, WebCore::ExceptionCode&); virtual void close(PassRefPtr<WebCore::IDBDatabaseCallbacks>); - virtual void open(PassRefPtr<WebCore::IDBDatabaseCallbacks>); + virtual void registerFrontendCallbacks(PassRefPtr<WebCore::IDBDatabaseCallbacks>); private: IDBDatabaseBackendProxy(PassOwnPtr<WebIDBDatabase>); diff --git a/Source/WebKit/chromium/src/InspectorClientImpl.cpp b/Source/WebKit/chromium/src/InspectorClientImpl.cpp index 17bd16111..025876446 100644 --- a/Source/WebKit/chromium/src/InspectorClientImpl.cpp +++ b/Source/WebKit/chromium/src/InspectorClientImpl.cpp @@ -33,6 +33,7 @@ #include "DOMWindow.h" #include "FloatRect.h" +#include "InspectorInstrumentation.h" #include "NotImplemented.h" #include "Page.h" #include "WebDevToolsAgentImpl.h" @@ -41,6 +42,7 @@ #include "platform/WebURLRequest.h" #include "WebViewClient.h" #include "WebViewImpl.h" +#include <public/Platform.h> #include <wtf/Vector.h> using namespace WebCore; @@ -128,6 +130,16 @@ void InspectorClientImpl::clearBrowserCookies() agent->clearBrowserCookies(); } +void InspectorClientImpl::startMainThreadMonitoring() +{ + WebKit::Platform::current()->currentThread()->addTaskObserver(this); +} + +void InspectorClientImpl::stopMainThreadMonitoring() +{ + WebKit::Platform::current()->currentThread()->removeTaskObserver(this); +} + bool InspectorClientImpl::canOverrideDeviceMetrics() { return true; @@ -150,6 +162,16 @@ bool InspectorClientImpl::supportsFrameInstrumentation() return true; } +void InspectorClientImpl::willProcessTask() +{ + InspectorInstrumentation::willProcessTask(m_inspectedWebView->page()); +} + +void InspectorClientImpl::didProcessTask() +{ + InspectorInstrumentation::didProcessTask(m_inspectedWebView->page()); +} + WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent() { return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent()); diff --git a/Source/WebKit/chromium/src/InspectorClientImpl.h b/Source/WebKit/chromium/src/InspectorClientImpl.h index bdb9b336d..6cb5c5544 100644 --- a/Source/WebKit/chromium/src/InspectorClientImpl.h +++ b/Source/WebKit/chromium/src/InspectorClientImpl.h @@ -33,6 +33,7 @@ #include "InspectorClient.h" #include "InspectorController.h" +#include "platform/WebThread.h" #include <wtf/OwnPtr.h> namespace WebKit { @@ -41,7 +42,8 @@ class WebDevToolsAgentClient; class WebDevToolsAgentImpl; class WebViewImpl; -class InspectorClientImpl : public WebCore::InspectorClient { +class InspectorClientImpl : public WebCore::InspectorClient, + public WebThread::TaskObserver { public: InspectorClientImpl(WebViewImpl*); ~InspectorClientImpl(); @@ -64,6 +66,9 @@ public: virtual bool canClearBrowserCookies(); virtual void clearBrowserCookies(); + virtual void startMainThreadMonitoring(); + virtual void stopMainThreadMonitoring(); + virtual bool canOverrideDeviceMetrics(); virtual void overrideDeviceMetrics(int, int, float, bool); virtual void autoZoomPageToFitWidth(); @@ -71,6 +76,10 @@ public: virtual bool supportsFrameInstrumentation(); private: + // WebThread::TaskObserver + virtual void willProcessTask(); + virtual void didProcessTask(); + WebDevToolsAgentImpl* devToolsAgent(); // The WebViewImpl of the page being inspected; gets passed to the constructor diff --git a/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp b/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp index af90bad6c..e3f7f1318 100644 --- a/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp +++ b/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp @@ -50,7 +50,6 @@ namespace WebKit { InspectorFrontendClientImpl::InspectorFrontendClientImpl(Page* frontendPage, WebDevToolsFrontendClient* client, WebDevToolsFrontendImpl* frontend) : m_frontendPage(frontendPage) , m_client(client) - , m_frontend(frontend) { } diff --git a/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h b/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h index 1aedc1f03..4f66e1bcd 100644 --- a/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h +++ b/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h @@ -79,7 +79,6 @@ public: private: WebCore::Page* m_frontendPage; WebDevToolsFrontendClient* m_client; - WebDevToolsFrontendImpl* m_frontend; RefPtr<WebCore::InspectorFrontendHost> m_frontendHost; }; diff --git a/Source/WebKit/chromium/src/NonCompositedContentHost.cpp b/Source/WebKit/chromium/src/NonCompositedContentHost.cpp index 4cc1c1177..2c37209c6 100644 --- a/Source/WebKit/chromium/src/NonCompositedContentHost.cpp +++ b/Source/WebKit/chromium/src/NonCompositedContentHost.cpp @@ -31,13 +31,15 @@ #include "FloatRect.h" #include "GraphicsLayer.h" #include "LayerChromium.h" -#include "LayerPainterChromium.h" +#include "PlatformContextSkia.h" +#include "WebViewImpl.h" #include "cc/CCLayerTreeHost.h" namespace WebKit { -NonCompositedContentHost::NonCompositedContentHost(PassOwnPtr<WebCore::LayerPainterChromium> contentPaint) - : m_contentPaint(contentPaint) +NonCompositedContentHost::NonCompositedContentHost(WebViewImpl* webView) + : m_webView(webView) + , m_opaque(true) , m_showDebugBorders(false) , m_deviceScaleFactor(1.0) { @@ -62,6 +64,12 @@ void NonCompositedContentHost::setBackgroundColor(const WebCore::Color& color) m_graphicsLayer->platformLayer()->setBackgroundColor(color); } +void NonCompositedContentHost::setOpaque(bool opaque) +{ + m_opaque = opaque; + m_graphicsLayer->platformLayer()->setOpaque(opaque); +} + void NonCompositedContentHost::setScrollLayer(WebCore::GraphicsLayer* layer) { m_graphicsLayer->setNeedsDisplay(); @@ -93,7 +101,7 @@ static void reserveScrollbarLayers(WebCore::LayerChromium* layer, WebCore::Layer layer->setAlwaysReserveTextures(true); } -void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, float deviceScale, int layerAdjustX) +void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, float deviceScale) { if (!scrollLayer()) return; @@ -101,7 +109,8 @@ void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, bool visibleRectChanged = m_viewportSize != viewportSize; m_viewportSize = viewportSize; - scrollLayer()->setScrollPosition(scrollPosition); + + scrollLayer()->setScrollPosition(scrollPosition + toSize(scrollOrigin)); scrollLayer()->setPosition(-scrollPosition); // Due to the possibility of pinch zoom, the noncomposited layer is always // assumed to be scrollable. @@ -110,10 +119,14 @@ void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, m_graphicsLayer->deviceOrPageScaleFactorChanged(); m_graphicsLayer->setSize(contentsSize); - m_layerAdjustX = layerAdjustX; - if (m_graphicsLayer->transform().m41() != m_layerAdjustX) { + // In RTL-style pages, the origin of the initial containing block for the + // root layer may be positive; translate the layer to avoid negative + // coordinates. + m_layerAdjust = -toSize(scrollOrigin); + if (m_graphicsLayer->transform().m41() != m_layerAdjust.width() || m_graphicsLayer->transform().m42() != m_layerAdjust.height()) { WebCore::TransformationMatrix transform = m_graphicsLayer->transform(); - transform.setM41(m_layerAdjustX); + transform.setM41(m_layerAdjust.width()); + transform.setM42(m_layerAdjust.height()); m_graphicsLayer->setTransform(transform); // If a tiled layer is shifted left or right, the content that goes into @@ -155,10 +168,16 @@ void NonCompositedContentHost::notifySyncRequired(const WebCore::GraphicsLayer*) void NonCompositedContentHost::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext& context, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect) { - context.translate(-m_layerAdjustX, 0); + // On non-android platforms, we want to render text with subpixel antialiasing on the root layer + // so long as the root is opaque. On android all text is grayscale. +#if !OS(ANDROID) + if (m_opaque) + context.platformContext()->setDrawingToImageBuffer(false); +#endif + context.translate(-m_layerAdjust); WebCore::IntRect adjustedClipRect = clipRect; - adjustedClipRect.move(m_layerAdjustX, 0); - m_contentPaint->paint(context, adjustedClipRect); + adjustedClipRect.move(m_layerAdjust); + m_webView->paintRootLayer(context, adjustedClipRect); } void NonCompositedContentHost::setShowDebugBorders(bool showDebugBorders) diff --git a/Source/WebKit/chromium/src/NonCompositedContentHost.h b/Source/WebKit/chromium/src/NonCompositedContentHost.h index 320e7c1be..9706860d7 100644 --- a/Source/WebKit/chromium/src/NonCompositedContentHost.h +++ b/Source/WebKit/chromium/src/NonCompositedContentHost.h @@ -40,30 +40,31 @@ class GraphicsContext; class IntPoint; class IntRect; class LayerChromium; -class LayerPainterChromium; } namespace WebKit { +class WebViewImpl; class NonCompositedContentHost : public WebCore::GraphicsLayerClient { WTF_MAKE_NONCOPYABLE(NonCompositedContentHost); public: - static PassOwnPtr<NonCompositedContentHost> create(PassOwnPtr<WebCore::LayerPainterChromium> contentPaint) + static PassOwnPtr<NonCompositedContentHost> create(WebViewImpl* webView) { - return adoptPtr(new NonCompositedContentHost(contentPaint)); + return adoptPtr(new NonCompositedContentHost(webView)); } virtual ~NonCompositedContentHost(); void invalidateRect(const WebCore::IntRect&); void setBackgroundColor(const WebCore::Color&); + void setOpaque(bool); void setScrollLayer(WebCore::GraphicsLayer*); - void setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, float deviceScale, int layerAdjustX); + void setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, float deviceScale); WebCore::GraphicsLayer* topLevelRootLayer() const { return m_graphicsLayer.get(); } void setShowDebugBorders(bool); protected: - explicit NonCompositedContentHost(PassOwnPtr<WebCore::LayerPainterChromium> contentPaint); + explicit NonCompositedContentHost(WebViewImpl*); private: // GraphicsLayerClient @@ -81,9 +82,11 @@ private: WebCore::LayerChromium* scrollLayer(); OwnPtr<WebCore::GraphicsLayer> m_graphicsLayer; - OwnPtr<WebCore::LayerPainterChromium> m_contentPaint; + WebViewImpl* m_webView; WebCore::IntSize m_viewportSize; - int m_layerAdjustX; + WebCore::IntSize m_layerAdjust; + + bool m_opaque; bool m_showDebugBorders; float m_deviceScaleFactor; }; diff --git a/Source/WebKit/chromium/src/PageWidgetDelegate.cpp b/Source/WebKit/chromium/src/PageWidgetDelegate.cpp index cb9e95fc3..340e6f1a9 100644 --- a/Source/WebKit/chromium/src/PageWidgetDelegate.cpp +++ b/Source/WebKit/chromium/src/PageWidgetDelegate.cpp @@ -82,12 +82,14 @@ void PageWidgetDelegate::layout(Page* page) view->updateLayoutAndStyleIfNeededRecursive(); } -void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas* canvas, const WebRect& rect) +void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas* canvas, const WebRect& rect, CanvasBackground background) { if (rect.isEmpty()) return; GraphicsContextBuilder builder(canvas); GraphicsContext& gc = builder.context(); + gc.platformContext()->setDrawingToImageBuffer(background == Opaque ? false : true); + gc.applyDeviceScaleFactor(page->deviceScaleFactor()); IntRect dirtyRect(rect); gc.save(); FrameView* view = mainFrameView(page); @@ -153,6 +155,7 @@ bool PageWidgetDelegate::handleInputEvent(Page* page, PageWidgetEventHandler& ha case WebInputEvent::GestureTap: case WebInputEvent::GestureTapDown: case WebInputEvent::GestureDoubleTap: + case WebInputEvent::GestureTwoFingerTap: case WebInputEvent::GestureLongPress: return handler.handleGestureEvent(*static_cast<const WebGestureEvent*>(&event)); #endif diff --git a/Source/WebKit/chromium/src/PageWidgetDelegate.h b/Source/WebKit/chromium/src/PageWidgetDelegate.h index dbbe269ac..807e1987b 100644 --- a/Source/WebKit/chromium/src/PageWidgetDelegate.h +++ b/Source/WebKit/chromium/src/PageWidgetDelegate.h @@ -73,9 +73,13 @@ public: // Common implementation of WebViewImpl and WebPagePopupImpl. class PageWidgetDelegate { public: + enum CanvasBackground { + Opaque, + Translucent, + }; static void animate(WebCore::Page*, double monotonicFrameBeginTime); static void layout(WebCore::Page*); - static void paint(WebCore::Page*, PageOverlayList*, WebCanvas*, const WebRect&); + static void paint(WebCore::Page*, PageOverlayList*, WebCanvas*, const WebRect&, CanvasBackground); static bool handleInputEvent(WebCore::Page*, PageWidgetEventHandler&, const WebInputEvent&); private: diff --git a/Source/WebKit/chromium/src/PlatformMessagePortChannel.cpp b/Source/WebKit/chromium/src/PlatformMessagePortChannel.cpp index 3c7e7113c..cd903c221 100644 --- a/Source/WebKit/chromium/src/PlatformMessagePortChannel.cpp +++ b/Source/WebKit/chromium/src/PlatformMessagePortChannel.cpp @@ -36,9 +36,10 @@ #include "SerializedScriptValue.h" #include "WebKit.h" -#include "platform/WebKitPlatformSupport.h" -#include "WebMessagePortChannel.h" -#include "platform/WebString.h" + +#include <public/Platform.h> +#include <public/WebMessagePortChannel.h> +#include <public/WebString.h> using namespace WebKit; @@ -122,7 +123,7 @@ PassRefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::create( PlatformMessagePortChannel::PlatformMessagePortChannel() : m_localPort(0) { - m_webChannel = webKitPlatformSupport()->createMessagePortChannel(); + m_webChannel = WebKit::Platform::current()->createMessagePortChannel(); if (m_webChannel) m_webChannel->setClient(this); } diff --git a/Source/WebKit/chromium/src/PlatformMessagePortChannel.h b/Source/WebKit/chromium/src/PlatformMessagePortChannel.h index f674ce635..b1498d4a3 100644 --- a/Source/WebKit/chromium/src/PlatformMessagePortChannel.h +++ b/Source/WebKit/chromium/src/PlatformMessagePortChannel.h @@ -31,9 +31,9 @@ #ifndef PlatformMessagePortChannel_h #define PlatformMessagePortChannel_h -#include "WebMessagePortChannelClient.h" #include "MessagePortChannel.h" +#include <public/WebMessagePortChannelClient.h> #include <wtf/PassRefPtr.h> #include <wtf/Threading.h> diff --git a/Source/WebKit/chromium/src/PlatformSupport.cpp b/Source/WebKit/chromium/src/PlatformSupport.cpp index cfaf097ef..94b26f05a 100644 --- a/Source/WebKit/chromium/src/PlatformSupport.cpp +++ b/Source/WebKit/chromium/src/PlatformSupport.cpp @@ -78,7 +78,6 @@ #include "NativeImageSkia.h" -#include "AsyncFileSystemChromium.h" #include "BitmapImage.h" #include "Cookie.h" #include "Document.h" @@ -96,7 +95,6 @@ #include <public/WebCookie.h> #include <public/WebCookieJar.h> #include <public/WebMimeRegistry.h> -#include <public/WebWorkerRunLoop.h> #include <wtf/Assertions.h> // We are part of the WebKit implementation. @@ -208,15 +206,6 @@ bool PlatformSupport::cookiesEnabled(const Document* document) return result; } -// File ------------------------------------------------------------------------ - -#if ENABLE(FILE_SYSTEM) -PassOwnPtr<AsyncFileSystem> PlatformSupport::createAsyncFileSystem() -{ - return AsyncFileSystemChromium::create(); -} -#endif - // Font ----------------------------------------------------------------------- #if OS(WINDOWS) @@ -372,18 +361,6 @@ PassOwnPtr<AudioBus> PlatformSupport::decodeAudioFileData(const char* data, size #endif // ENABLE(WEB_AUDIO) -// SharedTimers --------------------------------------------------------------- - -void PlatformSupport::setSharedTimerFiredFunction(void (*func)()) -{ - webKitPlatformSupport()->setSharedTimerFiredFunction(func); -} - -void PlatformSupport::setSharedTimerFireInterval(double interval) -{ - webKitPlatformSupport()->setSharedTimerFireInterval(interval); -} - // Theming -------------------------------------------------------------------- #if OS(WINDOWS) @@ -721,16 +698,6 @@ bool PlatformSupport::popupsAllowed(NPP npp) } #if ENABLE(WORKERS) -void PlatformSupport::didStartWorkerRunLoop(WorkerRunLoop* loop) -{ - WebKit::Platform::current()->didStartWorkerRunLoop(WebWorkerRunLoop(loop)); -} - -void PlatformSupport::didStopWorkerRunLoop(WorkerRunLoop* loop) -{ - WebKit::Platform::current()->didStopWorkerRunLoop(WebWorkerRunLoop(loop)); -} - WorkerContextProxy* WorkerContextProxy::create(Worker* worker) { return WebWorkerClientImpl::createWorkerContextProxy(worker); diff --git a/Source/WebKit/chromium/src/SharedWorkerRepository.cpp b/Source/WebKit/chromium/src/SharedWorkerRepository.cpp index 70b800b5c..d9188ddee 100644 --- a/Source/WebKit/chromium/src/SharedWorkerRepository.cpp +++ b/Source/WebKit/chromium/src/SharedWorkerRepository.cpp @@ -47,15 +47,17 @@ #include "WebFrameClient.h" #include "WebFrameImpl.h" #include "WebKit.h" -#include "WebMessagePortChannel.h" #include "WebSharedWorker.h" #include "WebSharedWorkerRepository.h" #include "platform/WebKitPlatformSupport.h" -#include "platform/WebString.h" -#include "platform/WebURL.h" #include "WorkerScriptLoader.h" #include "WorkerScriptLoaderClient.h" +#include <public/Platform.h> +#include <public/WebMessagePortChannel.h> +#include <public/WebString.h> +#include <public/WebURL.h> + namespace WebCore { class Document; diff --git a/Source/WebKit/chromium/src/WebCompositorImpl.cpp b/Source/WebKit/chromium/src/WebCompositorImpl.cpp index 91d8b1be6..f4e96e0be 100644 --- a/Source/WebKit/chromium/src/WebCompositorImpl.cpp +++ b/Source/WebKit/chromium/src/WebCompositorImpl.cpp @@ -34,6 +34,7 @@ #include "WebInputEvent.h" #include "cc/CCLayerTreeHost.h" #include "cc/CCProxy.h" +#include "cc/CCSettings.h" #include <wtf/ThreadingPrimitives.h> using namespace WebCore; @@ -51,6 +52,25 @@ void WebCompositor::initialize(WebThread* implThread) void WebCompositor::shutdown() { WebCompositorImpl::shutdown(); + CCSettings::reset(); +} + +void WebCompositor::setPerTilePaintingEnabled(bool enabled) +{ + ASSERT(!WebCompositorImpl::initialized()); + CCSettings::setPerTilePaintingEnabled(enabled); +} + +void WebCompositor::setPartialSwapEnabled(bool enabled) +{ + ASSERT(!WebCompositorImpl::initialized()); + CCSettings::setPartialSwapEnabled(enabled); +} + +void WebCompositor::setAcceleratedAnimationEnabled(bool enabled) +{ + ASSERT(!WebCompositorImpl::initialized()); + CCSettings::setAcceleratedAnimationEnabled(enabled); } void WebCompositorImpl::initialize(WebThread* implThread) diff --git a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp index 8e0c613a4..63bf270fe 100644 --- a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp +++ b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp @@ -191,7 +191,7 @@ WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::h // FIXME: This should be DropEvent, but in cases where we fail to properly sync scrollability it's safer to send the // event to the main thread. Change back to DropEvent once we have synchronization bugs sorted out. return DidNotHandle; - case CCInputHandlerClient::ScrollFailed: + case CCInputHandlerClient::ScrollOnMainThread: return DidNotHandle; } } else if (event.type == WebInputEvent::GestureScrollBegin) { @@ -206,7 +206,7 @@ WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::h case CCInputHandlerClient::ScrollStarted: m_gestureScrollStarted = true; return DidHandle; - case CCInputHandlerClient::ScrollFailed: + case CCInputHandlerClient::ScrollOnMainThread: return DidNotHandle; case CCInputHandlerClient::ScrollIgnored: return DropEvent; @@ -278,8 +278,8 @@ WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::h m_inputHandlerClient->scheduleAnimation(); return DidHandle; } - case CCInputHandlerClient::ScrollFailed: { - TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGestureFling::failed"); + case CCInputHandlerClient::ScrollOnMainThread: { + TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGestureFling::scrollOnMainThread"); return DidNotHandle; } case CCInputHandlerClient::ScrollIgnored: { diff --git a/Source/WebKit/chromium/src/WebContentLayerImpl.cpp b/Source/WebKit/chromium/src/WebContentLayerImpl.cpp index 222fa2fa7..8c8122f6b 100644 --- a/Source/WebKit/chromium/src/WebContentLayerImpl.cpp +++ b/Source/WebKit/chromium/src/WebContentLayerImpl.cpp @@ -53,12 +53,13 @@ WebContentLayerImpl::~WebContentLayerImpl() clearDelegate(); } -void WebContentLayerImpl::paintContents(GraphicsContext& gc, const IntRect& clip) +void WebContentLayerImpl::paintContents(SkCanvas* canvas, const IntRect& clip, IntRect& opaque) { if (!m_contentClient) return; - WebCanvas* canvas = gc.platformContext()->canvas(); - m_contentClient->paintContents(canvas, WebRect(clip)); + WebRect webOpaque; + m_contentClient->paintContents(canvas, WebRect(clip), webOpaque); + opaque = webOpaque; } } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebContentLayerImpl.h b/Source/WebKit/chromium/src/WebContentLayerImpl.h index a06cf9082..542bd9b8e 100644 --- a/Source/WebKit/chromium/src/WebContentLayerImpl.h +++ b/Source/WebKit/chromium/src/WebContentLayerImpl.h @@ -41,7 +41,7 @@ protected: virtual ~WebContentLayerImpl(); // ContentLayerDelegate implementation. - virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clip); + virtual void paintContents(SkCanvas*, const WebCore::IntRect& clip, WebCore::IntRect& opaque); WebContentLayerClient* m_contentClient; bool m_drawsContent; diff --git a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp b/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp index 6f72f13fd..7792cf863 100644 --- a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp +++ b/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp @@ -39,7 +39,6 @@ #include "InspectorBackendDispatcher.h" #include "InspectorController.h" #include "InspectorFrontend.h" -#include "InspectorInstrumentation.h" #include "InspectorProtocolVersion.h" #include "MemoryCache.h" #include "Page.h" @@ -232,10 +231,8 @@ public: return; frame->setTextZoomFactor(m_webView->emulatedTextZoomFactor()); - WebSize scaledFrameSize = scaledEmulatedFrameSize(frame->view()); ensureOriginalZoomFactor(frame->view()); - double sizeRatio = static_cast<double>(scaledFrameSize.width) / m_emulatedFrameSize.width; - frame->setPageAndTextZoomFactors(sizeRatio * m_originalZoomFactor, m_webView->emulatedTextZoomFactor()); + frame->setPageAndTextZoomFactors(m_originalZoomFactor, m_webView->emulatedTextZoomFactor()); Document* doc = frame->document(); doc->styleResolverChanged(RecalcStyleImmediately); doc->updateLayout(); @@ -270,8 +267,7 @@ private: m_webView->setPageScaleFactor(1, WebPoint()); m_webView->setZoomLevel(false, 0); WebSize scaledEmulatedSize = scaledEmulatedFrameSize(frameView); - Document* document = frameView->frame()->document(); - double denominator = document->renderView() ? document->renderView()->viewWidth() : frameView->contentsWidth(); + double denominator = frameView->contentsWidth(); if (!denominator) denominator = 1; m_originalZoomFactor = static_cast<double>(scaledEmulatedSize.width) / denominator; diff --git a/Source/WebKit/chromium/src/WebDeviceOrientation.cpp b/Source/WebKit/chromium/src/WebDeviceOrientation.cpp index 098cb425c..d7a282f35 100644 --- a/Source/WebKit/chromium/src/WebDeviceOrientation.cpp +++ b/Source/WebKit/chromium/src/WebDeviceOrientation.cpp @@ -31,7 +31,7 @@ namespace WebKit { -WebDeviceOrientation::WebDeviceOrientation(const PassRefPtr<WebCore::DeviceOrientation>& orientation) +WebDeviceOrientation::WebDeviceOrientation(const WebCore::DeviceOrientation* orientation) { if (!orientation) { m_isNull = true; @@ -57,7 +57,7 @@ WebDeviceOrientation::WebDeviceOrientation(const PassRefPtr<WebCore::DeviceOrien m_absolute = orientation->absolute(); } -WebDeviceOrientation& WebDeviceOrientation::operator=(const PassRefPtr<WebCore::DeviceOrientation>& orientation) +WebDeviceOrientation& WebDeviceOrientation::operator=(const WebCore::DeviceOrientation* orientation) { if (!orientation) { m_isNull = true; diff --git a/Source/WebKit/chromium/src/WebDeviceOrientationController.cpp b/Source/WebKit/chromium/src/WebDeviceOrientationController.cpp index aa9249f76..7d09a6e7d 100644 --- a/Source/WebKit/chromium/src/WebDeviceOrientationController.cpp +++ b/Source/WebKit/chromium/src/WebDeviceOrientationController.cpp @@ -35,7 +35,7 @@ namespace WebKit { void WebDeviceOrientationController::didChangeDeviceOrientation(const WebDeviceOrientation& orientation) { - PassRefPtr<WebCore::DeviceOrientation> deviceOrientation(orientation); + RefPtr<WebCore::DeviceOrientation> deviceOrientation = PassRefPtr<WebCore::DeviceOrientation>(orientation); m_controller->didChangeDeviceOrientation(deviceOrientation.get()); } diff --git a/Source/WebKit/chromium/src/WebDocument.cpp b/Source/WebKit/chromium/src/WebDocument.cpp index d4cd18b00..063f71892 100644 --- a/Source/WebKit/chromium/src/WebDocument.cpp +++ b/Source/WebKit/chromium/src/WebDocument.cpp @@ -139,6 +139,20 @@ WebNodeCollection WebDocument::all() return WebNodeCollection(unwrap<Document>()->all()); } +void WebDocument::images(WebVector<WebElement>& results) +{ + RefPtr<HTMLCollection> images = unwrap<Document>()->images(); + size_t sourceLength = images->length(); + Vector<WebElement> temp; + temp.reserveCapacity(sourceLength); + for (size_t i = 0; i < sourceLength; ++i) { + Node* node = images->item(i); + if (node && node->isHTMLElement()) + temp.append(WebElement(static_cast<Element*>(node))); + } + results.assign(temp); +} + void WebDocument::forms(WebVector<WebFormElement>& results) const { RefPtr<HTMLCollection> forms = const_cast<Document*>(constUnwrap<Document>())->forms(); diff --git a/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp b/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp index 8f7b58a9d..d9cea3bb1 100644 --- a/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp +++ b/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp @@ -27,6 +27,8 @@ #include <public/WebExternalTextureLayer.h> #include "TextureLayerChromium.h" +#include "cc/CCTextureUpdater.h" +#include <public/WebExternalTextureLayerClient.h> #include <public/WebFloatRect.h> #include <public/WebSize.h> @@ -34,13 +36,57 @@ using namespace WebCore; namespace WebKit { -WebExternalTextureLayer WebExternalTextureLayer::create() +class WebTextureUpdaterImpl : public WebTextureUpdater { +public: + explicit WebTextureUpdaterImpl(CCTextureUpdater& updater) + : m_updater(updater) + { + } + + virtual void appendCopy(unsigned sourceTexture, unsigned destinationTexture, WebSize size) OVERRIDE + { + m_updater.appendCopy(sourceTexture, destinationTexture, size); + } + +private: + CCTextureUpdater& m_updater; +}; + +class WebExternalTextureLayerImpl : public TextureLayerChromiumClient, public TextureLayerChromium { +public: + explicit WebExternalTextureLayerImpl(WebExternalTextureLayerClient* client) + : TextureLayerChromium(client ? this : 0) + , m_client(client) + { + } + + virtual unsigned prepareTexture(CCTextureUpdater& updater) OVERRIDE + { + WebTextureUpdaterImpl updaterImpl(updater); + return m_client->prepareTexture(updaterImpl); + } + + virtual WebKit::WebGraphicsContext3D* context() OVERRIDE + { + return m_client->context(); + } + +private: + WebExternalTextureLayerClient* m_client; +}; + +WebExternalTextureLayer WebExternalTextureLayer::create(WebExternalTextureLayerClient* client) { - RefPtr<TextureLayerChromium> layer = TextureLayerChromium::create(0); + RefPtr<TextureLayerChromium> layer = adoptRef(new WebExternalTextureLayerImpl(client)); layer->setIsDrawable(true); return WebExternalTextureLayer(layer.release()); } +void WebExternalTextureLayer::clearClient() +{ + unwrap<TextureLayerChromium>()->clearClient(); +} + void WebExternalTextureLayer::setTextureId(unsigned id) { unwrap<TextureLayerChromium>()->setTextureId(id); @@ -56,6 +102,26 @@ void WebExternalTextureLayer::setUVRect(const WebFloatRect& rect) unwrap<TextureLayerChromium>()->setUVRect(rect); } +void WebExternalTextureLayer::setOpaque(bool opaque) +{ + unwrap<TextureLayerChromium>()->setOpaque(opaque); +} + +void WebExternalTextureLayer::setPremultipliedAlpha(bool premultipliedAlpha) +{ + unwrap<TextureLayerChromium>()->setPremultipliedAlpha(premultipliedAlpha); +} + +void WebExternalTextureLayer::willModifyTexture() +{ + unwrap<TextureLayerChromium>()->willModifyTexture(); +} + +void WebExternalTextureLayer::setRateLimitContext(bool rateLimit) +{ + unwrap<TextureLayerChromium>()->setRateLimitContext(rateLimit); +} + WebExternalTextureLayer::WebExternalTextureLayer(PassRefPtr<TextureLayerChromium> layer) : WebLayer(layer) { diff --git a/Source/WebKit/chromium/src/WebFontImpl.cpp b/Source/WebKit/chromium/src/WebFontImpl.cpp index 8a05aed84..cdb83c214 100644 --- a/Source/WebKit/chromium/src/WebFontImpl.cpp +++ b/Source/WebKit/chromium/src/WebFontImpl.cpp @@ -148,7 +148,7 @@ WebRect WebFontImpl::estimateTextBounds(const WebTextRun& run, const WebFloatPoi { FontCachePurgePreventer fontCachePurgePreventer; int totalWidth = m_font.width(run, 0); - const FontMetrics& fontMetrics = m_font.fontMetrics(); + const WebCore::FontMetrics& fontMetrics = m_font.fontMetrics(); return WebRect(leftBaseline.x - (fontMetrics.ascent() + fontMetrics.descent()) / 2, leftBaseline.y - fontMetrics.ascent() - fontMetrics.lineGap(), totalWidth + fontMetrics.ascent() + fontMetrics.descent(), diff --git a/Source/WebKit/chromium/src/WebFrameImpl.cpp b/Source/WebKit/chromium/src/WebFrameImpl.cpp index fadb8c020..88fd9f61d 100644 --- a/Source/WebKit/chromium/src/WebFrameImpl.cpp +++ b/Source/WebKit/chromium/src/WebFrameImpl.cpp @@ -109,10 +109,12 @@ #include "IconURL.h" #include "InspectorController.h" #include "KURL.h" +#include "MessagePort.h" #include "Node.h" #include "Page.h" #include "PageOverlay.h" #include "Performance.h" +#include "PlatformMessagePortChannel.h" #include "PlatformSupport.h" #include "PluginDocument.h" #include "PrintContext.h" @@ -504,7 +506,6 @@ private: WebPluginContainerImpl* m_plugin; int m_pageCount; WebPrintParams m_printParams; - WebPrintScalingOption m_printScalingOption; }; @@ -1343,6 +1344,24 @@ void WebFrameImpl::requestTextChecking(const WebElement& webElem) frame()->editor()->spellChecker()->requestCheckingFor(SpellCheckRequest::create(TextCheckingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToCheck, rangeToCheck)); } +void WebFrameImpl::replaceMisspelledRange(const WebString& text) +{ + // If this caret selection has two or more markers, this function replace the range covered by the first marker with the specified word as Microsoft Word does. + if (pluginContainerFromFrame(frame())) + return; + RefPtr<Range> caretRange = frame()->selection()->toNormalizedRange(); + if (!caretRange) + return; + Vector<DocumentMarker*> markers = frame()->document()->markers()->markersInRange(caretRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar); + if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset()) + return; + RefPtr<Range> markerRange = TextIterator::rangeFromLocationAndLength(frame()->selection()->rootEditableElementOrDocumentElement(), markers[0]->startOffset(), markers[0]->endOffset() - markers[0]->startOffset()); + if (!markerRange.get() || !frame()->selection()->shouldChangeSelection(markerRange.get())) + return; + frame()->selection()->setSelection(markerRange.get(), CharacterGranularity); + frame()->editor()->replaceSelectionWithText(text, false, true); +} + bool WebFrameImpl::hasSelection() const { WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); @@ -1571,12 +1590,14 @@ bool WebFrameImpl::find(int identifier, { WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); - if (!options.findNext) { + if (!options.findNext) frame()->page()->unmarkAllTextMatches(); - m_activeMatch = 0; - } else + else setMarkerActive(m_activeMatch.get(), false); + if (m_activeMatch && m_activeMatch->ownerDocument() != frame()->document()) + m_activeMatch = 0; + // If the user has selected something since the last Find operation we want // to start from there. Otherwise, we start searching from where the last Find // operation left off (either a Find or a FindNext operation). @@ -1731,44 +1752,41 @@ void WebFrameImpl::scopeStringMatches(int identifier, continue; } - // Only treat the result as a match if it is visible - if (frame()->editor()->insideVisibleArea(resultRange.get())) { - ++matchCount; - - // Catch a special case where Find found something but doesn't know what - // the bounding box for it is. In this case we set the first match we find - // as the active rect. - IntRect resultBounds = resultRange->boundingBox(); - IntRect activeSelectionRect; - if (m_locatingActiveRect) { - activeSelectionRect = m_activeMatch.get() ? - m_activeMatch->boundingBox() : resultBounds; - } + ++matchCount; - // If the Find function found a match it will have stored where the - // match was found in m_activeSelectionRect on the current frame. If we - // find this rect during scoping it means we have found the active - // tickmark. - bool foundActiveMatch = false; - if (m_locatingActiveRect && (activeSelectionRect == resultBounds)) { - // We have found the active tickmark frame. - mainFrameImpl->m_currentActiveMatchFrame = this; - foundActiveMatch = true; - // We also know which tickmark is active now. - m_activeMatchIndexInCurrentFrame = matchCount - 1; - // To stop looking for the active tickmark, we set this flag. - m_locatingActiveRect = false; - - // Notify browser of new location for the selected rectangle. - reportFindInPageSelection( - frameView()->contentsToWindow(resultBounds), - m_activeMatchIndexInCurrentFrame + 1, - identifier); - } + // Catch a special case where Find found something but doesn't know what + // the bounding box for it is. In this case we set the first match we find + // as the active rect. + IntRect resultBounds = resultRange->boundingBox(); + IntRect activeSelectionRect; + if (m_locatingActiveRect) { + activeSelectionRect = m_activeMatch.get() ? + m_activeMatch->boundingBox() : resultBounds; + } - addMarker(resultRange.get(), foundActiveMatch); + // If the Find function found a match it will have stored where the + // match was found in m_activeSelectionRect on the current frame. If we + // find this rect during scoping it means we have found the active + // tickmark. + bool foundActiveMatch = false; + if (m_locatingActiveRect && (activeSelectionRect == resultBounds)) { + // We have found the active tickmark frame. + mainFrameImpl->m_currentActiveMatchFrame = this; + foundActiveMatch = true; + // We also know which tickmark is active now. + m_activeMatchIndexInCurrentFrame = matchCount - 1; + // To stop looking for the active tickmark, we set this flag. + m_locatingActiveRect = false; + + // Notify browser of new location for the selected rectangle. + reportFindInPageSelection( + frameView()->contentsToWindow(resultBounds), + m_activeMatchIndexInCurrentFrame + 1, + identifier); } + addMarker(resultRange.get(), foundActiveMatch); + // Set the new start for the search range to be the end of the previous // result range. There is no need to use a VisiblePosition here, // since findPlainText will use a TextIterator to go over the visible @@ -1901,15 +1919,27 @@ void WebFrameImpl::dispatchMessageEventWithOriginCheck(const WebSecurityOrigin& m_frame->domWindow()->dispatchMessageEventWithOriginCheck(intendedTargetOrigin.get(), event, 0); } -void WebFrameImpl::deliverIntent(const WebIntent& intent, WebDeliveredIntentClient* intentClient) +void WebFrameImpl::deliverIntent(const WebIntent& intent, WebMessagePortChannelArray* ports, WebDeliveredIntentClient* intentClient) { #if ENABLE(WEB_INTENTS) OwnPtr<WebCore::DeliveredIntentClient> client(adoptPtr(new DeliveredIntentClientImpl(intentClient))); - OwnPtr<MessagePortArray> ports; WebSerializedScriptValue intentData = WebSerializedScriptValue::fromString(intent.data()); const WebCore::Intent* webcoreIntent = intent; - RefPtr<DeliveredIntent> deliveredIntent = DeliveredIntent::create(m_frame, client.release(), intent.action(), intent.type(), intentData, ports.release(), webcoreIntent->extras()); + + // See PlatformMessagePortChannel.cpp + OwnPtr<MessagePortChannelArray> channels; + if (ports && ports->size()) { + channels = adoptPtr(new MessagePortChannelArray(ports->size())); + for (size_t i = 0; i < ports->size(); ++i) { + RefPtr<PlatformMessagePortChannel> platformChannel = PlatformMessagePortChannel::create((*ports)[i]); + (*ports)[i]->setClient(platformChannel.get()); + (*channels)[i] = MessagePortChannel::create(platformChannel); + } + } + OwnPtr<MessagePortArray> portArray = WebCore::MessagePort::entanglePorts(*(m_frame->domWindow()->scriptExecutionContext()), channels.release()); + + RefPtr<DeliveredIntent> deliveredIntent = DeliveredIntent::create(m_frame, client.release(), intent.action(), intent.type(), intentData, portArray.release(), webcoreIntent->extras()); DOMWindowIntents::from(m_frame->domWindow())->deliver(deliveredIntent.release()); #endif @@ -1947,18 +1977,6 @@ WebString WebFrameImpl::renderTreeAsText(RenderAsTextControls toShow) const return externalRepresentation(m_frame, behavior); } -WebString WebFrameImpl::counterValueForElementById(const WebString& id) const -{ - if (!m_frame) - return WebString(); - - Element* element = m_frame->document()->getElementById(id); - if (!element) - return WebString(); - - return counterValueForElement(element); -} - WebString WebFrameImpl::markerTextForListItem(const WebElement& webElement) const { return WebCore::markerTextForListItem(const_cast<Element*>(webElement.constUnwrap<Element>())); @@ -2023,6 +2041,7 @@ PassRefPtr<WebFrameImpl> WebFrameImpl::create(WebFrameClient* client) WebFrameImpl::WebFrameImpl(WebFrameClient* client) : m_frameLoaderClient(this) , m_client(client) + , m_frame(0) , m_currentActiveMatchFrame(0) , m_activeMatchIndexInCurrentFrame(-1) , m_locatingActiveRect(false) @@ -2048,9 +2067,9 @@ WebFrameImpl::~WebFrameImpl() cancelPendingScopingEffort(); } -void WebFrameImpl::initializeAsMainFrame(WebViewImpl* webViewImpl) +void WebFrameImpl::initializeAsMainFrame(WebCore::Page* page) { - RefPtr<Frame> frame = Frame::create(webViewImpl->page(), 0, &m_frameLoaderClient); + RefPtr<Frame> frame = Frame::create(page, 0, &m_frameLoaderClient); m_frame = frame.get(); // Add reference on behalf of FrameLoader. See comments in @@ -2209,6 +2228,14 @@ void WebFrameImpl::setFindEndstateFocusAndSelection() // a link focused, which is weird). frame()->selection()->setSelection(m_activeMatch.get()); frame()->document()->setFocusedNode(0); + + // Finally clear the active match, for two reasons: + // We just finished the find 'session' and we don't want future (potentially + // unrelated) find 'sessions' operations to start at the same place. + // The WebFrameImpl could get reused and the m_activeMatch could end up pointing + // to a document that is no longer valid. Keeping an invalid reference around + // is just asking for trouble. + m_activeMatch = 0; } } diff --git a/Source/WebKit/chromium/src/WebFrameImpl.h b/Source/WebKit/chromium/src/WebFrameImpl.h index d8ae6dca6..39937471a 100644 --- a/Source/WebKit/chromium/src/WebFrameImpl.h +++ b/Source/WebKit/chromium/src/WebFrameImpl.h @@ -171,6 +171,7 @@ public: virtual void enableContinuousSpellChecking(bool); virtual bool isContinuousSpellCheckingEnabled() const; virtual void requestTextChecking(const WebElement&); + virtual void replaceMisspelledRange(const WebString&); virtual bool hasSelection() const; virtual WebRange selectionRange() const; virtual WebString selectionAsText() const; @@ -217,12 +218,11 @@ public: const WebSecurityOrigin& intendedTargetOrigin, const WebDOMEvent&); - virtual void deliverIntent(const WebIntent&, WebDeliveredIntentClient*); + virtual void deliverIntent(const WebIntent&, WebMessagePortChannelArray*, WebDeliveredIntentClient*); virtual WebString contentAsText(size_t maxChars) const; virtual WebString contentAsMarkup() const; virtual WebString renderTreeAsText(RenderAsTextControls toShow = RenderAsTextNormal) const; - virtual WebString counterValueForElementById(const WebString& id) const; virtual WebString markerTextForListItem(const WebElement&) const; virtual int pageNumberForElementById(const WebString& id, float pageWidthInPixels, @@ -235,8 +235,8 @@ public: static PassRefPtr<WebFrameImpl> create(WebFrameClient* client); virtual ~WebFrameImpl(); - // Called by the WebViewImpl to initialize its main frame: - void initializeAsMainFrame(WebViewImpl*); + // Called by the WebViewImpl to initialize the main frame for the page. + void initializeAsMainFrame(WebCore::Page*); PassRefPtr<WebCore::Frame> createChildFrame( const WebCore::FrameLoadRequest&, WebCore::HTMLFrameOwnerElement*); diff --git a/Source/WebKit/chromium/src/WebHelperPluginImpl.cpp b/Source/WebKit/chromium/src/WebHelperPluginImpl.cpp new file mode 100644 index 000000000..afa3701aa --- /dev/null +++ b/Source/WebKit/chromium/src/WebHelperPluginImpl.cpp @@ -0,0 +1,255 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebHelperPluginImpl.h" + +#include "DocumentLoader.h" +#include "EmptyClients.h" +#include "FocusController.h" +#include "FrameView.h" +#include "HTMLPlugInElement.h" +#include "NodeList.h" +#include "Page.h" +#include "PageWidgetDelegate.h" +#include "Settings.h" +#include "WebFrameImpl.h" +#include "WebPlugin.h" +#include "WebPluginContainerImpl.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" +#include "WebWidgetClient.h" + +using namespace WebCore; + +namespace WebKit { + +#define addLiteral(literal, writer) writer.addData(literal, sizeof(literal) - 1) + +static inline void addString(const String& str, DocumentWriter& writer) +{ + CString str8 = str.utf8(); + writer.addData(str8.data(), str8.length()); +} + +void writeDocument(WebCore::DocumentWriter& writer, const String& pluginType) +{ + writer.setMIMEType("text/html"); + writer.setEncoding("UTF-8", false); + writer.begin(); + + addLiteral("<!DOCTYPE html><head><meta charset='UTF-8'></head><body>\n", writer); + String objectTag = "<object type=\"" + pluginType + "\"></object>"; + addString(objectTag, writer); + addLiteral("</body>\n", writer); + + writer.end(); +} + +class HelperPluginChromeClient : public EmptyChromeClient { + WTF_MAKE_NONCOPYABLE(HelperPluginChromeClient); + WTF_MAKE_FAST_ALLOCATED; + +public: + explicit HelperPluginChromeClient(WebHelperPluginImpl* widget) + : m_widget(widget) + { + ASSERT(m_widget->m_widgetClient); + } + +private: + virtual void closeWindowSoon() OVERRIDE + { + m_widget->closeHelperPlugin(); + } + + virtual void* webView() const OVERRIDE + { + return m_widget->m_webView; + } + + WebHelperPluginImpl* m_widget; +}; + +// WebHelperPluginImpl ---------------------------------------------------------------- + +WebHelperPluginImpl::WebHelperPluginImpl(WebWidgetClient* client) + : m_widgetClient(client) + , m_webView(0) +{ + ASSERT(client); +} + +WebHelperPluginImpl::~WebHelperPluginImpl() +{ + ASSERT(!m_page); +} + +bool WebHelperPluginImpl::init(WebViewImpl* webView, const String& pluginType) +{ + ASSERT(webView); + m_webView = webView; + + if (!initPage(webView, pluginType)) + return false; + m_widgetClient->show(WebNavigationPolicy()); + + setFocus(true); + + return true; +} + +void WebHelperPluginImpl::closeHelperPlugin() +{ + if (m_page) { + m_page->setGroupName(String()); + m_page->mainFrame()->loader()->stopAllLoaders(); + m_page->mainFrame()->loader()->stopLoading(UnloadEventPolicyNone); + } + // m_widgetClient might be 0 because this widget might be already closed. + if (m_widgetClient) { + // closeWidgetSoon() will call this->close() later. + m_widgetClient->closeWidgetSoon(); + } +} + +void WebHelperPluginImpl::initializeFrame(WebFrameClient* client) +{ + ASSERT(m_page); + RefPtr<WebFrameImpl> frame = WebFrameImpl::create(client); + frame->initializeAsMainFrame(m_page.get()); +} + +// Returns a pointer to the WebPlugin by finding the single <object> tag in the page. +WebPlugin* WebHelperPluginImpl::getPlugin() +{ + ASSERT(m_page); + + RefPtr<NodeList> objectElements = m_page->mainFrame()->document()->getElementsByTagName(WebCore::HTMLNames::objectTag.localName()); + ASSERT(objectElements && objectElements->length() == 1); + if (!objectElements || objectElements->length() < 1) + return 0; + Node* node = objectElements->item(0); + ASSERT(node->hasTagName(WebCore::HTMLNames::objectTag)); + WebCore::Widget* widget = static_cast<HTMLPlugInElement*>(node)->pluginWidget(); + if (!widget) + return 0; + WebPlugin* plugin = static_cast<WebPluginContainerImpl*>(widget)->plugin(); + ASSERT(plugin); + // If the plugin is a placeholder, it is not useful to the caller, and it + // could be replaced at any time. Therefore, do not return it. + if (plugin->isPlaceholder()) + return 0; + + // The plugin was instantiated and will outlive this object. + return plugin; +} + +bool WebHelperPluginImpl::initPage(WebKit::WebViewImpl* webView, const String& pluginType) +{ + Page::PageClients pageClients; + fillWithEmptyClients(pageClients); + m_chromeClient = adoptPtr(new HelperPluginChromeClient(this)); + pageClients.chromeClient = m_chromeClient.get(); + + m_page = adoptPtr(new Page(pageClients)); + // Scripting must be enabled in ScriptController::windowScriptNPObject(). + m_page->settings()->setScriptEnabled(true); + m_page->settings()->setPluginsEnabled(true); + + webView->client()->initializeHelperPluginWebFrame(this); + + // The page's main frame was set in initializeFrame() as a result of the above call. + Frame* frame = m_page->mainFrame(); + ASSERT(frame); + frame->setView(FrameView::create(frame)); + // No need to set a size or make it not transparent. + + DocumentWriter* writer = frame->loader()->activeDocumentLoader()->writer(); + writeDocument(*writer, pluginType); + + return true; +} + +void WebHelperPluginImpl::setCompositorSurfaceReady() +{ +} + +void WebHelperPluginImpl::composite(bool) +{ +} + +void WebHelperPluginImpl::layout() +{ + PageWidgetDelegate::layout(m_page.get()); +} + +void WebHelperPluginImpl::setFocus(bool enable) +{ + if (!m_page) + return; + m_page->focusController()->setFocused(enable); + if (enable) + m_page->focusController()->setActive(true); +} + +void WebHelperPluginImpl::close() +{ + RefPtr<WebFrameImpl> mainFrameImpl; + + if (m_page) { + // Initiate shutdown. This will cause a lot of notifications to be sent. + if (m_page->mainFrame()) { + mainFrameImpl = WebFrameImpl::fromFrame(m_page->mainFrame()); + m_page->mainFrame()->loader()->frameDetached(); + } + m_page.clear(); + } + + m_widgetClient = 0; + deref(); +} + +// WebHelperPlugin ---------------------------------------------------------------- + +WebHelperPlugin* WebHelperPlugin::create(WebWidgetClient* client) +{ + if (!client) + CRASH(); + // A WebHelperPluginImpl instance usually has two references. + // - One owned by the instance itself. It represents the visible widget. + // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the + // WebHelperPluginImpl to close. + // We need them because the closing operation is asynchronous and the widget + // can be closed while the WebViewImpl is unaware of it. + return adoptRef(new WebHelperPluginImpl(client)).leakRef(); +} + +} // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebHelperPluginImpl.h b/Source/WebKit/chromium/src/WebHelperPluginImpl.h new file mode 100644 index 000000000..2eb28ec31 --- /dev/null +++ b/Source/WebKit/chromium/src/WebHelperPluginImpl.h @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebHelperPluginImpl_h +#define WebHelperPluginImpl_h + +#include "WebHelperPlugin.h" +#include <wtf/OwnPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { +class Page; +} + +namespace WebKit { + +class HelperPluginChromeClient; +class WebViewImpl; +class WebWidgetClient; + +// Hosts a simple page that instantiates a plugin using an <object> tag. +// The widget is offscreen, and the plugin will not receive painting, resize, etc. events. +class WebHelperPluginImpl : public WebHelperPlugin, + public RefCounted<WebHelperPluginImpl> { + WTF_MAKE_NONCOPYABLE(WebHelperPluginImpl); + WTF_MAKE_FAST_ALLOCATED; + +public: + virtual ~WebHelperPluginImpl(); + bool init(WebViewImpl*, const String& pluginType); + void closeHelperPlugin(); + + // WebHelperPlugin methods: + virtual void initializeFrame(WebFrameClient*) OVERRIDE; + virtual WebPlugin* getPlugin() OVERRIDE; + +private: + explicit WebHelperPluginImpl(WebWidgetClient*); + bool initPage(WebKit::WebViewImpl*, const String& pluginType); + + // WebWidget methods: + virtual void setCompositorSurfaceReady() OVERRIDE; + virtual void composite(bool) OVERRIDE; + virtual void layout() OVERRIDE; + virtual void setFocus(bool) OVERRIDE; + virtual void close() OVERRIDE; + + WebWidgetClient* m_widgetClient; + WebViewImpl* m_webView; + OwnPtr<WebCore::Page> m_page; + OwnPtr<HelperPluginChromeClient> m_chromeClient; + + friend class WebHelperPlugin; + friend class HelperPluginChromeClient; +}; + +} // namespace WebKit + +#endif // WebHelperPluginImpl_h diff --git a/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp index 4be43dc14..2662f801f 100644 --- a/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp +++ b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp @@ -111,7 +111,7 @@ void WebIDBDatabaseImpl::open(WebIDBDatabaseCallbacks* callbacks) { ASSERT(!m_databaseCallbacks); m_databaseCallbacks = IDBDatabaseCallbacksProxy::create(adoptPtr(callbacks)); - m_databaseBackend->open(m_databaseCallbacks); + m_databaseBackend->registerFrontendCallbacks(m_databaseCallbacks); } } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h index 96571bbe9..190d7e2dc 100644 --- a/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h +++ b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h @@ -59,6 +59,7 @@ public: virtual WebIDBTransaction* transaction(const WebDOMStringList& names, unsigned short mode, WebExceptionCode&); virtual void close(); + // FIXME: Rename "open" to registerFrontendCallbacks. virtual void open(WebIDBDatabaseCallbacks*); private: diff --git a/Source/WebKit/chromium/src/WebIDBKeyPath.cpp b/Source/WebKit/chromium/src/WebIDBKeyPath.cpp index 17c158f34..b094e77bd 100644 --- a/Source/WebKit/chromium/src/WebIDBKeyPath.cpp +++ b/Source/WebKit/chromium/src/WebIDBKeyPath.cpp @@ -37,11 +37,6 @@ using namespace WebCore; namespace WebKit { -WebIDBKeyPath::~WebIDBKeyPath() -{ - m_private.reset(0); -} - WebIDBKeyPath WebIDBKeyPath::create(const WebString& keyPath) { return WebIDBKeyPath(IDBKeyPath(keyPath)); @@ -60,6 +55,17 @@ WebIDBKeyPath WebIDBKeyPath::createNull() return WebIDBKeyPath(IDBKeyPath()); } +void WebIDBKeyPath::assign(const WebIDBKeyPath& keyPath) +{ + ASSERT(keyPath.m_private.get()); + m_private.reset(new IDBKeyPath(keyPath)); +} + +void WebIDBKeyPath::reset() +{ + m_private.reset(0); +} + bool WebIDBKeyPath::isValid() const { ASSERT(m_private.get()); @@ -87,12 +93,6 @@ WebString WebIDBKeyPath::string() const return m_private->string(); } -WebIDBKeyPath::WebIDBKeyPath(const WebIDBKeyPath& keyPath) - : m_private(new IDBKeyPath(keyPath)) -{ - ASSERT(m_private.get()); -} - WebIDBKeyPath::WebIDBKeyPath(const WebCore::IDBKeyPath& value) : m_private(new IDBKeyPath(value)) { diff --git a/Source/WebKit/chromium/src/WebImageLayer.cpp b/Source/WebKit/chromium/src/WebImageLayer.cpp new file mode 100644 index 000000000..93dbf3930 --- /dev/null +++ b/Source/WebKit/chromium/src/WebImageLayer.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include <public/WebImageLayer.h> + +#include "ImageLayerChromium.h" + +namespace WebKit { + +WebImageLayer WebImageLayer::create() +{ + return WebImageLayer(WebCore::ImageLayerChromium::create()); +} + +WebImageLayer::WebImageLayer(PassRefPtr<WebCore::ImageLayerChromium> layer) + : WebLayer(layer) +{ +} + +void WebImageLayer::setBitmap(SkBitmap bitmap) +{ + return unwrap<WebCore::ImageLayerChromium>()->setBitmap(bitmap); +} + +} // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebInputEvent.cpp b/Source/WebKit/chromium/src/WebInputEvent.cpp index e61b4ac65..c0690f8d7 100644 --- a/Source/WebKit/chromium/src/WebInputEvent.cpp +++ b/Source/WebKit/chromium/src/WebInputEvent.cpp @@ -43,27 +43,27 @@ using namespace WebCore; namespace WebKit { -class SameSizeAsWebInputEvent { +struct SameSizeAsWebInputEvent { int inputData[5]; }; -class SameSizeAsWebKeyboardEvent : public SameSizeAsWebInputEvent { +struct SameSizeAsWebKeyboardEvent : public SameSizeAsWebInputEvent { int keyboardData[12]; }; -class SameSizeAsWebMouseEvent : public SameSizeAsWebInputEvent { +struct SameSizeAsWebMouseEvent : public SameSizeAsWebInputEvent { int mouseData[10]; }; -class SameSizeAsWebMouseWheelEvent : public SameSizeAsWebMouseEvent { +struct SameSizeAsWebMouseWheelEvent : public SameSizeAsWebMouseEvent { int mousewheelData[8]; }; -class SameSizeAsWebGestureEvent : public SameSizeAsWebInputEvent { +struct SameSizeAsWebGestureEvent : public SameSizeAsWebInputEvent { int gestureData[6]; }; -class SameSizeAsWebTouchEvent : public SameSizeAsWebInputEvent { +struct SameSizeAsWebTouchEvent : public SameSizeAsWebInputEvent { WebTouchPoint touchPoints[3 * WebTouchEvent::touchesLengthCap]; int touchData[3]; }; diff --git a/Source/WebKit/chromium/src/WebInputEventConversion.cpp b/Source/WebKit/chromium/src/WebInputEventConversion.cpp index 58df5093b..207d81ca3 100644 --- a/Source/WebKit/chromium/src/WebInputEventConversion.cpp +++ b/Source/WebKit/chromium/src/WebInputEventConversion.cpp @@ -123,8 +123,8 @@ PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo if (e.modifiers & WebInputEvent::MetaKey) m_modifiers |= PlatformEvent::MetaKey; -#if OS(DARWIN) m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas; +#if OS(DARWIN) m_phase = static_cast<WebCore::PlatformWheelEventPhase>(e.phase); m_momentumPhase = static_cast<WebCore::PlatformWheelEventPhase>(e.momentumPhase); m_timestamp = e.timeStampSeconds; @@ -159,6 +159,9 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W case WebInputEvent::GestureDoubleTap: m_type = PlatformEvent::GestureDoubleTap; break; + case WebInputEvent::GestureTwoFingerTap: + m_type = PlatformEvent::GestureTwoFingerTap; + break; case WebInputEvent::GestureLongPress: m_type = PlatformEvent::GestureLongPress; break; diff --git a/Source/WebKit/chromium/src/WebIntent.cpp b/Source/WebKit/chromium/src/WebIntent.cpp index 44ce2d0ac..55775ecfc 100644 --- a/Source/WebKit/chromium/src/WebIntent.cpp +++ b/Source/WebKit/chromium/src/WebIntent.cpp @@ -35,20 +35,27 @@ #include "MessagePort.h" #include "PlatformMessagePortChannel.h" #include "SerializedScriptValue.h" +#include "platform/WebSerializedScriptValue.h" #include <wtf/HashMap.h> namespace WebKit { -WebIntent::WebIntent(const WebString& action, const WebString& type, const WebString& data) +WebIntent WebIntent::create(const WebString& action, const WebString& type, const WebString& data, + const WebVector<WebString>& extrasNames, const WebVector<WebString>& extrasValues) { #if ENABLE(WEB_INTENTS) WebCore::ExceptionCode ec = 0; - WebCore::MessagePortArray ports; - RefPtr<WebCore::Intent> intent = WebCore::Intent::create(action, type, WebCore::SerializedScriptValue::createFromWire(data), ports, ec); + WebCore::MessagePortArray dummyPorts; + RefPtr<WebCore::Intent> intent = WebCore::Intent::create(action, type, WebCore::SerializedScriptValue::createFromWire(data), dummyPorts, ec); if (ec) - return; + return WebIntent(); - m_private = intent.release(); + HashMap<String, String> extras; + for (size_t i = 0; i < extrasNames.size() && i < extrasValues.size(); ++i) + extras.add(extrasNames[i], extrasValues[i]); + intent->setExtras(extras); + + return WebIntent(intent.release()); #endif } diff --git a/Source/WebKit/chromium/src/WebKit.cpp b/Source/WebKit/chromium/src/WebKit.cpp index ee999a916..6106597ae 100644 --- a/Source/WebKit/chromium/src/WebKit.cpp +++ b/Source/WebKit/chromium/src/WebKit.cpp @@ -63,6 +63,7 @@ namespace { class EndOfTaskRunner : public WebThread::TaskObserver { public: + virtual void willProcessTask() { } virtual void didProcessTask() { WebCore::WebKitMutationObserver::deliverAllMutations(); diff --git a/Source/WebKit/chromium/src/WebLayerTreeView.cpp b/Source/WebKit/chromium/src/WebLayerTreeView.cpp index 65a2a63b1..47cc88310 100644 --- a/Source/WebKit/chromium/src/WebLayerTreeView.cpp +++ b/Source/WebKit/chromium/src/WebLayerTreeView.cpp @@ -37,20 +37,17 @@ using namespace WebCore; namespace WebKit { -WebLayerTreeView::Settings::operator CCSettings() const + +WebLayerTreeView::Settings::operator CCLayerTreeSettings() const { - CCSettings settings; - settings.acceleratePainting = acceleratePainting; + CCLayerTreeSettings settings; + settings.forceSoftwareCompositing = forceSoftwareCompositing; settings.showFPSCounter = showFPSCounter; settings.showPlatformLayerTree = showPlatformLayerTree; settings.showPaintRects = showPaintRects; settings.refreshRate = refreshRate; - settings.perTilePainting = perTilePainting; - settings.partialSwapEnabled = partialSwapEnabled; - settings.threadedAnimationEnabled = threadedAnimationEnabled; settings.defaultTileSize = defaultTileSize; settings.maxUntiledLayerSize = maxUntiledLayerSize; - settings.deviceScaleFactor = deviceScaleFactor; // FIXME: showFPSCounter / showPlatformLayerTree / maxPartialTextureUpdates aren't supported currently. return settings; @@ -101,11 +98,26 @@ WebSize WebLayerTreeView::viewportSize() const return WebSize(m_private->layerTreeHost()->viewportSize()); } +void WebLayerTreeView::setDeviceScaleFactor(const float deviceScaleFactor) +{ + m_private->layerTreeHost()->setDeviceScaleFactor(deviceScaleFactor); +} + +float WebLayerTreeView::deviceScaleFactor() const +{ + return m_private->layerTreeHost()->deviceScaleFactor(); +} + void WebLayerTreeView::setBackgroundColor(WebColor color) { m_private->layerTreeHost()->setBackgroundColor(color); } +void WebLayerTreeView::setHasTransparentBackground(bool transparent) +{ + m_private->layerTreeHost()->setHasTransparentBackground(transparent); +} + void WebLayerTreeView::setVisible(bool visible) { m_private->layerTreeHost()->setVisible(visible); @@ -161,7 +173,7 @@ void WebLayerTreeView::finishAllRendering() WebGraphicsContext3D* WebLayerTreeView::context() { - return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_private->layerTreeHost()->context()); + return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_private->layerTreeHost()->context()->context3D()); } void WebLayerTreeView::loseCompositorContext(int numTimes) diff --git a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp index 45a99603c..17d5fe867 100644 --- a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp @@ -54,7 +54,7 @@ public: virtual void updateAnimations(double monotonicFrameBeginTime) OVERRIDE { m_client->updateAnimations(monotonicFrameBeginTime); } virtual void layout() OVERRIDE { m_client->layout(); } virtual void applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale) OVERRIDE { m_client->applyScrollAndScale(scrollDelta, pageScale); } - virtual PassRefPtr<WebCore::GraphicsContext3D> createContext() OVERRIDE + virtual PassRefPtr<WebCore::GraphicsContext3D> createContext3D() OVERRIDE { OwnPtr<WebGraphicsContext3D> webContext = adoptPtr(m_client->createContext3D()); if (!webContext) diff --git a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp index 44e51cd87..95186dd86 100644 --- a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp +++ b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp @@ -19,10 +19,10 @@ #include "PlatformContextSkia.h" #include "RenderView.h" #include "TimeRanges.h" -#include "VideoLayerChromium.h" #include "WebAudioSourceProvider.h" #include "WebFrameClient.h" #include "WebFrameImpl.h" +#include "WebHelperPluginImpl.h" #include "WebKit.h" #include "WebMediaPlayer.h" #include "WebViewImpl.h" @@ -96,6 +96,8 @@ WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl() if (m_webMediaPlayer) m_webMediaPlayer->setStreamTextureClient(0); #endif + if (m_helperPlugin) + closeHelperPlugin(); } void WebMediaPlayerClientImpl::networkStateChanged() @@ -265,6 +267,32 @@ void WebMediaPlayerClientImpl::keyNeeded(const WebString& keySystem, const WebSt #endif } +WebPlugin* WebMediaPlayerClientImpl::createHelperPlugin(const WebString& pluginType, WebFrame* frame) +{ + ASSERT(!m_helperPlugin); + WebViewImpl* webView = static_cast<WebViewImpl*>(frame->view()); + m_helperPlugin = webView->createHelperPlugin(pluginType); + if (!m_helperPlugin) + return 0; + + WebPlugin* plugin = m_helperPlugin->getPlugin(); + if (!plugin) { + // There is no need to keep the helper plugin around and the caller + // should not be expected to call close after a failure (null pointer). + closeHelperPlugin(); + return 0; + } + + return plugin; +} + +void WebMediaPlayerClientImpl::closeHelperPlugin() +{ + ASSERT(m_helperPlugin); + m_helperPlugin->closeHelperPlugin(); + m_helperPlugin = 0; +} + void WebMediaPlayerClientImpl::disableAcceleratedCompositing() { m_supportsAcceleratedCompositing = false; @@ -301,7 +329,9 @@ void WebMediaPlayerClientImpl::loadInternal() // Make sure if we create/re-create the WebMediaPlayer that we update our wrapper. m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); #endif - m_webMediaPlayer->load(KURL(ParsedURLString, m_url)); + m_webMediaPlayer->load( + KURL(ParsedURLString, m_url), + static_cast<WebMediaPlayer::CORSMode>(m_mediaPlayer->mediaPlayerClient()->mediaPlayerCORSMode())); } } @@ -312,10 +342,10 @@ void WebMediaPlayerClientImpl::cancelLoad() } #if USE(ACCELERATED_COMPOSITING) -PlatformLayer* WebMediaPlayerClientImpl::platformLayer() const +LayerChromium* WebMediaPlayerClientImpl::platformLayer() const { ASSERT(m_supportsAcceleratedCompositing); - return m_videoLayer.unwrap<VideoLayerChromium>(); + return m_videoLayer.unwrap<LayerChromium>(); } #endif @@ -608,7 +638,7 @@ void WebMediaPlayerClientImpl::paint(GraphicsContext* context, const IntRect& re { #if USE(ACCELERATED_COMPOSITING) // If we are using GPU to render video, ignore requests to paint frames into - // canvas because it will be taken care of by VideoLayerChromium. + // canvas because it will be taken care of by WebVideoLayer. if (acceleratedRenderingInUse()) return; #endif @@ -645,6 +675,13 @@ bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const return false; } +bool WebMediaPlayerClientImpl::didPassCORSAccessCheck() const +{ + if (m_webMediaPlayer) + return m_webMediaPlayer->didPassCORSAccessCheck(); + return false; +} + MediaPlayer::MovieLoadType WebMediaPlayerClientImpl::movieLoadType() const { if (m_webMediaPlayer) diff --git a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h index 0888d5eee..53a24d666 100644 --- a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h +++ b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h @@ -47,6 +47,7 @@ namespace WebCore { class AudioSourceProviderClient; } namespace WebKit { +class WebHelperPluginImpl; class WebAudioSourceProvider; class WebMediaPlayer; @@ -89,6 +90,8 @@ public: virtual void keyError(const WebString& keySystem, const WebString& sessionId, MediaKeyErrorCode, unsigned short systemCode); virtual void keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength); virtual void keyNeeded(const WebString& keySystem, const WebString& sessionId, const unsigned char* initData, unsigned initDataLength); + virtual WebPlugin* createHelperPlugin(const WebString& pluginType, WebFrame*); + virtual void closeHelperPlugin(); virtual void disableAcceleratedCompositing(); // MediaPlayerPrivateInterface methods: @@ -128,6 +131,7 @@ public: virtual void paintCurrentFrameInContext(WebCore::GraphicsContext*, const WebCore::IntRect&); virtual void setPreload(WebCore::MediaPlayer::Preload); virtual bool hasSingleSecurityOrigin() const; + virtual bool didPassCORSAccessCheck() const; virtual WebCore::MediaPlayer::MovieLoadType movieLoadType() const; virtual float mediaTimeForTimeValue(float timeValue) const; virtual unsigned decodedFrameCount() const; @@ -198,6 +202,7 @@ private: String m_url; bool m_delayingLoad; WebCore::MediaPlayer::Preload m_preload; + RefPtr<WebHelperPluginImpl> m_helperPlugin; #if USE(ACCELERATED_COMPOSITING) WebVideoLayer m_videoLayer; bool m_supportsAcceleratedCompositing; diff --git a/Source/WebKit/chromium/src/WebNode.cpp b/Source/WebKit/chromium/src/WebNode.cpp index 69908c9b7..49dcdd98e 100644 --- a/Source/WebKit/chromium/src/WebNode.cpp +++ b/Source/WebKit/chromium/src/WebNode.cpp @@ -153,7 +153,7 @@ bool WebNode::isTextNode() const bool WebNode::isFocusable() const { - m_private->document()->updateLayout(); + m_private->document()->updateLayoutIgnorePendingStylesheets(); return m_private->isFocusable(); } @@ -215,6 +215,7 @@ WebElement WebNode::rootEditableElement() const bool WebNode::hasNonEmptyBoundingBox() const { + m_private->document()->updateLayoutIgnorePendingStylesheets(); return m_private->hasNonEmptyBoundingBox(); } diff --git a/Source/WebKit/chromium/src/WebPagePopupImpl.cpp b/Source/WebKit/chromium/src/WebPagePopupImpl.cpp index 617b725ce..6d59cc19c 100644 --- a/Source/WebKit/chromium/src/WebPagePopupImpl.cpp +++ b/Source/WebKit/chromium/src/WebPagePopupImpl.cpp @@ -32,18 +32,16 @@ #include "WebPagePopupImpl.h" #include "Chrome.h" +#include "ContextFeatures.h" #include "DOMWindowPagePopup.h" +#include "DocumentLoader.h" #include "EmptyClients.h" -#include "FileChooser.h" #include "FocusController.h" -#include "FormState.h" #include "FrameView.h" -#include "HTMLFormElement.h" #include "Page.h" #include "PagePopupClient.h" #include "PageWidgetDelegate.h" #include "Settings.h" -#include "WebInputEvent.h" #include "WebInputEventConversion.h" #include "WebPagePopup.h" #include "WebViewImpl.h" @@ -128,10 +126,17 @@ private: WebPagePopupImpl* m_popup; }; -class PagePopupFrameLoaderClient : public EmptyFrameLoaderClient { - virtual bool allowPagePopup() OVERRIDE { return true; } +class PagePopupFeaturesClient : public ContextFeaturesClient { + virtual bool isEnabled(Document*, ContextFeatures::FeatureType, bool) OVERRIDE; }; +bool PagePopupFeaturesClient::isEnabled(Document*, ContextFeatures::FeatureType type, bool defaultValue) +{ + if (type == ContextFeatures::PagePopup) + return true; + return defaultValue; +} + // WebPagePopupImpl ---------------------------------------------------------------- WebPagePopupImpl::WebPagePopupImpl(WebWidgetClient* client) @@ -186,8 +191,10 @@ bool WebPagePopupImpl::initPage() m_page->settings()->setScriptEnabled(true); m_page->settings()->setAllowScriptsToCloseWindows(true); - static FrameLoaderClient* pagePopupFrameLoaderClient = new PagePopupFrameLoaderClient; - RefPtr<Frame> frame = Frame::create(m_page.get(), 0, pagePopupFrameLoaderClient); + static ContextFeaturesClient* pagePopupFeaturesClient = new PagePopupFeaturesClient(); + provideContextFeaturesTo(m_page.get(), pagePopupFeaturesClient); + static FrameLoaderClient* emptyFrameLoaderClient = new EmptyFrameLoaderClient(); + RefPtr<Frame> frame = Frame::create(m_page.get(), 0, emptyFrameLoaderClient); frame->setView(FrameView::create(frame.get())); frame->init(); frame->view()->resize(m_popupClient->contentSize()); @@ -230,7 +237,7 @@ void WebPagePopupImpl::layout() void WebPagePopupImpl::paint(WebCanvas* canvas, const WebRect& rect) { - PageWidgetDelegate::paint(m_page.get(), 0, canvas, rect); + PageWidgetDelegate::paint(m_page.get(), 0, canvas, rect, PageWidgetDelegate::Opaque); } void WebPagePopupImpl::resize(const WebSize& newSize) @@ -287,6 +294,8 @@ void WebPagePopupImpl::setFocus(bool enable) void WebPagePopupImpl::close() { + if (m_page && m_page->mainFrame()) + m_page->mainFrame()->loader()->frameDetached(); m_page.clear(); m_widgetClient = 0; deref(); diff --git a/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp index 1f0b7668a..ec89930fb 100644 --- a/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp +++ b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp @@ -198,8 +198,12 @@ void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect) if (!m_widget) return; - if (!rect.isEmpty()) - m_widget->paint(&GraphicsContextBuilder(canvas).context(), rect); + if (!rect.isEmpty()) { + GraphicsContextBuilder builder(canvas); + GraphicsContext& context = builder.context(); + context.applyDeviceScaleFactor(m_client->deviceScaleFactor()); + m_widget->paint(&context, rect); + } } void WebPopupMenuImpl::themeChanged() @@ -274,6 +278,7 @@ bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent) case WebInputEvent::GestureTap: case WebInputEvent::GestureTapDown: case WebInputEvent::GestureDoubleTap: + case WebInputEvent::GestureTwoFingerTap: case WebInputEvent::GestureLongPress: case WebInputEvent::GesturePinchBegin: case WebInputEvent::GesturePinchEnd: diff --git a/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp index f6478e4ba..03129c54d 100644 --- a/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp +++ b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp @@ -278,18 +278,11 @@ bool WebRuntimeFeatures::isScriptedSpeechEnabled() void WebRuntimeFeatures::enableXHRResponseBlob(bool enable) { -#if ENABLE(XHR_RESPONSE_BLOB) - RuntimeEnabledFeatures::setXHRResponseBlobEnabled(enable); -#endif } bool WebRuntimeFeatures::isXHRResponseBlobEnabled() { -#if ENABLE(XHR_RESPONSE_BLOB) - return RuntimeEnabledFeatures::xhrResponseBlobEnabled(); -#else - return false; -#endif + return true; } void WebRuntimeFeatures::enableFileSystem(bool enable) @@ -397,7 +390,7 @@ bool WebRuntimeFeatures::isFullScreenAPIEnabled() void WebRuntimeFeatures::enablePointerLock(bool enable) { #if ENABLE(POINTER_LOCK) - RuntimeEnabledFeatures::setWebkitPointerLockEnabled(enable); + RuntimeEnabledFeatures::setPointerLockEnabled(enable); #else UNUSED_PARAM(enable); #endif @@ -406,7 +399,7 @@ void WebRuntimeFeatures::enablePointerLock(bool enable) bool WebRuntimeFeatures::isPointerLockEnabled() { #if ENABLE(POINTER_LOCK) - return RuntimeEnabledFeatures::webkitPointerLockEnabled(); + return RuntimeEnabledFeatures::pointerLockEnabled(); #else return false; #endif diff --git a/Source/WebKit/chromium/src/WebSecurityPolicy.cpp b/Source/WebKit/chromium/src/WebSecurityPolicy.cpp index a14a36dcd..e80061889 100644 --- a/Source/WebKit/chromium/src/WebSecurityPolicy.cpp +++ b/Source/WebKit/chromium/src/WebSecurityPolicy.cpp @@ -68,6 +68,11 @@ void WebSecurityPolicy::registerURLSchemeAsCORSEnabled(const WebString& scheme) SchemeRegistry::registerURLSchemeAsCORSEnabled(scheme); } +void WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(const WebString& scheme) +{ + SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(scheme); +} + void WebSecurityPolicy::registerURLSchemeAsEmptyDocument(const WebString& scheme) { SchemeRegistry::registerURLSchemeAsEmptyDocument(scheme); diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.cpp b/Source/WebKit/chromium/src/WebSettingsImpl.cpp index c51fffbf7..5f8776b58 100644 --- a/Source/WebKit/chromium/src/WebSettingsImpl.cpp +++ b/Source/WebKit/chromium/src/WebSettingsImpl.cpp @@ -47,6 +47,7 @@ namespace WebKit { WebSettingsImpl::WebSettingsImpl(Settings* settings) : m_settings(settings) + , m_forceSoftwareCompositing(false) , m_showFPSCounter(false) , m_showPlatformLayerTree(false) , m_showPaintRects(false) @@ -88,6 +89,11 @@ void WebSettingsImpl::setFantasyFontFamily(const WebString& font, UScriptCode sc m_settings->setFantasyFontFamily(font, script); } +void WebSettingsImpl::setPictographFontFamily(const WebString& font, UScriptCode script) +{ + m_settings->setPictographFontFamily(font, script); +} + void WebSettingsImpl::setDefaultFontSize(int size) { m_settings->setDefaultFontSize(size); @@ -113,19 +119,14 @@ void WebSettingsImpl::setMinimumLogicalFontSize(int size) m_settings->setMinimumLogicalFontSize(size); } -void WebSettingsImpl::setDefaultDeviceScaleFactor(int defaultDeviceScaleFactor) -{ - m_settings->setDefaultDeviceScaleFactor(defaultDeviceScaleFactor); -} - -int WebSettingsImpl::defaultDeviceScaleFactor() +void WebSettingsImpl::setDeviceSupportsTouch(bool deviceSupportsTouch) { - return m_settings->defaultDeviceScaleFactor(); + m_settings->setDeviceSupportsTouch(deviceSupportsTouch); } -void WebSettingsImpl::setDeviceSupportsTouch(bool deviceSupportsTouch) +void WebSettingsImpl::setDeviceSupportsMouse(bool deviceSupportsMouse) { - m_settings->setDeviceSupportsTouch(deviceSupportsTouch); + m_settings->setDeviceSupportsMouse(deviceSupportsMouse); } bool WebSettingsImpl::deviceSupportsTouch() @@ -388,6 +389,11 @@ void WebSettingsImpl::setForceCompositingMode(bool enabled) m_settings->setForceCompositingMode(enabled); } +void WebSettingsImpl::setForceSoftwareCompositing(bool enabled) +{ + m_forceSoftwareCompositing = enabled; +} + void WebSettingsImpl::setMockScrollbarsEnabled(bool enabled) { m_settings->setMockScrollbarsEnabled(enabled); @@ -586,21 +592,6 @@ void WebSettingsImpl::setAcceleratedPaintingEnabled(bool enabled) m_settings->setAcceleratedDrawingEnabled(enabled); } -void WebSettingsImpl::setPerTilePaintingEnabled(bool enabled) -{ - m_settings->setPerTileDrawingEnabled(enabled); -} - -void WebSettingsImpl::setPartialSwapEnabled(bool enabled) -{ - m_settings->setPartialSwapEnabled(enabled); -} - -void WebSettingsImpl::setThreadedAnimationEnabled(bool enabled) -{ - m_settings->setThreadedAnimationEnabled(enabled); -} - void WebSettingsImpl::setMediaPlaybackRequiresUserGesture(bool required) { m_settings->setMediaPlaybackRequiresUserGesture(required); diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.h b/Source/WebKit/chromium/src/WebSettingsImpl.h index c28908441..2b58c0443 100644 --- a/Source/WebKit/chromium/src/WebSettingsImpl.h +++ b/Source/WebKit/chromium/src/WebSettingsImpl.h @@ -50,16 +50,16 @@ public: virtual void setSansSerifFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON); virtual void setCursiveFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON); virtual void setFantasyFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON); + virtual void setPictographFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON); virtual void setDefaultFontSize(int); virtual void setDefaultFixedFontSize(int); virtual void setMinimumFontSize(int); virtual void setMinimumLogicalFontSize(int); - virtual void setDefaultDeviceScaleFactor(int); - virtual int defaultDeviceScaleFactor(); virtual void setApplyDefaultDeviceScaleFactorInCompositor(bool); virtual void setFontBoostingEnabled(bool); virtual void setDefaultTextEncodingName(const WebString&); virtual void setDeviceSupportsTouch(bool); + virtual void setDeviceSupportsMouse(bool); virtual bool deviceSupportsTouch(); virtual void setJavaScriptEnabled(bool); virtual void setWebSecurityEnabled(bool); @@ -109,6 +109,7 @@ public: virtual void setEditingBehavior(EditingBehavior); virtual void setAcceleratedCompositingEnabled(bool); virtual void setForceCompositingMode(bool); + virtual void setForceSoftwareCompositing(bool); virtual void setMockScrollbarsEnabled(bool); virtual void setAcceleratedCompositingFor3DTransformsEnabled(bool); virtual void setAcceleratedCompositingForVideoEnabled(bool); @@ -143,9 +144,6 @@ public: virtual void setShouldDisplayCaptions(bool); virtual void setShouldDisplayTextDescriptions(bool); virtual void setAcceleratedPaintingEnabled(bool); - virtual void setPerTilePaintingEnabled(bool); - virtual void setPartialSwapEnabled(bool); - virtual void setThreadedAnimationEnabled(bool); virtual void setFixedPositionCreatesStackingContext(bool); virtual void setViewportEnabled(bool); virtual void setMediaPlaybackRequiresUserGesture(bool); @@ -158,9 +156,11 @@ public: bool applyDefaultDeviceScaleFactorInCompositor() const { return m_applyDefaultDeviceScaleFactorInCompositor; } WebSize defaultTileSize() const { return m_defaultTileSize; } WebSize maxUntiledLayerSize() const { return m_maxUntiledLayerSize; } + virtual bool forceSoftwareCompositing() const { return m_forceSoftwareCompositing; } private: WebCore::Settings* m_settings; + bool m_forceSoftwareCompositing; bool m_showFPSCounter; bool m_showPlatformLayerTree; bool m_showPaintRects; diff --git a/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp b/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp index 301c75e36..e44a1b434 100644 --- a/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp +++ b/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp @@ -46,7 +46,6 @@ #include "WebFileError.h" #include "WebFrameClient.h" #include "WebFrameImpl.h" -#include "WebMessagePortChannel.h" #include "WebRuntimeFeatures.h" #include "WebSettings.h" #include "WebSharedWorkerClient.h" @@ -56,8 +55,9 @@ #include "WorkerInspectorController.h" #include "WorkerLoaderProxy.h" #include "WorkerThread.h" -#include "platform/WebString.h" -#include "platform/WebURL.h" +#include <public/WebMessagePortChannel.h> +#include <public/WebString.h> +#include <public/WebURL.h> #include <wtf/MainThread.h> using namespace WebCore; diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index dacfa152e..67b7c041e 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -41,6 +41,7 @@ #include "Color.h" #include "ColorSpace.h" #include "CompositionUnderlineVectorBuilder.h" +#include "ContextFeaturesClientImpl.h" #include "ContextMenu.h" #include "ContextMenuController.h" #include "ContextMenuItem.h" @@ -127,6 +128,7 @@ #include "WebDevToolsAgentImpl.h" #include "WebDevToolsAgentPrivate.h" #include "WebFrameImpl.h" +#include "WebHelperPluginImpl.h" #include "WebInputElement.h" #include "WebInputEvent.h" #include "WebInputEventConversion.h" @@ -145,6 +147,7 @@ #include "WebViewClient.h" #include "WheelEvent.h" #include "cc/CCProxy.h" +#include "cc/CCSettings.h" #include "painting/GraphicsContextBuilder.h" #include "platform/WebKitPlatformSupport.h" #include "platform/WebString.h" @@ -308,13 +311,18 @@ void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient) // and releases that reference once the corresponding Frame is destroyed. RefPtr<WebFrameImpl> frame = WebFrameImpl::create(frameClient); - frame->initializeAsMainFrame(this); + frame->initializeAsMainFrame(page()); // Restrict the access to the local file system // (see WebView.mm WebView::_commonInitializationWithFrameName). SecurityPolicy::setLocalLoadPolicy(SecurityPolicy::AllowLocalLoadsForLocalOnly); } +void WebViewImpl::initializeHelperPluginFrame(WebFrameClient* client) +{ + RefPtr<WebFrameImpl> frame = WebFrameImpl::create(client); +} + void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient) { m_autofillClient = autofillClient; @@ -331,6 +339,7 @@ void WebViewImpl::setDevToolsAgentClient(WebDevToolsAgentClient* devToolsClient) void WebViewImpl::setPermissionClient(WebPermissionClient* permissionClient) { m_permissionClient = permissionClient; + m_featureSwitchClient->setPermissionClient(permissionClient); } void WebViewImpl::setPrerendererClient(WebPrerendererClient* prerendererClient) @@ -386,6 +395,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) , m_imeAcceptEvents(true) , m_operationsAllowed(WebDragOperationNone) , m_dragOperation(WebDragOperationNone) + , m_featureSwitchClient(adoptPtr(new ContextFeaturesClientImpl())) , m_autofillPopupShowing(false) , m_autofillPopup(0) , m_isTransparent(false) @@ -445,6 +455,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) provideNotification(m_page.get(), notificationPresenterImpl()); #endif + provideContextFeaturesTo(m_page.get(), m_featureSwitchClient.get()); provideDeviceOrientationTo(m_page.get(), m_deviceOrientationClientProxy.get()); provideGeolocationTo(m_page.get(), m_geolocationClientProxy.get()); m_geolocationClientProxy->setController(GeolocationController::from(m_page.get())); @@ -452,7 +463,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) #if ENABLE(BATTERY_STATUS) provideBatteryTo(m_page.get(), m_batteryClient.get()); #endif - + m_page->setGroupName(pageGroupName); #if ENABLE(PAGE_VISIBILITY_API) @@ -676,6 +687,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) } return gestureHandled; } + case WebInputEvent::GestureTwoFingerTap: case WebInputEvent::GestureLongPress: { if (!mainFrameImpl() || !mainFrameImpl()->frameView()) return false; @@ -1265,6 +1277,19 @@ void WebViewImpl::hideAutofillPopup() } } +WebHelperPluginImpl* WebViewImpl::createHelperPlugin(const String& pluginType) +{ + WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypeHelperPlugin); + ASSERT(popupWidget); + WebHelperPluginImpl* helperPlugin = static_cast<WebHelperPluginImpl*>(popupWidget); + + if (!helperPlugin->init(this, pluginType)) { + helperPlugin->closeHelperPlugin(); + helperPlugin = 0; + } + return helperPlugin; +} + Frame* WebViewImpl::focusedWebCoreFrame() const { return m_page ? m_page->focusController()->focusedOrMainFrame() : 0; @@ -1547,7 +1572,7 @@ void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) #endif } else { double paintStart = currentTime(); - PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect); + PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTransparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque); double paintEnd = currentTime(); double pixelsPerSec = (rect.width * rect.height) / (paintEnd - paintStart); WebKit::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30); @@ -2461,6 +2486,10 @@ void WebViewImpl::setDeviceScaleFactor(float scaleFactor) // needs to match the one in the compositor. ASSERT(scaleFactor == m_deviceScaleInCompositor); } + if (!m_layerTreeView.isNull() && m_webSettings->applyDefaultDeviceScaleFactorInCompositor()) { + m_deviceScaleInCompositor = page()->deviceScaleFactor(); + m_layerTreeView.setDeviceScaleFactor(m_deviceScaleInCompositor); + } } bool WebViewImpl::isFixedLayoutModeEnabled() const @@ -2956,9 +2985,6 @@ void WebViewImpl::applyAutofillSuggestions( if (!m_autofillPopup) { PopupContainerSettings popupSettings = autofillPopupSettings; - popupSettings.defaultDeviceScaleFactor = settingsImpl()->defaultDeviceScaleFactor(); - if (!popupSettings.defaultDeviceScaleFactor) - popupSettings.defaultDeviceScaleFactor = 1; popupSettings.deviceSupportsTouch = settingsImpl()->deviceSupportsTouch(); m_autofillPopup = PopupContainer::create(m_autofillPopupClient.get(), PopupContainer::Suggestion, @@ -3009,6 +3035,12 @@ void WebViewImpl::setIsTransparent(bool isTransparent) // Future frames check this to know whether to be transparent. m_isTransparent = isTransparent; + + if (m_nonCompositedContentHost) + m_nonCompositedContentHost->setOpaque(!isTransparent); + + if (!m_layerTreeView.isNull()) + m_layerTreeView.setHasTransparentBackground(isTransparent); } bool WebViewImpl::isTransparent() const @@ -3387,38 +3419,20 @@ void WebViewImpl::scheduleAnimation() } #endif -class WebViewImplContentPainter : public LayerPainterChromium { - WTF_MAKE_NONCOPYABLE(WebViewImplContentPainter); -public: - static PassOwnPtr<WebViewImplContentPainter*> create(WebViewImpl* webViewImpl) - { - return adoptPtr(new WebViewImplContentPainter(webViewImpl)); - } - - virtual void paint(GraphicsContext& context, const IntRect& contentRect) - { - double paintStart = currentTime(); - Page* page = m_webViewImpl->page(); - if (!page) - return; - FrameView* view = page->mainFrame()->view(); - view->paintContents(&context, contentRect); - double paintEnd = currentTime(); - double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintEnd - paintStart); - WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelRootPaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30); - WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelRootPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30); - - m_webViewImpl->setBackgroundColor(view->documentBackgroundColor()); - } - -private: - explicit WebViewImplContentPainter(WebViewImpl* webViewImpl) - : m_webViewImpl(webViewImpl) - { - } +void WebViewImpl::paintRootLayer(GraphicsContext& context, const IntRect& contentRect) +{ + double paintStart = currentTime(); + if (!page()) + return; + FrameView* view = page()->mainFrame()->view(); + view->paintContents(&context, contentRect); + double paintEnd = currentTime(); + double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintEnd - paintStart); + WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelRootPaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30); + WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelRootPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30); - WebViewImpl* m_webViewImpl; -}; + setBackgroundColor(view->documentBackgroundColor()); +} void WebViewImpl::setIsAcceleratedCompositingActive(bool active) { @@ -3447,33 +3461,28 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) layerTreeViewSettings.showFPSCounter = settingsImpl()->showFPSCounter(); layerTreeViewSettings.showPlatformLayerTree = settingsImpl()->showPlatformLayerTree(); layerTreeViewSettings.showPaintRects = settingsImpl()->showPaintRects(); - - layerTreeViewSettings.perTilePainting = page()->settings()->perTileDrawingEnabled(); - layerTreeViewSettings.partialSwapEnabled = page()->settings()->partialSwapEnabled(); - layerTreeViewSettings.threadedAnimationEnabled = page()->settings()->threadedAnimationEnabled(); + layerTreeViewSettings.forceSoftwareCompositing = settings()->forceSoftwareCompositing(); layerTreeViewSettings.defaultTileSize = settingsImpl()->defaultTileSize(); layerTreeViewSettings.maxUntiledLayerSize = settingsImpl()->maxUntiledLayerSize(); - m_nonCompositedContentHost = NonCompositedContentHost::create(WebViewImplContentPainter::create(this)); + m_nonCompositedContentHost = NonCompositedContentHost::create(this); m_nonCompositedContentHost->setShowDebugBorders(page()->settings()->showDebugBorders()); - - if (m_webSettings->applyDefaultDeviceScaleFactorInCompositor() && page()->settings()->defaultDeviceScaleFactor() != 1) { - ASSERT(page()->settings()->defaultDeviceScaleFactor()); - - m_deviceScaleInCompositor = page()->settings()->defaultDeviceScaleFactor(); - layerTreeViewSettings.deviceScaleFactor = m_deviceScaleInCompositor; - setDeviceScaleFactor(m_deviceScaleInCompositor); - // When applying a scale factor in the compositor, we disallow page - // scaling as they are currently incompatible. - setPageScaleFactorLimits(1, 1); - } + m_nonCompositedContentHost->setOpaque(!isTransparent()); m_layerTreeView.initialize(this, m_rootLayer, layerTreeViewSettings); if (!m_layerTreeView.isNull()) { + if (m_webSettings->applyDefaultDeviceScaleFactorInCompositor() && page()->deviceScaleFactor() != 1) { + ASSERT(page()->deviceScaleFactor()); + + m_deviceScaleInCompositor = page()->deviceScaleFactor(); + setDeviceScaleFactor(m_deviceScaleInCompositor); + } + m_layerTreeView.setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor); if (m_compositorSurfaceReady) m_layerTreeView.setSurfaceReady(); + m_layerTreeView.setHasTransparentBackground(isTransparent()); updateLayerTreeViewport(); m_client->didActivateCompositor(m_layerTreeView.compositorIdentifier()); m_isAcceleratedCompositingActive = true; @@ -3495,6 +3504,9 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) PassOwnPtr<WebKit::WebGraphicsContext3D> WebViewImpl::createCompositorGraphicsContext3D() { + if (settings()->forceSoftwareCompositing()) + CRASH(); + // Explicitly disable antialiasing for the compositor. As of the time of // this writing, the only platform that supported antialiasing for the // compositor was Mac OS X, because the on-screen OpenGL context creation @@ -3518,6 +3530,9 @@ PassOwnPtr<WebKit::WebGraphicsContext3D> WebViewImpl::createCompositorGraphicsCo WebKit::WebGraphicsContext3D* WebViewImpl::createContext3D() { + if (settings()->forceSoftwareCompositing()) + CRASH(); + OwnPtr<WebKit::WebGraphicsContext3D> webContext; // If we've already created an onscreen context for this view, return that. @@ -3609,15 +3624,10 @@ void WebViewImpl::updateLayerTreeViewport() IntRect visibleRect = view->visibleContentRect(true /* include scrollbars */); IntPoint scroll(view->scrollX(), view->scrollY()); - // In RTL-style pages, the origin of the initial containing block for the - // root layer may be positive; translate the layer to avoid negative - // coordinates. - int layerAdjustX = -view->scrollOrigin().x(); - // This part of the deviceScale will be used to scale the contents of // the NCCH's GraphicsLayer. float deviceScale = m_deviceScaleInCompositor; - m_nonCompositedContentHost->setViewport(visibleRect.size(), view->contentsSize(), scroll, deviceScale, layerAdjustX); + m_nonCompositedContentHost->setViewport(visibleRect.size(), view->contentsSize(), scroll, view->scrollOrigin(), deviceScale); m_layerTreeView.setViewportSize(size()); m_layerTreeView.setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor); diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h index 67562feab..4f5c048d9 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.h +++ b/Source/WebKit/chromium/src/WebViewImpl.h @@ -86,10 +86,12 @@ namespace WebKit { class AutocompletePopupMenuClient; class AutofillPopupMenuClient; class BatteryClientImpl; +class ContextFeaturesClientImpl; class ContextMenuClientImpl; class DeviceOrientationClientProxy; class DragScrollTimer; class GeolocationClientProxy; +class WebHelperPluginImpl; class NonCompositedContentHost; class PrerendererClientImpl; class SpeechInputClientImpl; @@ -162,6 +164,7 @@ public: // WebView methods: virtual void initializeMainFrame(WebFrameClient*); + virtual void initializeHelperPluginFrame(WebFrameClient*); virtual void setAutofillClient(WebAutofillClient*); virtual void setDevToolsAgentClient(WebDevToolsAgentClient*); virtual void setPermissionClient(WebPermissionClient*); @@ -488,6 +491,8 @@ public: void hideAutofillPopup(); + WebHelperPluginImpl* createHelperPlugin(const String& pluginType); + // Returns the input event we're currently processing. This is used in some // cases where the WebCore DOM event doesn't have the information we need. static const WebInputEvent* currentInputEvent() @@ -501,6 +506,7 @@ public: void scheduleCompositingLayerSync(); void scrollRootLayerRect(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& clipRect); void invalidateRootLayerRect(const WebCore::IntRect&); + void paintRootLayer(WebCore::GraphicsContext&, const WebCore::IntRect& contentRect); NonCompositedContentHost* nonCompositedContentHost(); void setBackgroundColor(const WebCore::Color&); #endif @@ -729,6 +735,9 @@ private: // current drop target in this WebView (the drop target can accept the drop). WebDragOperation m_dragOperation; + // Context-based feature switches. + OwnPtr<ContextFeaturesClientImpl> m_featureSwitchClient; + // Whether an Autofill popup is currently showing. bool m_autofillPopupShowing; diff --git a/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp b/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp index 09021ef44..7a387c7ed 100644 --- a/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp +++ b/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp @@ -191,6 +191,7 @@ void WorkerAsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL PassRefPtr<WorkerFileSystemCallbacksBridge> WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks> callbacks) { ASSERT(m_synchronousType == AsynchronousFileSystem || !m_bridgeForCurrentOperation); + (void)m_synchronousType; m_modeForCurrentOperation = fileSystemOperationsMode; m_modeForCurrentOperation.append(String::number(m_workerContext->thread()->runLoop().createUniqueId())); diff --git a/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.cpp b/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.cpp index 6d62098a6..e127cfc6d 100644 --- a/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.cpp +++ b/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.cpp @@ -51,9 +51,8 @@ using namespace WebKit; namespace WebCore { WorkerAsyncFileWriterChromium::WorkerAsyncFileWriterChromium(WebFileSystem* webFileSystem, const WebURL& path, WorkerContext* workerContext, AsyncFileWriterClient* client, WriterType type) - : m_type(type) { - ASSERT(m_type == Asynchronous); // Synchronous is not implemented yet. + ASSERT(type == Asynchronous); // Synchronous is not implemented yet. WorkerLoaderProxy* proxy = &workerContext->thread()->workerLoaderProxy(); m_bridge = WorkerFileWriterCallbacksBridge::create(path, proxy, workerContext, client); diff --git a/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.h b/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.h index 86e6517fa..2408a022a 100644 --- a/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.h +++ b/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.h @@ -79,7 +79,6 @@ private: WorkerAsyncFileWriterChromium(WebKit::WebFileSystem*, const WebKit::WebURL& path, WorkerContext*, AsyncFileWriterClient*, WriterType); RefPtr<WebKit::WorkerFileWriterCallbacksBridge> m_bridge; - WriterType m_type; }; } // namespace diff --git a/Source/WebKit/chromium/src/js/DevTools.js b/Source/WebKit/chromium/src/js/DevTools.js index c4d54238d..ffea8af86 100644 --- a/Source/WebKit/chromium/src/js/DevTools.js +++ b/Source/WebKit/chromium/src/js/DevTools.js @@ -41,6 +41,8 @@ Preferences.exposeDisableCache = true; Preferences.exposeWorkersInspection = true; Preferences.showDockToRight = true; + Preferences.exposeFileSystemInspection = true; + Preferences.displayInitiator = true; })();} function buildPlatformExtensionAPI(extensionInfo) diff --git a/Source/WebKit/chromium/src/linux/WebFontInfo.cpp b/Source/WebKit/chromium/src/linux/WebFontInfo.cpp index b23b77789..327af40c9 100644 --- a/Source/WebKit/chromium/src/linux/WebFontInfo.cpp +++ b/Source/WebKit/chromium/src/linux/WebFontInfo.cpp @@ -39,6 +39,13 @@ namespace WebKit { +static bool useSubpixelPositioning = false; + +void WebFontInfo::setSubpixelPositioning(bool subpixelPositioning) +{ + useSubpixelPositioning = subpixelPositioning; +} + void WebFontInfo::familyForChars(const WebUChar* characters, size_t numCharacters, const char* preferredLocale, WebFontFamily* family) { FcCharSet* cset = FcCharSetCreate(); @@ -185,21 +192,25 @@ void WebFontInfo::renderStyleForStrike(const char* family, int sizeAndStyle, Web if (FcPatternGetInteger(match, FC_RGBA, 0, &i) == FcResultMatch) { switch (i) { case FC_RGBA_NONE: - out->useSubpixel = 0; + out->useSubpixelRendering = 0; break; case FC_RGBA_RGB: case FC_RGBA_BGR: case FC_RGBA_VRGB: case FC_RGBA_VBGR: - out->useSubpixel = 1; + out->useSubpixelRendering = 1; break; default: // This includes FC_RGBA_UNKNOWN. - out->useSubpixel = 2; + out->useSubpixelRendering = 2; break; } } + // FontConfig doesn't provide parameters to configure whether subpixel + // positioning should be used or not, so we just use a global setting. + out->useSubpixelPositioning = useSubpixelPositioning; + FcPatternDestroy(match); } diff --git a/Source/WebKit/chromium/src/linux/WebFontRenderStyle.cpp b/Source/WebKit/chromium/src/linux/WebFontRenderStyle.cpp index 0b864d1b1..0edf8410e 100644 --- a/Source/WebKit/chromium/src/linux/WebFontRenderStyle.cpp +++ b/Source/WebKit/chromium/src/linux/WebFontRenderStyle.cpp @@ -44,7 +44,8 @@ void WebFontRenderStyle::toFontRenderStyle(FontRenderStyle* out) out->useHinting = useHinting; out->hintStyle = hintStyle; out->useAntiAlias = useAntiAlias; - out->useSubpixel = useSubpixel; + out->useSubpixelRendering = useSubpixelRendering; + out->useSubpixelPositioning = useSubpixelPositioning; } void WebFontRenderStyle::setDefaults() @@ -54,7 +55,8 @@ void WebFontRenderStyle::setDefaults() useHinting = 2; hintStyle = 0; useAntiAlias = 2; - useSubpixel = 2; + useSubpixelRendering = 2; + useSubpixelPositioning = 2; } } // namespace WebKit diff --git a/Source/WebKit/chromium/src/linux/WebFontRendering.cpp b/Source/WebKit/chromium/src/linux/WebFontRendering.cpp index b9862f58b..7dc98e667 100644 --- a/Source/WebKit/chromium/src/linux/WebFontRendering.cpp +++ b/Source/WebKit/chromium/src/linux/WebFontRendering.cpp @@ -33,6 +33,10 @@ #include "FontPlatformData.h" +#if OS(LINUX) +#include "WebFontInfo.h" +#endif + using WebCore::FontPlatformData; namespace WebKit { @@ -44,15 +48,36 @@ void WebFontRendering::setHinting(SkPaint::Hinting hinting) } // static -void WebFontRendering::setAntiAlias(bool isAntiAlias) +void WebFontRendering::setAutoHint(bool useAutoHint) +{ + FontPlatformData::setAutoHint(useAutoHint); +} + +// static +void WebFontRendering::setUseBitmaps(bool useBitmaps) +{ + FontPlatformData::setUseBitmaps(useBitmaps); +} + +// static +void WebFontRendering::setAntiAlias(bool useAntiAlias) +{ + FontPlatformData::setAntiAlias(useAntiAlias); +} + +// static +void WebFontRendering::setSubpixelRendering(bool useSubpixelRendering) { - FontPlatformData::setAntiAlias(isAntiAlias); + FontPlatformData::setSubpixelRendering(useSubpixelRendering); } // static -void WebFontRendering::setSubpixelGlyphs(bool isSubpixelGlyphs) +void WebFontRendering::setSubpixelPositioning(bool useSubpixelPositioning) { - FontPlatformData::setSubpixelGlyphs(isSubpixelGlyphs); + FontPlatformData::setSubpixelPositioning(useSubpixelPositioning); +#if OS(LINUX) + WebFontInfo::setSubpixelPositioning(useSubpixelPositioning); +#endif } // static diff --git a/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm b/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm index b9fdc141c..88c3b72e5 100644 --- a/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm +++ b/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm @@ -35,6 +35,14 @@ #include "WebScreenInfo.h" +@interface NSWindow (LionAPI) +- (CGFloat)backingScaleFactor; +@end + +@interface NSScreen (LionAPI) +- (CGFloat)backingScaleFactor; +@end + namespace WebKit { static NSScreen* screenForWindow(NSWindow* window) @@ -50,40 +58,46 @@ static NSScreen* screenForWindow(NSWindow* window) return nil; } -static WebRect toUserSpace(const NSRect& rect, NSWindow* destination) +static WebRect convertRect(const NSRect& rect, NSWindow* destination) { CGRect userRect = NSRectToCGRect(rect); - userRect.origin.y = - NSMaxY([screenForWindow(destination) frame]) - (userRect.origin.y + userRect.size.height); // flip - - if (destination) { - CGFloat scale = 1 / [destination userSpaceScaleFactor]; // scale down - userRect.origin.x *= scale; - userRect.origin.y *= scale; - userRect.size.width *= scale; - userRect.size.height *= scale; - } - + NSMaxY([screenForWindow(destination) frame]) - NSMaxY(rect); // flip return WebRect(userRect.origin.x, userRect.origin.y, userRect.size.width, userRect.size.height); } +static float deviceScaleFactor(NSView* view) +{ + NSWindow* window = [view window]; + if (window) + { + if ([window respondsToSelector:@selector(backingScaleFactor)]) + return [window backingScaleFactor]; + return [window userSpaceScaleFactor]; + } + + NSArray* screens = [NSScreen screens]; + if (![screens count]) + return 1; + + NSScreen* screen = [screens objectAtIndex:0]; + if ([screen respondsToSelector:@selector(backingScaleFactor)]) + return [screen backingScaleFactor]; + return [screen userSpaceScaleFactor]; +} + WebScreenInfo WebScreenInfoFactory::screenInfo(NSView* view) { NSString *colorSpace = NSColorSpaceFromDepth([[NSScreen deepestScreen] depth]); WebScreenInfo results; - // FIXME: Currently Mac seems to always report 72dpi. Need to find a way to - // report the true screen dpi. - NSWindow* window = [view window]; - NSDictionary* deviceDescription = [window deviceDescription]; - NSSize deviceDPI = [[deviceDescription valueForKey:NSDeviceResolution] sizeValue]; - results.horizontalDPI = static_cast<int>(deviceDPI.width); - results.verticalDPI = static_cast<int>(deviceDPI.height); + float deviceDPI = 160 * deviceScaleFactor(view); + results.horizontalDPI = deviceDPI; + results.verticalDPI = deviceDPI; results.depth = NSBitsPerPixelFromDepth([[NSScreen deepestScreen] depth]); @@ -93,10 +107,9 @@ WebScreenInfo WebScreenInfoFactory::screenInfo(NSView* view) || colorSpace == NSCalibratedBlackColorSpace || colorSpace == NSDeviceWhiteColorSpace || colorSpace == NSDeviceBlackColorSpace; - results.rect = - toUserSpace([screenForWindow([view window]) frame], [view window]); + results.rect = convertRect([screenForWindow([view window]) frame], [view window]); results.availableRect = - toUserSpace([screenForWindow([view window]) visibleFrame], [view window]); + convertRect([screenForWindow([view window]) visibleFrame], [view window]); return results; } |