diff options
Diffstat (limited to 'Source/WebKit/chromium/src')
32 files changed, 777 insertions, 963 deletions
diff --git a/Source/WebKit/chromium/src/FindInPageCoordinates.cpp b/Source/WebKit/chromium/src/FindInPageCoordinates.cpp index b00a30c23..643848868 100644 --- a/Source/WebKit/chromium/src/FindInPageCoordinates.cpp +++ b/Source/WebKit/chromium/src/FindInPageCoordinates.cpp @@ -38,6 +38,7 @@ #include "IntPoint.h" #include "Node.h" #include "Range.h" +#include "RenderBlock.h" #include "RenderBox.h" #include "RenderObject.h" #include "RenderPart.h" @@ -48,39 +49,32 @@ using namespace WebCore; namespace WebKit { -static FloatRect toNormalizedRect(const FloatRect& absoluteRect, const RenderObject* renderer, FloatRect& containerBoundingBox) +static FloatRect toNormalizedRect(const FloatRect& absoluteRect, const RenderObject* renderer) { ASSERT(renderer); - const RenderObject* container = renderer->container(); - if (!container) { - containerBoundingBox = FloatRect(); + const RenderBlock* container = renderer->containingBlock(); + ASSERT(container || renderer->isRenderView()); + if (!container) return FloatRect(); - } - - FloatRect normalizedRect = absoluteRect; - FloatRect containerRect = container->absoluteBoundingBoxRect(); - containerBoundingBox = containerRect; - // For RenderBoxes we want to normalize by the max layout overflow size instead of only the visible bounding box. + // We want to normalize by the max layout overflow size instead of only the visible bounding box. // Quads and their enclosing bounding boxes need to be used in order to keep results transform-friendly. - if (container->isBox()) { - const RenderBox* containerBox = toRenderBox(container); - FloatPoint scrolledOrigin; + FloatPoint scrolledOrigin; - // For overflow:scroll we need to get where the actual origin is independently of the scroll. - if (container->hasOverflowClip()) - scrolledOrigin = -IntPoint(containerBox->scrolledContentOffset()); + // For overflow:scroll we need to get where the actual origin is independently of the scroll. + if (container->hasOverflowClip()) + scrolledOrigin = -IntPoint(container->scrolledContentOffset()); - FloatRect overflowRect(scrolledOrigin, containerBox->maxLayoutOverflow()); - containerRect = containerBox->localToAbsoluteQuad(FloatQuad(overflowRect), false).enclosingBoundingBox(); - } + FloatRect overflowRect(scrolledOrigin, container->maxLayoutOverflow()); + FloatRect containerRect = container->localToAbsoluteQuad(FloatQuad(overflowRect), false).enclosingBoundingBox(); if (containerRect.isEmpty()) return FloatRect(); // Make the coordinates relative to the container enclosing bounding box. // Since we work with rects enclosing quad unions this is still transform-friendly. + FloatRect normalizedRect = absoluteRect; normalizedRect.moveBy(-containerRect.location()); // Fixed positions do not make sense in this coordinate system, but need to leave consistent tickmarks. @@ -89,29 +83,26 @@ static FloatRect toNormalizedRect(const FloatRect& absoluteRect, const RenderObj normalizedRect.move(-toRenderView(container)->frameView()->scrollOffsetForFixedPosition()); normalizedRect.scale(1 / containerRect.width(), 1 / containerRect.height()); - return normalizedRect; } -FloatRect findInPageRectFromAbsoluteRect(const FloatRect& inputRect, const RenderObject* renderer) +FloatRect findInPageRectFromAbsoluteRect(const FloatRect& inputRect, const RenderObject* baseRenderer) { - if (!renderer || inputRect.isEmpty()) + if (!baseRenderer || inputRect.isEmpty()) return FloatRect(); - // Normalize the input rect to its container, saving the container bounding box for the incoming loop. - FloatRect rendererBoundingBox; - FloatRect normalizedRect = toNormalizedRect(inputRect, renderer, rendererBoundingBox); - renderer = renderer->container(); + // Normalize the input rect to its container block. + FloatRect normalizedRect = toNormalizedRect(inputRect, baseRenderer); // Go up across frames. - while (renderer) { + for (const RenderObject* renderer = baseRenderer->containingBlock(); renderer; ) { // Go up the render tree until we reach the root of the current frame (the RenderView). - for (const RenderObject* container = renderer->container(); container; renderer = container, container = container->container()) { + for (const RenderBlock* container = renderer->containingBlock(); container; + renderer = container, container = container->containingBlock()) { - // Compose the normalized rects. The absolute bounding box of the container is calculated in toNormalizedRect - // and can be reused for the next iteration of the loop. - FloatRect normalizedBoxRect = toNormalizedRect(rendererBoundingBox, renderer, rendererBoundingBox); + // Compose the normalized rects. + FloatRect normalizedBoxRect = toNormalizedRect(renderer->absoluteBoundingBoxRect(), renderer); normalizedRect.scale(normalizedBoxRect.width(), normalizedBoxRect.height()); normalizedRect.moveBy(normalizedBoxRect.location()); @@ -122,10 +113,6 @@ FloatRect findInPageRectFromAbsoluteRect(const FloatRect& inputRect, const Rende // Jump to the renderer owning the frame, if any. ASSERT(renderer->isRenderView()); renderer = renderer->frame() ? renderer->frame()->ownerRenderer() : 0; - - // Update the absolute coordinates to the new frame. - if (renderer) - rendererBoundingBox = renderer->absoluteBoundingBoxRect(); } return normalizedRect; diff --git a/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp b/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp index b8fb074ea..b53eb2c3a 100755 --- a/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp +++ b/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp @@ -138,14 +138,6 @@ void IDBObjectStoreBackendProxy::deleteIndex(const String& name, IDBTransactionB m_webIDBObjectStore->deleteIndex(name, *transactionProxy->getWebIDBTransaction(), ec); } -void IDBObjectStoreBackendProxy::openCursor(PassRefPtr<IDBKeyRange> range, unsigned short direction, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec) -{ - // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer, - // all implementations of IDB interfaces are proxy objects. - IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction); - m_webIDBObjectStore->openCursor(range, static_cast<WebIDBCursor::Direction>(direction), new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction(), ec); -} - void IDBObjectStoreBackendProxy::openCursor(PassRefPtr<IDBKeyRange> range, IDBCursor::Direction direction, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface::TaskType taskType, IDBTransactionBackendInterface* transaction, ExceptionCode& ec) { // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer, diff --git a/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.h b/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.h index fb0f2af37..74cb0bd57 100644 --- a/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.h +++ b/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.h @@ -55,8 +55,6 @@ public: PassRefPtr<WebCore::IDBIndexBackendInterface> index(const String& name, WebCore::ExceptionCode&); void deleteIndex(const String& name, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); - // FIXME: Remove this version of openCursor when TaskType is plumbed through chromium. - virtual void openCursor(PassRefPtr<WebCore::IDBKeyRange>, unsigned short direction, PassRefPtr<WebCore::IDBCallbacks>, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); virtual void openCursor(PassRefPtr<WebCore::IDBKeyRange>, WebCore::IDBCursor::Direction, PassRefPtr<WebCore::IDBCallbacks>, WebCore::IDBTransactionBackendInterface::TaskType, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); virtual void count(PassRefPtr<WebCore::IDBKeyRange>, PassRefPtr<WebCore::IDBCallbacks>, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); diff --git a/Source/WebKit/chromium/src/NonCompositedContentHost.cpp b/Source/WebKit/chromium/src/NonCompositedContentHost.cpp index 4df4204b3..65dac62ca 100644 --- a/Source/WebKit/chromium/src/NonCompositedContentHost.cpp +++ b/Source/WebKit/chromium/src/NonCompositedContentHost.cpp @@ -30,7 +30,6 @@ #include "FloatPoint.h" #include "FloatRect.h" #include "GraphicsLayer.h" -#include "GraphicsLayerChromium.h" #include "PlatformContextSkia.h" #include "WebViewImpl.h" #include <public/WebContentLayer.h> @@ -49,11 +48,11 @@ NonCompositedContentHost::NonCompositedContentHost(WebViewImpl* webView) m_graphicsLayer->setName("non-composited content"); #endif m_graphicsLayer->setDrawsContent(true); - WebContentLayer* layer = static_cast<WebCore::GraphicsLayerChromium*>(m_graphicsLayer.get())->contentLayer(); - layer->setUseLCDText(true); - layer->layer()->setOpaque(true); + WebContentLayer layer = m_graphicsLayer->platformLayer()->to<WebContentLayer>(); + layer.setUseLCDText(true); + layer.setOpaque(true); #if !OS(ANDROID) - layer->setDrawCheckerboardForMissingTiles(true); + layer.setDrawCheckerboardForMissingTiles(true); #endif } @@ -81,7 +80,7 @@ void NonCompositedContentHost::setScrollLayer(WebCore::GraphicsLayer* layer) return; } - if (layer->platformLayer() == scrollLayer()) + if (*layer->platformLayer() == scrollLayer()) return; layer->addChildAtIndex(m_graphicsLayer.get(), 0); @@ -96,12 +95,12 @@ void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, bool visibleRectChanged = m_viewportSize != viewportSize; m_viewportSize = viewportSize; - WebLayer* layer = scrollLayer(); - layer->setScrollPosition(scrollPosition + scrollOrigin); - layer->setPosition(WebFloatPoint(-scrollPosition)); + WebScrollableLayer layer = scrollLayer(); + layer.setScrollPosition(scrollPosition + scrollOrigin); + layer.setPosition(WebFloatPoint(-scrollPosition)); // Due to the possibility of pinch zoom, the noncomposited layer is always // assumed to be scrollable. - layer->setScrollable(true); + layer.setScrollable(true); m_deviceScaleFactor = deviceScale; m_graphicsLayer->deviceOrPageScaleFactorChanged(); m_graphicsLayer->setSize(contentsSize); @@ -128,11 +127,11 @@ bool NonCompositedContentHost::haveScrollLayer() return m_graphicsLayer->parent(); } -WebLayer* NonCompositedContentHost::scrollLayer() +WebScrollableLayer NonCompositedContentHost::scrollLayer() { if (!m_graphicsLayer->parent()) - return 0; - return m_graphicsLayer->parent()->platformLayer(); + return WebScrollableLayer(); + return m_graphicsLayer->parent()->platformLayer()->to<WebScrollableLayer>(); } void NonCompositedContentHost::invalidateRect(const WebCore::IntRect& rect) diff --git a/Source/WebKit/chromium/src/NonCompositedContentHost.h b/Source/WebKit/chromium/src/NonCompositedContentHost.h index 08b5f6a41..e60e9ef48 100644 --- a/Source/WebKit/chromium/src/NonCompositedContentHost.h +++ b/Source/WebKit/chromium/src/NonCompositedContentHost.h @@ -29,7 +29,7 @@ #include "GraphicsLayerClient.h" #include "IntSize.h" -#include <public/WebLayer.h> +#include <public/WebScrollableLayer.h> #include <wtf/Noncopyable.h> #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> @@ -80,7 +80,7 @@ private: virtual float deviceScaleFactor() const OVERRIDE { return m_deviceScaleFactor; } bool haveScrollLayer(); - WebLayer* scrollLayer(); + WebScrollableLayer scrollLayer(); OwnPtr<WebCore::GraphicsLayer> m_graphicsLayer; WebViewImpl* m_webView; diff --git a/Source/WebKit/chromium/src/WebVideoLayerImpl.cpp b/Source/WebKit/chromium/src/WebContentLayer.cpp index 5bfed6742..efa7465b1 100644 --- a/Source/WebKit/chromium/src/WebVideoLayerImpl.cpp +++ b/Source/WebKit/chromium/src/WebContentLayer.cpp @@ -24,35 +24,59 @@ */ #include "config.h" -#include "WebVideoLayerImpl.h" +#include <public/WebContentLayer.h> -#include "VideoLayerChromium.h" -#include "WebLayerImpl.h" +#include "ContentLayerChromium.h" +#include "WebContentLayerImpl.h" + +using namespace WebCore; namespace WebKit { -WebVideoLayer* WebVideoLayer::create(WebVideoFrameProvider* provider) +WebContentLayer WebContentLayer::create(WebContentLayerClient* contentClient) +{ + return WebContentLayer(WebContentLayerImpl::create(contentClient)); +} + +void WebContentLayer::clearClient() +{ + unwrap<ContentLayerChromium>()->clearDelegate(); +} + +void WebContentLayer::setDoubleSided(bool doubleSided) +{ + m_private->setDoubleSided(doubleSided); +} + +void WebContentLayer::setContentsScale(float scale) +{ + m_private->setContentsScale(scale); +} + +void WebContentLayer::setUseLCDText(bool enable) { - return new WebVideoLayerImpl(WebCore::VideoLayerChromium::create(provider)); + m_private->setUseLCDText(enable); } -WebVideoLayerImpl::WebVideoLayerImpl(PassRefPtr<WebCore::VideoLayerChromium> layer) - : m_layer(adoptPtr(new WebLayerImpl(layer))) +void WebContentLayer::setDrawCheckerboardForMissingTiles(bool enable) { + m_private->setDrawCheckerboardForMissingTiles(enable); } -WebVideoLayerImpl::~WebVideoLayerImpl() +WebContentLayer::WebContentLayer(const PassRefPtr<ContentLayerChromium>& node) + : WebScrollableLayer(node) { } -WebLayer* WebVideoLayerImpl::layer() +WebContentLayer& WebContentLayer::operator=(const PassRefPtr<ContentLayerChromium>& node) { - return m_layer.get(); + m_private = node; + return *this; } -bool WebVideoLayerImpl::active() const +WebContentLayer::operator PassRefPtr<ContentLayerChromium>() const { - return m_layer->layer()->layerTreeHost(); + return static_cast<ContentLayerChromium*>(m_private.get()); } } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebContentLayerImpl.cpp b/Source/WebKit/chromium/src/WebContentLayerImpl.cpp index fa21e8974..69da1ea3f 100644 --- a/Source/WebKit/chromium/src/WebContentLayerImpl.cpp +++ b/Source/WebKit/chromium/src/WebContentLayerImpl.cpp @@ -26,66 +26,37 @@ #include "config.h" #include "WebContentLayerImpl.h" -#include "SkMatrix44.h" #include <public/WebContentLayerClient.h> -#include <public/WebFloatPoint.h> #include <public/WebFloatRect.h> #include <public/WebRect.h> -#include <public/WebSize.h> using namespace WebCore; namespace WebKit { -WebContentLayer* WebContentLayer::create(WebContentLayerClient* client) +PassRefPtr<WebContentLayerImpl> WebContentLayerImpl::create(WebContentLayerClient* contentClient) { - return new WebContentLayerImpl(client); + return adoptRef(new WebContentLayerImpl(contentClient)); } -WebContentLayerImpl::WebContentLayerImpl(WebContentLayerClient* client) - : m_webLayerImpl(adoptPtr(new WebLayerImpl(ContentLayerChromium::create(this)))) - , m_client(client) +WebContentLayerImpl::WebContentLayerImpl(WebContentLayerClient* contentClient) + : ContentLayerChromium(this) + , m_contentClient(contentClient) { - m_webLayerImpl->layer()->setIsDrawable(true); + setIsDrawable(true); } WebContentLayerImpl::~WebContentLayerImpl() { - static_cast<ContentLayerChromium*>(m_webLayerImpl->layer())->clearDelegate(); + clearDelegate(); } -WebLayer* WebContentLayerImpl::layer() -{ - return m_webLayerImpl.get(); -} - -void WebContentLayerImpl::setDoubleSided(bool doubleSided) -{ - m_webLayerImpl->layer()->setDoubleSided(doubleSided); -} - -void WebContentLayerImpl::setContentsScale(float scale) -{ - m_webLayerImpl->layer()->setContentsScale(scale); -} - -void WebContentLayerImpl::setUseLCDText(bool enable) -{ - m_webLayerImpl->layer()->setUseLCDText(enable); -} - -void WebContentLayerImpl::setDrawCheckerboardForMissingTiles(bool enable) -{ - m_webLayerImpl->layer()->setDrawCheckerboardForMissingTiles(enable); -} - - void WebContentLayerImpl::paintContents(SkCanvas* canvas, const IntRect& clip, FloatRect& opaque) { - if (!m_client) + if (!m_contentClient) return; WebFloatRect webOpaque; - m_client->paintContents(canvas, WebRect(clip), webOpaque); + m_contentClient->paintContents(canvas, WebRect(clip), webOpaque); opaque = webOpaque; } diff --git a/Source/WebKit/chromium/src/WebContentLayerImpl.h b/Source/WebKit/chromium/src/WebContentLayerImpl.h index 511f8e0ba..97729ea1e 100644 --- a/Source/WebKit/chromium/src/WebContentLayerImpl.h +++ b/Source/WebKit/chromium/src/WebContentLayerImpl.h @@ -27,33 +27,23 @@ #define WebContentLayerImpl_h #include "ContentLayerChromium.h" -#include "WebLayerImpl.h" -#include <public/WebContentLayer.h> #include <wtf/PassRefPtr.h> namespace WebKit { class WebContentLayerClient; -class WebContentLayerImpl : public WebContentLayer, - public WebCore::ContentLayerDelegate { +class WebContentLayerImpl : public WebCore::ContentLayerChromium, public WebCore::ContentLayerDelegate { public: - explicit WebContentLayerImpl(WebContentLayerClient*); - - // WebContentLayer implementation. - virtual WebLayer* layer() OVERRIDE; - virtual void setDoubleSided(bool) OVERRIDE; - virtual void setContentsScale(float) OVERRIDE; - virtual void setUseLCDText(bool) OVERRIDE; - virtual void setDrawCheckerboardForMissingTiles(bool) OVERRIDE; + static PassRefPtr<WebContentLayerImpl> create(WebContentLayerClient* contentClient); protected: + explicit WebContentLayerImpl(WebContentLayerClient* contentClient); virtual ~WebContentLayerImpl(); // ContentLayerDelegate implementation. virtual void paintContents(SkCanvas*, const WebCore::IntRect& clip, WebCore::FloatRect& opaque) OVERRIDE; - OwnPtr<WebLayerImpl> m_webLayerImpl; - WebContentLayerClient* m_client; + WebContentLayerClient* m_contentClient; bool m_drawsContent; }; diff --git a/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.cpp b/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp index d62166f44..d4aff5721 100644 --- a/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.cpp +++ b/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp @@ -24,11 +24,10 @@ */ #include "config.h" -#include "WebExternalTextureLayerImpl.h" +#include <public/WebExternalTextureLayer.h> #include "CCTextureUpdateQueue.h" #include "TextureLayerChromium.h" -#include "WebLayerImpl.h" #include <public/WebExternalTextureLayerClient.h> #include <public/WebFloatRect.h> #include <public/WebSize.h> @@ -37,96 +36,96 @@ using namespace WebCore; namespace WebKit { -WebExternalTextureLayer* WebExternalTextureLayer::create(WebExternalTextureLayerClient* client) -{ - return new WebExternalTextureLayerImpl(client); -} +class WebTextureUpdaterImpl : public WebTextureUpdater { +public: + explicit WebTextureUpdaterImpl(CCTextureUpdateQueue& queue) + : m_queue(queue) + { + } -WebExternalTextureLayerImpl::WebExternalTextureLayerImpl(WebExternalTextureLayerClient* client) - : m_client(client) -{ - RefPtr<TextureLayerChromium> layer; - if (m_client) - layer = TextureLayerChromium::create(this); - else - layer = TextureLayerChromium::create(0); - layer->setIsDrawable(true); - m_layer = adoptPtr(new WebLayerImpl(layer.release())); -} + virtual void appendCopy(unsigned sourceTexture, unsigned destinationTexture, WebSize size) OVERRIDE + { + TextureCopier::Parameters copy = { sourceTexture, destinationTexture, size }; + m_queue.appendCopy(copy); + } -WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() -{ - static_cast<TextureLayerChromium*>(m_layer->layer())->clearClient(); -} +private: + CCTextureUpdateQueue& m_queue; +}; + +class WebExternalTextureLayerImpl : public TextureLayerChromiumClient, public TextureLayerChromium { +public: + explicit WebExternalTextureLayerImpl(WebExternalTextureLayerClient* client) + : TextureLayerChromium(client ? this : 0) + , m_client(client) + { + } + + virtual unsigned prepareTexture(CCTextureUpdateQueue& queue) OVERRIDE + { + WebTextureUpdaterImpl updaterImpl(queue); + return m_client->prepareTexture(updaterImpl); + } -WebLayer* WebExternalTextureLayerImpl::layer() + virtual WebKit::WebGraphicsContext3D* context() OVERRIDE + { + return m_client->context(); + } + +private: + WebExternalTextureLayerClient* m_client; +}; + +WebExternalTextureLayer WebExternalTextureLayer::create(WebExternalTextureLayerClient* client) { - return m_layer.get(); + RefPtr<TextureLayerChromium> layer = adoptRef(new WebExternalTextureLayerImpl(client)); + layer->setIsDrawable(true); + return WebExternalTextureLayer(layer.release()); } -void WebExternalTextureLayerImpl::setTextureId(unsigned id) +void WebExternalTextureLayer::clearClient() { - static_cast<TextureLayerChromium*>(m_layer->layer())->setTextureId(id); + unwrap<TextureLayerChromium>()->clearClient(); } -void WebExternalTextureLayerImpl::setFlipped(bool flipped) +void WebExternalTextureLayer::setTextureId(unsigned id) { - static_cast<TextureLayerChromium*>(m_layer->layer())->setFlipped(flipped); + unwrap<TextureLayerChromium>()->setTextureId(id); } -void WebExternalTextureLayerImpl::setUVRect(const WebFloatRect& rect) +void WebExternalTextureLayer::setFlipped(bool flipped) { - static_cast<TextureLayerChromium*>(m_layer->layer())->setUVRect(rect); + unwrap<TextureLayerChromium>()->setFlipped(flipped); } -void WebExternalTextureLayerImpl::setOpaque(bool opaque) +void WebExternalTextureLayer::setUVRect(const WebFloatRect& rect) { - static_cast<TextureLayerChromium*>(m_layer->layer())->setOpaque(opaque); + unwrap<TextureLayerChromium>()->setUVRect(rect); } -void WebExternalTextureLayerImpl::setPremultipliedAlpha(bool premultipliedAlpha) +void WebExternalTextureLayer::setOpaque(bool opaque) { - static_cast<TextureLayerChromium*>(m_layer->layer())->setPremultipliedAlpha(premultipliedAlpha); + unwrap<TextureLayerChromium>()->setOpaque(opaque); } -void WebExternalTextureLayerImpl::willModifyTexture() +void WebExternalTextureLayer::setPremultipliedAlpha(bool premultipliedAlpha) { - static_cast<TextureLayerChromium*>(m_layer->layer())->willModifyTexture(); + unwrap<TextureLayerChromium>()->setPremultipliedAlpha(premultipliedAlpha); } -void WebExternalTextureLayerImpl::setRateLimitContext(bool rateLimit) +void WebExternalTextureLayer::willModifyTexture() { - static_cast<TextureLayerChromium*>(m_layer->layer())->setRateLimitContext(rateLimit); + unwrap<TextureLayerChromium>()->willModifyTexture(); } -class WebTextureUpdaterImpl : public WebTextureUpdater { -public: - explicit WebTextureUpdaterImpl(CCTextureUpdateQueue& queue) - : m_queue(queue) - { - } - - virtual void appendCopy(unsigned sourceTexture, unsigned destinationTexture, WebSize size) OVERRIDE - { - TextureCopier::Parameters copy = { sourceTexture, destinationTexture, size }; - m_queue.appendCopy(copy); - } - -private: - CCTextureUpdateQueue& m_queue; -}; - -unsigned WebExternalTextureLayerImpl::prepareTexture(CCTextureUpdateQueue& queue) +void WebExternalTextureLayer::setRateLimitContext(bool rateLimit) { - ASSERT(m_client); - WebTextureUpdaterImpl updaterImpl(queue); - return m_client->prepareTexture(updaterImpl); + unwrap<TextureLayerChromium>()->setRateLimitContext(rateLimit); } -WebGraphicsContext3D* WebExternalTextureLayerImpl::context() +WebExternalTextureLayer::WebExternalTextureLayer(PassRefPtr<TextureLayerChromium> layer) + : WebLayer(layer) { - ASSERT(m_client); - return m_client->context(); } } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.h b/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.h deleted file mode 100644 index 5348895bf..000000000 --- a/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WebExternalTextureLayerImpl_h -#define WebExternalTextureLayerImpl_h - -#include "TextureLayerChromium.h" -#include <public/WebExternalTextureLayer.h> - -namespace WebKit { - -class WebLayerImpl; - -class WebExternalTextureLayerImpl : public WebExternalTextureLayer, - public WebCore::TextureLayerChromiumClient { -public: - explicit WebExternalTextureLayerImpl(WebExternalTextureLayerClient*); - virtual ~WebExternalTextureLayerImpl(); - - // WebExternalTextureLayer implementation. - virtual WebLayer* layer() OVERRIDE; - virtual void setTextureId(unsigned) OVERRIDE; - virtual void setFlipped(bool) OVERRIDE; - virtual void setUVRect(const WebFloatRect&) OVERRIDE; - virtual void setOpaque(bool) OVERRIDE; - virtual void setPremultipliedAlpha(bool) OVERRIDE; - virtual void willModifyTexture() OVERRIDE; - virtual void setRateLimitContext(bool) OVERRIDE; - - // TextureLayerChromiumClient implementation. - virtual unsigned prepareTexture(WebCore::CCTextureUpdateQueue&) OVERRIDE; - virtual WebGraphicsContext3D* context() OVERRIDE; - -private: - WebExternalTextureLayerClient* m_client; - OwnPtr<WebLayerImpl> m_layer; -}; - -} - -#endif // WebExternalTextureLayerImpl_h - diff --git a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h index 95879b5d0..04020e558 100644 --- a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h +++ b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h @@ -56,10 +56,6 @@ public: WebIDBIndex* index(const WebString& name, WebExceptionCode&); void deleteIndex(const WebString& name, const WebIDBTransaction&, WebExceptionCode&); - void openCursor(const WebIDBKeyRange& range, unsigned short direction, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec) - { - openCursor(range, static_cast<WebIDBCursor::Direction>(direction), callbacks, WebIDBTransaction::NormalTask, transaction, ec); - } void openCursor(const WebIDBKeyRange&, WebIDBCursor::Direction, WebIDBCallbacks*, WebIDBTransaction::TaskType, const WebIDBTransaction&, WebExceptionCode&); void count(const WebIDBKeyRange&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); diff --git a/Source/WebKit/chromium/src/WebIOSurfaceLayerImpl.cpp b/Source/WebKit/chromium/src/WebIOSurfaceLayer.cpp index bab70c61d..77db0c877 100644 --- a/Source/WebKit/chromium/src/WebIOSurfaceLayerImpl.cpp +++ b/Source/WebKit/chromium/src/WebIOSurfaceLayer.cpp @@ -24,39 +24,30 @@ */ #include "config.h" -#include "WebIOSurfaceLayerImpl.h" +#include <public/WebIOSurfaceLayer.h> #include "IOSurfaceLayerChromium.h" -#include "WebLayerImpl.h" +#include <public/WebSize.h> -using WebCore::IOSurfaceLayerChromium; +using namespace WebCore; namespace WebKit { -WebIOSurfaceLayer* WebIOSurfaceLayer::create() +WebIOSurfaceLayer WebIOSurfaceLayer::create() { RefPtr<IOSurfaceLayerChromium> layer = IOSurfaceLayerChromium::create(); layer->setIsDrawable(true); - return new WebIOSurfaceLayerImpl(layer.release()); + return WebIOSurfaceLayer(layer.release()); } -WebIOSurfaceLayerImpl::WebIOSurfaceLayerImpl(PassRefPtr<IOSurfaceLayerChromium> layer) - : m_layer(adoptPtr(new WebLayerImpl(layer))) +void WebIOSurfaceLayer::setIOSurfaceProperties(unsigned ioSurfaceId, WebSize size) { + unwrap<IOSurfaceLayerChromium>()->setIOSurfaceProperties(ioSurfaceId, size); } -WebIOSurfaceLayerImpl::~WebIOSurfaceLayerImpl() +WebIOSurfaceLayer::WebIOSurfaceLayer(PassRefPtr<IOSurfaceLayerChromium> layer) + : WebLayer(layer) { } -void WebIOSurfaceLayerImpl::setIOSurfaceProperties(unsigned ioSurfaceId, WebSize size) -{ - static_cast<IOSurfaceLayerChromium*>(m_layer->layer())->setIOSurfaceProperties(ioSurfaceId, size); -} - -WebLayer* WebIOSurfaceLayerImpl::layer() -{ - return m_layer.get(); -} - } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebIOSurfaceLayerImpl.h b/Source/WebKit/chromium/src/WebIOSurfaceLayerImpl.h deleted file mode 100644 index 3dbb02759..000000000 --- a/Source/WebKit/chromium/src/WebIOSurfaceLayerImpl.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2012 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WebIOSurfaceLayerImpl_h -#define WebIOSurfaceLayerImpl_h - -#include <public/WebIOSurfaceLayer.h> -#include <wtf/OwnPtr.h> - -namespace WebCore { -class IOSurfaceLayerChromium; -} - -namespace WebKit { - -class WebIOSurfaceLayerImpl : public WebIOSurfaceLayer { -public: - explicit WebIOSurfaceLayerImpl(PassRefPtr<WebCore::IOSurfaceLayerChromium>); - virtual ~WebIOSurfaceLayerImpl(); - - // WebIOSurfaceLayer implementation. - virtual WebLayer* layer() OVERRIDE; - virtual void setIOSurfaceProperties(unsigned ioSurfaceId, WebSize) OVERRIDE; - -private: - OwnPtr<WebLayerImpl> m_layer; -}; - -} - -#endif // WebIOSurfaceLayerImpl_h - diff --git a/Source/WebKit/chromium/src/WebImageLayerImpl.h b/Source/WebKit/chromium/src/WebImageLayer.cpp index 9a4b8b3eb..f76151530 100644 --- a/Source/WebKit/chromium/src/WebImageLayerImpl.h +++ b/Source/WebKit/chromium/src/WebImageLayer.cpp @@ -23,32 +23,26 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebImageLayerImpl_h -#define WebImageLayerImpl_h - +#include "config.h" #include <public/WebImageLayer.h> -#include <wtf/OwnPtr.h> -namespace WebCore { -class ImageLayerChromium; -} +#include "ImageLayerChromium.h" namespace WebKit { -class WebLayerImpl; - -class WebImageLayerImpl : public WebImageLayer { -public: - explicit WebImageLayerImpl(PassRefPtr<WebCore::ImageLayerChromium>); - virtual ~WebImageLayerImpl(); - // WebImageLayer implementation. - WebLayer* layer() OVERRIDE; - virtual void setBitmap(SkBitmap) OVERRIDE; +WebImageLayer WebImageLayer::create() +{ + return WebImageLayer(WebCore::ImageLayerChromium::create()); +} -private: - OwnPtr<WebLayerImpl> m_layer; -}; +WebImageLayer::WebImageLayer(PassRefPtr<WebCore::ImageLayerChromium> layer) + : WebLayer(layer) +{ +} +void WebImageLayer::setBitmap(SkBitmap bitmap) +{ + unwrap<WebCore::ImageLayerChromium>()->setBitmap(bitmap); } -#endif // WebImageLayerImpl_h +} // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebLayer.cpp b/Source/WebKit/chromium/src/WebLayer.cpp new file mode 100644 index 000000000..37897e6f8 --- /dev/null +++ b/Source/WebKit/chromium/src/WebLayer.cpp @@ -0,0 +1,379 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include <public/WebLayer.h> + +#include "LayerChromium.h" +#include "SkMatrix44.h" +#include "WebAnimationImpl.h" +#include "WebLayerImpl.h" +#include <public/WebFilterOperations.h> +#include <public/WebFloatPoint.h> +#include <public/WebFloatRect.h> +#include <public/WebSize.h> +#include <public/WebTransformationMatrix.h> + +using namespace WebCore; +using WebKit::WebTransformationMatrix; + +namespace { + +WebTransformationMatrix transformationMatrixFromSkMatrix44(const SkMatrix44& matrix) +{ + double data[16]; + matrix.asColMajord(data); + return WebTransformationMatrix(data[0], data[1], data[2], data[3], + data[4], data[5], data[6], data[7], + data[8], data[9], data[10], data[11], + data[12], data[13], data[14], data[15]); +} + +SkMatrix44 skMatrix44FromTransformationMatrix(const WebTransformationMatrix& matrix) +{ + SkMatrix44 skMatrix; + skMatrix.set(0, 0, SkDoubleToMScalar(matrix.m11())); + skMatrix.set(1, 0, SkDoubleToMScalar(matrix.m12())); + skMatrix.set(2, 0, SkDoubleToMScalar(matrix.m13())); + skMatrix.set(3, 0, SkDoubleToMScalar(matrix.m14())); + skMatrix.set(0, 1, SkDoubleToMScalar(matrix.m21())); + skMatrix.set(1, 1, SkDoubleToMScalar(matrix.m22())); + skMatrix.set(2, 1, SkDoubleToMScalar(matrix.m23())); + skMatrix.set(3, 1, SkDoubleToMScalar(matrix.m24())); + skMatrix.set(0, 2, SkDoubleToMScalar(matrix.m31())); + skMatrix.set(1, 2, SkDoubleToMScalar(matrix.m32())); + skMatrix.set(2, 2, SkDoubleToMScalar(matrix.m33())); + skMatrix.set(3, 2, SkDoubleToMScalar(matrix.m34())); + skMatrix.set(0, 3, SkDoubleToMScalar(matrix.m41())); + skMatrix.set(1, 3, SkDoubleToMScalar(matrix.m42())); + skMatrix.set(2, 3, SkDoubleToMScalar(matrix.m43())); + skMatrix.set(3, 3, SkDoubleToMScalar(matrix.m44())); + return skMatrix; +} + +} // anonymous namespace + +namespace WebKit { + +WebLayer WebLayer::create() +{ + return WebLayer(WebLayerImpl::create()); +} + +void WebLayer::reset() +{ + m_private.reset(); +} + +void WebLayer::assign(const WebLayer& other) +{ + m_private = other.m_private; +} + +bool WebLayer::equals(const WebLayer& n) const +{ + return (m_private.get() == n.m_private.get()); +} + +void WebLayer::invalidateRect(const WebFloatRect& dirtyRect) +{ + m_private->setNeedsDisplayRect(dirtyRect); +} + +void WebLayer::invalidate() +{ + m_private->setNeedsDisplay(); +} + +void WebLayer::addChild(const WebLayer& child) +{ + m_private->addChild(child); +} + +void WebLayer::insertChild(const WebLayer& child, size_t index) +{ + m_private->insertChild(child, index); +} + +void WebLayer::replaceChild(const WebLayer& reference, const WebLayer& newLayer) +{ + WebLayer ref = reference; + m_private->replaceChild(ref.unwrap<LayerChromium>(), newLayer); +} + +void WebLayer::setChildren(const WebVector<WebLayer>& webChildren) +{ + Vector<RefPtr<LayerChromium> > children(webChildren.size()); + for (size_t i = 0; i < webChildren.size(); ++i) + children[i] = webChildren[i].unwrap<LayerChromium>(); + m_private->setChildren(children); +} + +void WebLayer::removeFromParent() +{ + m_private->removeFromParent(); +} + +void WebLayer::removeAllChildren() +{ + m_private->removeAllChildren(); +} + +void WebLayer::setAnchorPoint(const WebFloatPoint& anchorPoint) +{ + m_private->setAnchorPoint(anchorPoint); +} + +WebFloatPoint WebLayer::anchorPoint() const +{ + return WebFloatPoint(m_private->anchorPoint()); +} + +void WebLayer::setAnchorPointZ(float anchorPointZ) +{ + m_private->setAnchorPointZ(anchorPointZ); +} + +float WebLayer::anchorPointZ() const +{ + return m_private->anchorPointZ(); +} + +void WebLayer::setBounds(const WebSize& size) +{ + m_private->setBounds(size); +} + +WebSize WebLayer::bounds() const +{ + return WebSize(m_private->bounds()); +} + +void WebLayer::setMasksToBounds(bool masksToBounds) +{ + m_private->setMasksToBounds(masksToBounds); +} + +bool WebLayer::masksToBounds() const +{ + return m_private->masksToBounds(); +} + +void WebLayer::setMaskLayer(const WebLayer& maskLayer) +{ + WebLayer ref = maskLayer; + m_private->setMaskLayer(ref.unwrap<LayerChromium>()); +} + +void WebLayer::setReplicaLayer(const WebLayer& replicaLayer) +{ + WebLayer ref = replicaLayer; + m_private->setReplicaLayer(ref.unwrap<LayerChromium>()); +} + +void WebLayer::setOpacity(float opacity) +{ + m_private->setOpacity(opacity); +} + +float WebLayer::opacity() const +{ + return m_private->opacity(); +} + +void WebLayer::setOpaque(bool opaque) +{ + m_private->setOpaque(opaque); +} + +bool WebLayer::opaque() const +{ + return m_private->opaque(); +} + +void WebLayer::setPosition(const WebFloatPoint& position) +{ + m_private->setPosition(position); +} + +WebFloatPoint WebLayer::position() const +{ + return WebFloatPoint(m_private->position()); +} + +void WebLayer::setSublayerTransform(const SkMatrix44& matrix) +{ + m_private->setSublayerTransform(transformationMatrixFromSkMatrix44(matrix)); +} + +void WebLayer::setSublayerTransform(const WebTransformationMatrix& matrix) +{ + m_private->setSublayerTransform(matrix); +} + +SkMatrix44 WebLayer::sublayerTransform() const +{ + return skMatrix44FromTransformationMatrix(m_private->sublayerTransform()); +} + +void WebLayer::setTransform(const SkMatrix44& matrix) +{ + m_private->setTransform(transformationMatrixFromSkMatrix44(matrix)); +} + +void WebLayer::setTransform(const WebTransformationMatrix& matrix) +{ + m_private->setTransform(matrix); +} + +SkMatrix44 WebLayer::transform() const +{ + return skMatrix44FromTransformationMatrix(m_private->transform()); +} + +void WebLayer::setDrawsContent(bool drawsContent) +{ + m_private->setIsDrawable(drawsContent); +} + +bool WebLayer::drawsContent() const +{ + return m_private->drawsContent(); +} + +void WebLayer::setPreserves3D(bool preserve3D) +{ + m_private->setPreserves3D(preserve3D); +} + +void WebLayer::setUseParentBackfaceVisibility(bool useParentBackfaceVisibility) +{ + m_private->setUseParentBackfaceVisibility(useParentBackfaceVisibility); +} + +void WebLayer::setBackgroundColor(WebColor color) +{ + m_private->setBackgroundColor(color); +} + +void WebLayer::setFilters(const WebFilterOperations& filters) +{ + m_private->setFilters(filters); +} + +void WebLayer::setBackgroundFilters(const WebFilterOperations& filters) +{ + m_private->setBackgroundFilters(filters); +} + +void WebLayer::setDebugBorderColor(const WebColor& color) +{ + m_private->setDebugBorderColor(color); +} + +void WebLayer::setDebugBorderWidth(float width) +{ + m_private->setDebugBorderWidth(width); +} + +void WebLayer::setDebugName(WebString name) +{ + m_private->setDebugName(name); +} + +void WebLayer::setAnimationDelegate(WebAnimationDelegate* delegate) +{ + m_private->setLayerAnimationDelegate(delegate); +} + +bool WebLayer::addAnimation(WebAnimation* animation) +{ + return m_private->addAnimation(static_cast<WebAnimationImpl*>(animation)->cloneToCCAnimation()); +} + +void WebLayer::removeAnimation(int animationId) +{ + m_private->removeAnimation(animationId); +} + +void WebLayer::removeAnimation(int animationId, WebAnimation::TargetProperty targetProperty) +{ + m_private->layerAnimationController()->removeAnimation(animationId, static_cast<CCActiveAnimation::TargetProperty>(targetProperty)); +} + +void WebLayer::pauseAnimation(int animationId, double timeOffset) +{ + m_private->pauseAnimation(animationId, timeOffset); +} + +void WebLayer::suspendAnimations(double monotonicTime) +{ + m_private->suspendAnimations(monotonicTime); +} + +void WebLayer::resumeAnimations(double monotonicTime) +{ + m_private->resumeAnimations(monotonicTime); +} + +bool WebLayer::hasActiveAnimation() +{ + return m_private->hasActiveAnimation(); +} + +void WebLayer::transferAnimationsTo(WebLayer* other) +{ + ASSERT(other); + if (other) + other->m_private->setLayerAnimationController(m_private->releaseLayerAnimationController()); +} + +void WebLayer::setForceRenderSurface(bool forceRenderSurface) +{ + m_private->setForceRenderSurface(forceRenderSurface); +} + +void WebLayer::clearRenderSurface() +{ + m_private->clearRenderSurface(); +} + +WebLayer::WebLayer(const PassRefPtr<LayerChromium>& node) + : m_private(node) +{ +} + +WebLayer& WebLayer::operator=(const PassRefPtr<LayerChromium>& node) +{ + m_private = node; + return *this; +} + +WebLayer::operator PassRefPtr<LayerChromium>() const +{ + return m_private.get(); +} + +} // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebLayerImpl.cpp b/Source/WebKit/chromium/src/WebLayerImpl.cpp index 40ced485d..16e1206ca 100644 --- a/Source/WebKit/chromium/src/WebLayerImpl.cpp +++ b/Source/WebKit/chromium/src/WebLayerImpl.cpp @@ -26,376 +26,25 @@ #include "config.h" #include "WebLayerImpl.h" -#include "CCActiveAnimation.h" -#include "LayerChromium.h" -#include "SkMatrix44.h" -#include "WebAnimationImpl.h" -#include <public/WebFloatPoint.h> -#include <public/WebFloatRect.h> -#include <public/WebSize.h> -#include <public/WebTransformationMatrix.h> - -using WebCore::CCActiveAnimation; -using WebCore::LayerChromium; +using namespace WebCore; namespace WebKit { -namespace { - -WebTransformationMatrix transformationMatrixFromSkMatrix44(const SkMatrix44& matrix) -{ - double data[16]; - matrix.asColMajord(data); - return WebTransformationMatrix(data[0], data[1], data[2], data[3], - data[4], data[5], data[6], data[7], - data[8], data[9], data[10], data[11], - data[12], data[13], data[14], data[15]); -} - -SkMatrix44 skMatrix44FromTransformationMatrix(const WebTransformationMatrix& matrix) -{ - SkMatrix44 skMatrix; - skMatrix.set(0, 0, SkDoubleToMScalar(matrix.m11())); - skMatrix.set(1, 0, SkDoubleToMScalar(matrix.m12())); - skMatrix.set(2, 0, SkDoubleToMScalar(matrix.m13())); - skMatrix.set(3, 0, SkDoubleToMScalar(matrix.m14())); - skMatrix.set(0, 1, SkDoubleToMScalar(matrix.m21())); - skMatrix.set(1, 1, SkDoubleToMScalar(matrix.m22())); - skMatrix.set(2, 1, SkDoubleToMScalar(matrix.m23())); - skMatrix.set(3, 1, SkDoubleToMScalar(matrix.m24())); - skMatrix.set(0, 2, SkDoubleToMScalar(matrix.m31())); - skMatrix.set(1, 2, SkDoubleToMScalar(matrix.m32())); - skMatrix.set(2, 2, SkDoubleToMScalar(matrix.m33())); - skMatrix.set(3, 2, SkDoubleToMScalar(matrix.m34())); - skMatrix.set(0, 3, SkDoubleToMScalar(matrix.m41())); - skMatrix.set(1, 3, SkDoubleToMScalar(matrix.m42())); - skMatrix.set(2, 3, SkDoubleToMScalar(matrix.m43())); - skMatrix.set(3, 3, SkDoubleToMScalar(matrix.m44())); - return skMatrix; -} - -} // anonymous namespace - - -WebLayer* WebLayer::create() +PassRefPtr<WebLayerImpl> WebLayerImpl::create() { - return new WebLayerImpl(LayerChromium::create()); + return adoptRef(new WebLayerImpl()); } -WebLayerImpl::WebLayerImpl(PassRefPtr<LayerChromium> layer) - : m_layer(layer) +WebLayerImpl::WebLayerImpl() + : LayerChromium() { + // Make sure that this layer does not draw content. This way we don't have to override + // the base class implementation of drawsContent(). + ASSERT(!drawsContent()); } WebLayerImpl::~WebLayerImpl() { - m_layer->clearRenderSurface(); - m_layer->setLayerAnimationDelegate(0); -} - -int WebLayerImpl::id() const -{ - return m_layer->id(); -} - -void WebLayerImpl::invalidateRect(const WebFloatRect& rect) -{ - m_layer->setNeedsDisplayRect(rect); -} - -void WebLayerImpl::invalidate() -{ - m_layer->setNeedsDisplay(); -} - -void WebLayerImpl::addChild(WebLayer* child) -{ - m_layer->addChild(static_cast<WebLayerImpl*>(child)->layer()); -} - -void WebLayerImpl::insertChild(WebLayer* child, size_t index) -{ - m_layer->insertChild(static_cast<WebLayerImpl*>(child)->layer(), index); -} - -void WebLayerImpl::replaceChild(WebLayer* reference, WebLayer* newLayer) -{ - m_layer->replaceChild(static_cast<WebLayerImpl*>(reference)->layer(), static_cast<WebLayerImpl*>(newLayer)->layer()); -} - -void WebLayerImpl::setChildren(const WebVector<WebLayer*>& webChildren) -{ - Vector<RefPtr<LayerChromium> > children(webChildren.size()); - for (size_t i = 0; i < webChildren.size(); ++i) - children[i] = static_cast<WebLayerImpl*>(webChildren[i])->layer(); - m_layer->setChildren(children); -} - -void WebLayerImpl::removeFromParent() -{ - m_layer->removeFromParent(); -} - -void WebLayerImpl::removeAllChildren() -{ - m_layer->removeAllChildren(); -} - -void WebLayerImpl::setAnchorPoint(const WebFloatPoint& anchorPoint) -{ - m_layer->setAnchorPoint(anchorPoint); -} - -WebFloatPoint WebLayerImpl::anchorPoint() const -{ - return WebFloatPoint(m_layer->anchorPoint()); -} - -void WebLayerImpl::setAnchorPointZ(float anchorPointZ) -{ - m_layer->setAnchorPointZ(anchorPointZ); -} - -float WebLayerImpl::anchorPointZ() const -{ - return m_layer->anchorPointZ(); -} - -void WebLayerImpl::setBounds(const WebSize& size) -{ - m_layer->setBounds(size); -} - -WebSize WebLayerImpl::bounds() const -{ - return WebSize(m_layer->bounds()); -} - -void WebLayerImpl::setMasksToBounds(bool masksToBounds) -{ - m_layer->setMasksToBounds(masksToBounds); -} - -bool WebLayerImpl::masksToBounds() const -{ - return m_layer->masksToBounds(); -} - -void WebLayerImpl::setMaskLayer(WebLayer* maskLayer) -{ - m_layer->setMaskLayer(maskLayer ? static_cast<WebLayerImpl*>(maskLayer)->layer() : 0); -} - -void WebLayerImpl::setReplicaLayer(WebLayer* replicaLayer) -{ - m_layer->setReplicaLayer(replicaLayer ? static_cast<WebLayerImpl*>(replicaLayer)->layer() : 0); -} - -void WebLayerImpl::setOpacity(float opacity) -{ - m_layer->setOpacity(opacity); -} - -float WebLayerImpl::opacity() const -{ - return m_layer->opacity(); -} - -void WebLayerImpl::setOpaque(bool opaque) -{ - m_layer->setOpaque(opaque); -} - -bool WebLayerImpl::opaque() const -{ - return m_layer->opaque(); -} - -void WebLayerImpl::setPosition(const WebFloatPoint& position) -{ - m_layer->setPosition(position); -} - -WebFloatPoint WebLayerImpl::position() const -{ - return WebFloatPoint(m_layer->position()); -} - -void WebLayerImpl::setSublayerTransform(const SkMatrix44& matrix) -{ - m_layer->setSublayerTransform(transformationMatrixFromSkMatrix44(matrix)); -} - -void WebLayerImpl::setSublayerTransform(const WebTransformationMatrix& matrix) -{ - m_layer->setSublayerTransform(matrix); -} - -SkMatrix44 WebLayerImpl::sublayerTransform() const -{ - return skMatrix44FromTransformationMatrix(m_layer->sublayerTransform()); -} - -void WebLayerImpl::setTransform(const SkMatrix44& matrix) -{ - m_layer->setTransform(transformationMatrixFromSkMatrix44(matrix)); -} - -void WebLayerImpl::setTransform(const WebTransformationMatrix& matrix) -{ - m_layer->setTransform(matrix); -} - -SkMatrix44 WebLayerImpl::transform() const -{ - return skMatrix44FromTransformationMatrix(m_layer->transform()); -} - -void WebLayerImpl::setDrawsContent(bool drawsContent) -{ - m_layer->setIsDrawable(drawsContent); -} - -bool WebLayerImpl::drawsContent() const -{ - return m_layer->drawsContent(); -} - -void WebLayerImpl::setPreserves3D(bool preserve3D) -{ - m_layer->setPreserves3D(preserve3D); -} - -void WebLayerImpl::setUseParentBackfaceVisibility(bool useParentBackfaceVisibility) -{ - m_layer->setUseParentBackfaceVisibility(useParentBackfaceVisibility); -} - -void WebLayerImpl::setBackgroundColor(WebColor color) -{ - m_layer->setBackgroundColor(color); -} - -void WebLayerImpl::setFilters(const WebFilterOperations& filters) -{ - m_layer->setFilters(filters); -} - -void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) -{ - m_layer->setBackgroundFilters(filters); -} - -void WebLayerImpl::setDebugBorderColor(const WebColor& color) -{ - m_layer->setDebugBorderColor(color); -} - -void WebLayerImpl::setDebugBorderWidth(float width) -{ - m_layer->setDebugBorderWidth(width); -} - -void WebLayerImpl::setDebugName(WebString name) -{ - m_layer->setDebugName(name); -} - -void WebLayerImpl::setAnimationDelegate(WebAnimationDelegate* delegate) -{ - m_layer->setLayerAnimationDelegate(delegate); -} - -bool WebLayerImpl::addAnimation(WebAnimation* animation) -{ - return m_layer->addAnimation(static_cast<WebAnimationImpl*>(animation)->cloneToCCAnimation()); -} - -void WebLayerImpl::removeAnimation(int animationId) -{ - m_layer->removeAnimation(animationId); -} - -void WebLayerImpl::removeAnimation(int animationId, WebAnimation::TargetProperty targetProperty) -{ - m_layer->layerAnimationController()->removeAnimation(animationId, static_cast<CCActiveAnimation::TargetProperty>(targetProperty)); -} - -void WebLayerImpl::pauseAnimation(int animationId, double timeOffset) -{ - m_layer->pauseAnimation(animationId, timeOffset); -} - -void WebLayerImpl::suspendAnimations(double monotonicTime) -{ - m_layer->suspendAnimations(monotonicTime); -} - -void WebLayerImpl::resumeAnimations(double monotonicTime) -{ - m_layer->resumeAnimations(monotonicTime); -} - -bool WebLayerImpl::hasActiveAnimation() -{ - return m_layer->hasActiveAnimation(); -} - -void WebLayerImpl::transferAnimationsTo(WebLayer* other) -{ - ASSERT(other); - static_cast<WebLayerImpl*>(other)->m_layer->setLayerAnimationController(m_layer->releaseLayerAnimationController()); -} - -void WebLayerImpl::setForceRenderSurface(bool forceRenderSurface) -{ - m_layer->setForceRenderSurface(forceRenderSurface); -} - -void WebLayerImpl::setScrollPosition(WebPoint position) -{ - m_layer->setScrollPosition(position); -} - -void WebLayerImpl::setScrollable(bool scrollable) -{ - m_layer->setScrollable(scrollable); -} - -void WebLayerImpl::setHaveWheelEventHandlers(bool haveWheelEventHandlers) -{ - m_layer->setHaveWheelEventHandlers(haveWheelEventHandlers); -} - -void WebLayerImpl::setShouldScrollOnMainThread(bool shouldScrollOnMainThread) -{ - m_layer->setShouldScrollOnMainThread(shouldScrollOnMainThread); -} - -void WebLayerImpl::setNonFastScrollableRegion(const WebVector<WebRect>& rects) -{ - WebCore::Region region; - for (size_t i = 0; i < rects.size(); ++i) { - WebCore::IntRect rect = rects[i]; - region.unite(rect); - } - m_layer->setNonFastScrollableRegion(region); - -} - -void WebLayerImpl::setIsContainerForFixedPositionLayers(bool enable) -{ - m_layer->setIsContainerForFixedPositionLayers(enable); -} - -void WebLayerImpl::setFixedToContainerLayer(bool enable) -{ - m_layer->setFixedToContainerLayer(enable); -} - -LayerChromium* WebLayerImpl::layer() const -{ - return m_layer.get(); } } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebLayerImpl.h b/Source/WebKit/chromium/src/WebLayerImpl.h index 7e3b533bc..7e4e75062 100644 --- a/Source/WebKit/chromium/src/WebLayerImpl.h +++ b/Source/WebKit/chromium/src/WebLayerImpl.h @@ -26,84 +26,18 @@ #ifndef WebLayerImpl_h #define WebLayerImpl_h -#include <public/WebLayer.h> -#include <wtf/RefPtr.h> - -namespace WebCore { -class LayerChromium; -} +#include "LayerChromium.h" +#include <wtf/PassRefPtr.h> namespace WebKit { -class WebLayerImpl : public WebLayer { +class WebLayerImpl : public WebCore::LayerChromium { public: - explicit WebLayerImpl(PassRefPtr<WebCore::LayerChromium>); - virtual ~WebLayerImpl(); - - // WebLayer implementation. - virtual int id() const OVERRIDE; - virtual void invalidateRect(const WebFloatRect&) OVERRIDE; - virtual void invalidate() OVERRIDE; - virtual void addChild(WebLayer*) OVERRIDE; - virtual void insertChild(WebLayer*, size_t index) OVERRIDE; - virtual void replaceChild(WebLayer* reference, WebLayer* newLayer) OVERRIDE; - virtual void setChildren(const WebVector<WebLayer*>&) OVERRIDE; - virtual void removeFromParent() OVERRIDE; - virtual void removeAllChildren() OVERRIDE; - virtual void setAnchorPoint(const WebFloatPoint&) OVERRIDE; - virtual WebFloatPoint anchorPoint() const OVERRIDE; - virtual void setAnchorPointZ(float) OVERRIDE; - virtual float anchorPointZ() const OVERRIDE; - virtual void setBounds(const WebSize&) OVERRIDE; - virtual WebSize bounds() const OVERRIDE; - virtual void setMasksToBounds(bool) OVERRIDE; - virtual bool masksToBounds() const OVERRIDE; - virtual void setMaskLayer(WebLayer*) OVERRIDE; - virtual void setReplicaLayer(WebLayer*) OVERRIDE; - virtual void setOpacity(float) OVERRIDE; - virtual float opacity() const OVERRIDE; - virtual void setOpaque(bool) OVERRIDE; - virtual bool opaque() const OVERRIDE; - virtual void setPosition(const WebFloatPoint&) OVERRIDE; - virtual WebFloatPoint position() const OVERRIDE; - virtual void setSublayerTransform(const SkMatrix44&) OVERRIDE; - virtual void setSublayerTransform(const WebTransformationMatrix&) OVERRIDE; - virtual SkMatrix44 sublayerTransform() const OVERRIDE; - virtual void setTransform(const SkMatrix44&) OVERRIDE; - virtual void setTransform(const WebTransformationMatrix&) OVERRIDE; - virtual SkMatrix44 transform() const OVERRIDE; - virtual void setDrawsContent(bool) OVERRIDE; - virtual bool drawsContent() const OVERRIDE; - virtual void setPreserves3D(bool) OVERRIDE; - virtual void setUseParentBackfaceVisibility(bool) OVERRIDE; - virtual void setBackgroundColor(WebColor) OVERRIDE; - virtual void setFilters(const WebFilterOperations&) OVERRIDE; - virtual void setBackgroundFilters(const WebFilterOperations&) OVERRIDE; - virtual void setDebugBorderColor(const WebColor&) OVERRIDE; - virtual void setDebugBorderWidth(float) OVERRIDE; - virtual void setDebugName(WebString) OVERRIDE; - virtual void setAnimationDelegate(WebAnimationDelegate*) OVERRIDE; - virtual bool addAnimation(WebAnimation*) OVERRIDE; - virtual void removeAnimation(int animationId) OVERRIDE; - virtual void removeAnimation(int animationId, WebAnimation::TargetProperty) OVERRIDE; - virtual void pauseAnimation(int animationId, double timeOffset) OVERRIDE; - virtual void suspendAnimations(double monotonicTime) OVERRIDE; - virtual void resumeAnimations(double monotonicTime) OVERRIDE; - virtual bool hasActiveAnimation() OVERRIDE; - virtual void transferAnimationsTo(WebLayer*) OVERRIDE; - virtual void setForceRenderSurface(bool) OVERRIDE; - virtual void setScrollPosition(WebPoint) OVERRIDE; - virtual void setScrollable(bool) OVERRIDE; - virtual void setHaveWheelEventHandlers(bool) OVERRIDE; - virtual void setShouldScrollOnMainThread(bool) OVERRIDE; - virtual void setNonFastScrollableRegion(const WebVector<WebRect>&) OVERRIDE; - virtual void setIsContainerForFixedPositionLayers(bool) OVERRIDE; - virtual void setFixedToContainerLayer(bool) OVERRIDE; - - WebCore::LayerChromium* layer() const; + static PassRefPtr<WebLayerImpl> create(); protected: - RefPtr<WebCore::LayerChromium> m_layer; + WebLayerImpl(); + virtual ~WebLayerImpl(); }; } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebLayerTreeView.cpp b/Source/WebKit/chromium/src/WebLayerTreeView.cpp index 7dfbcd129..f397e534a 100644 --- a/Source/WebKit/chromium/src/WebLayerTreeView.cpp +++ b/Source/WebKit/chromium/src/WebLayerTreeView.cpp @@ -31,7 +31,6 @@ #include "CCLayerTreeHost.h" #include "CCRenderingStats.h" #include "LayerChromium.h" -#include "WebLayerImpl.h" #include "WebLayerTreeViewImpl.h" #include <public/WebLayer.h> #include <public/WebPoint.h> @@ -84,7 +83,7 @@ void WebLayerTreeView::setSurfaceReady() void WebLayerTreeView::setRootLayer(WebLayer *root) { if (root) - m_private->layerTreeHost()->setRootLayer(static_cast<WebLayerImpl*>(root)->layer()); + m_private->layerTreeHost()->setRootLayer(*root); else m_private->layerTreeHost()->setRootLayer(PassRefPtr<LayerChromium>()); } diff --git a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp index 1fd823976..1f1933fc9 100644 --- a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp @@ -29,7 +29,6 @@ #include "CCLayerTreeHost.h" #include "CCThreadProxy.h" #include "LayerChromium.h" -#include "WebLayerImpl.h" #include <public/WebGraphicsContext3D.h> #include <public/WebLayer.h> #include <public/WebLayerTreeView.h> @@ -143,7 +142,7 @@ PassOwnPtr<WebLayerTreeViewImpl> WebLayerTreeViewImpl::create(WebLayerTreeViewCl OwnPtr<WebLayerTreeViewImpl> impl = adoptPtr(new WebLayerTreeViewImpl(client, settings)); if (!impl->layerTreeHost()) return nullptr; - impl->layerTreeHost()->setRootLayer(static_cast<const WebLayerImpl*>(&root)->layer()); + impl->layerTreeHost()->setRootLayer(root); return impl.release(); } diff --git a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp index cb756233e..4a90a988d 100644 --- a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp +++ b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp @@ -109,9 +109,9 @@ void WebMediaPlayerClientImpl::readyStateChanged() ASSERT(m_mediaPlayer); m_mediaPlayer->readyStateChanged(); #if USE(ACCELERATED_COMPOSITING) - if (hasVideo() && supportsAcceleratedRendering() && !m_videoLayer) { - m_videoLayer = adoptPtr(WebVideoLayer::create(this)); - m_videoLayer->layer()->setOpaque(m_opaque); + if (hasVideo() && supportsAcceleratedRendering() && m_videoLayer.isNull()) { + m_videoLayer = WebVideoLayer::create(this); + m_videoLayer.setOpaque(m_opaque); } #endif } @@ -138,8 +138,8 @@ void WebMediaPlayerClientImpl::repaint() { ASSERT(m_mediaPlayer); #if USE(ACCELERATED_COMPOSITING) - if (m_videoLayer && supportsAcceleratedRendering()) - m_videoLayer->layer()->invalidate(); + if (!m_videoLayer.isNull() && supportsAcceleratedRendering()) + m_videoLayer.invalidate(); #endif m_mediaPlayer->repaint(); } @@ -166,8 +166,8 @@ void WebMediaPlayerClientImpl::setOpaque(bool opaque) { #if USE(ACCELERATED_COMPOSITING) m_opaque = opaque; - if (m_videoLayer) - m_videoLayer->layer()->setOpaque(m_opaque); + if (!m_videoLayer.isNull()) + m_videoLayer.setOpaque(m_opaque); #endif } @@ -343,7 +343,7 @@ void WebMediaPlayerClientImpl::cancelLoad() WebLayer* WebMediaPlayerClientImpl::platformLayer() const { ASSERT(m_supportsAcceleratedCompositing); - return m_videoLayer ? m_videoLayer->layer() : 0; + return const_cast<WebVideoLayer*>(&m_videoLayer); } #endif @@ -745,7 +745,7 @@ bool WebMediaPlayerClientImpl::supportsAcceleratedRendering() const bool WebMediaPlayerClientImpl::acceleratedRenderingInUse() { - return m_videoLayer && m_videoLayer->active(); + return !m_videoLayer.isNull() && m_videoLayer.active(); } void WebMediaPlayerClientImpl::setVideoFrameProviderClient(WebVideoFrameProvider::Client* client) diff --git a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h index 329fd9ec0..373015eb7 100644 --- a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h +++ b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h @@ -205,7 +205,7 @@ private: WebCore::MediaPlayer::Preload m_preload; RefPtr<WebHelperPluginImpl> m_helperPlugin; #if USE(ACCELERATED_COMPOSITING) - OwnPtr<WebVideoLayer> m_videoLayer; + WebVideoLayer m_videoLayer; bool m_supportsAcceleratedCompositing; bool m_opaque; WebVideoFrameProvider::Client* m_videoFrameProviderClient; diff --git a/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp b/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp index 75a97e0f6..a35a0407f 100644 --- a/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp +++ b/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp @@ -366,11 +366,11 @@ void WebPluginContainerImpl::setBackingTextureId(unsigned textureId) if (m_textureId == textureId) return; - ASSERT(!m_ioSurfaceLayer); + ASSERT(m_ioSurfaceLayer.isNull()); - if (!m_textureLayer) - m_textureLayer = adoptPtr(WebExternalTextureLayer::create()); - m_textureLayer->setTextureId(textureId); + if (m_textureLayer.isNull()) + m_textureLayer = WebExternalTextureLayer::create(); + m_textureLayer.setTextureId(textureId); // If anyone of the IDs is zero we need to switch between hardware // and software compositing. This is done by triggering a style recalc @@ -390,11 +390,11 @@ void WebPluginContainerImpl::setBackingIOSurfaceId(int width, if (ioSurfaceId == m_ioSurfaceId) return; - ASSERT(!m_textureLayer); + ASSERT(m_textureLayer.isNull()); - if (!m_ioSurfaceLayer) - m_ioSurfaceLayer = adoptPtr(WebIOSurfaceLayer::create()); - m_ioSurfaceLayer->setIOSurfaceProperties(ioSurfaceId, WebSize(width, height)); + if (m_ioSurfaceLayer.isNull()) + m_ioSurfaceLayer = WebIOSurfaceLayer::create(); + m_ioSurfaceLayer.setIOSurfaceProperties(ioSurfaceId, WebSize(width, height)); // If anyone of the IDs is zero we need to switch between hardware // and software compositing. This is done by triggering a style recalc @@ -409,11 +409,11 @@ void WebPluginContainerImpl::setBackingIOSurfaceId(int width, void WebPluginContainerImpl::commitBackingTexture() { #if USE(ACCELERATED_COMPOSITING) - if (m_textureLayer) - m_textureLayer->layer()->invalidate(); + if (!m_textureLayer.isNull()) + m_textureLayer.invalidate(); - if (m_ioSurfaceLayer) - m_ioSurfaceLayer->layer()->invalidate(); + if (!m_ioSurfaceLayer.isNull()) + m_ioSurfaceLayer.invalidate(); #endif } @@ -480,11 +480,11 @@ void WebPluginContainerImpl::zoomLevelChanged(double zoomLevel) void WebPluginContainerImpl::setOpaque(bool opaque) { #if USE(ACCELERATED_COMPOSITING) - if (m_textureLayer) - m_textureLayer->layer()->setOpaque(opaque); + if (!m_textureLayer.isNull()) + m_textureLayer.setOpaque(opaque); - if (m_ioSurfaceLayer) - m_ioSurfaceLayer->layer()->setOpaque(opaque); + if (!m_ioSurfaceLayer.isNull()) + m_ioSurfaceLayer.setOpaque(opaque); #endif } @@ -575,9 +575,9 @@ void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver WebLayer* WebPluginContainerImpl::platformLayer() const { if (m_textureId) - return m_textureLayer->layer(); + return const_cast<WebExternalTextureLayer*>(&m_textureLayer); if (m_ioSurfaceId) - return m_ioSurfaceLayer->layer(); + return const_cast<WebIOSurfaceLayer*>(&m_ioSurfaceLayer); return 0; } #endif diff --git a/Source/WebKit/chromium/src/WebPluginContainerImpl.h b/Source/WebKit/chromium/src/WebPluginContainerImpl.h index 998be6e41..074a0ccdc 100644 --- a/Source/WebKit/chromium/src/WebPluginContainerImpl.h +++ b/Source/WebKit/chromium/src/WebPluginContainerImpl.h @@ -186,10 +186,10 @@ private: // A composited plugin will either have no composited layer, a texture layer, or an IOSurface layer. // It will never have both a texture and IOSurface output. unsigned m_textureId; - OwnPtr<WebExternalTextureLayer> m_textureLayer; + WebExternalTextureLayer m_textureLayer; unsigned m_ioSurfaceId; - OwnPtr<WebIOSurfaceLayer> m_ioSurfaceLayer; + WebIOSurfaceLayer m_ioSurfaceLayer; #endif // The associated scrollbar group object, created lazily. Used for Pepper diff --git a/Source/WebKit/chromium/src/WebScrollableLayer.cpp b/Source/WebKit/chromium/src/WebScrollableLayer.cpp new file mode 100644 index 000000000..a20e81d81 --- /dev/null +++ b/Source/WebKit/chromium/src/WebScrollableLayer.cpp @@ -0,0 +1,75 @@ +/* + * 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/WebScrollableLayer.h> + +#include "LayerChromium.h" +#include "Region.h" + +namespace WebKit { + +void WebScrollableLayer::setScrollPosition(WebPoint position) +{ + m_private->setScrollPosition(position); +} + +void WebScrollableLayer::setScrollable(bool scrollable) +{ + m_private->setScrollable(scrollable); +} + +void WebScrollableLayer::setHaveWheelEventHandlers(bool haveWheelEventHandlers) +{ + m_private->setHaveWheelEventHandlers(haveWheelEventHandlers); +} + +void WebScrollableLayer::setShouldScrollOnMainThread(bool shouldScrollOnMainThread) +{ + m_private->setShouldScrollOnMainThread(shouldScrollOnMainThread); +} + +void WebScrollableLayer::setNonFastScrollableRegion(const WebVector<WebRect>& rects) +{ + WebCore::Region region; + for (size_t i = 0; i < rects.size(); ++i) { + WebCore::IntRect rect = rects[i]; + region.unite(rect); + } + m_private->setNonFastScrollableRegion(region); + +} + +void WebScrollableLayer::setIsContainerForFixedPositionLayers(bool enable) +{ + m_private->setIsContainerForFixedPositionLayers(enable); +} + +void WebScrollableLayer::setFixedToContainerLayer(bool enable) +{ + m_private->setFixedToContainerLayer(enable); +} + +} // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebScrollbarLayerImpl.cpp b/Source/WebKit/chromium/src/WebScrollbarLayer.cpp index ec6e9895d..2bd1b20fb 100644 --- a/Source/WebKit/chromium/src/WebScrollbarLayerImpl.cpp +++ b/Source/WebKit/chromium/src/WebScrollbarLayer.cpp @@ -24,42 +24,39 @@ */ #include "config.h" -#include "WebScrollbarLayerImpl.h" +#include <public/WebScrollbarLayer.h> #include "ScrollbarLayerChromium.h" -#include "WebLayerImpl.h" -using WebCore::Scrollbar; -using WebCore::ScrollbarLayerChromium; +using namespace WebCore; namespace WebKit { -WebScrollbarLayer* WebScrollbarLayer::create(WebCore::Scrollbar* scrollbar, WebScrollbarThemePainter painter, PassOwnPtr<WebScrollbarThemeGeometry> geometry) +void WebScrollbarLayer::setScrollLayer(const WebLayer layer) { - return new WebScrollbarLayerImpl(ScrollbarLayerChromium::create(WebScrollbar::create(scrollbar), painter, geometry, 0)); + int id = layer.isNull() ? 0 : layer.constUnwrap<LayerChromium>()->id(); + unwrap<ScrollbarLayerChromium>()->setScrollLayerId(id); } - -WebScrollbarLayerImpl::WebScrollbarLayerImpl(PassRefPtr<WebCore::ScrollbarLayerChromium> layer) - : m_layer(adoptPtr(new WebLayerImpl(layer))) +WebScrollbarLayer WebScrollbarLayer::create(WebCore::Scrollbar* scrollbar, WebScrollbarThemePainter painter, PassOwnPtr<WebScrollbarThemeGeometry> geometry) { + return WebScrollbarLayer(ScrollbarLayerChromium::create(WebScrollbar::create(scrollbar), painter, geometry, 0)); } -WebScrollbarLayerImpl::~WebScrollbarLayerImpl() +WebScrollbarLayer::WebScrollbarLayer(const WTF::PassRefPtr<WebCore::ScrollbarLayerChromium>& layer) + : WebLayer(layer) { } -WebLayer* WebScrollbarLayerImpl::layer() +WebScrollbarLayer& WebScrollbarLayer::operator=(const WTF::PassRefPtr<WebCore::ScrollbarLayerChromium>& layer) { - return m_layer.get(); + m_private = layer; + return *this; } -void WebScrollbarLayerImpl::setScrollLayer(WebLayer* layer) +WebScrollbarLayer::operator PassRefPtr<ScrollbarLayerChromium>() const { - int id = layer ? static_cast<WebLayerImpl*>(layer)->layer()->id() : 0; - static_cast<ScrollbarLayerChromium*>(m_layer->layer())->setScrollLayerId(id); + return unwrap<ScrollbarLayerChromium>(); } - - } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebScrollbarLayerImpl.h b/Source/WebKit/chromium/src/WebScrollbarLayerImpl.h deleted file mode 100644 index 720f79c55..000000000 --- a/Source/WebKit/chromium/src/WebScrollbarLayerImpl.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WebScrollbarLayerImpl_h -#define WebScrollbarLayerImpl_h - -#include <public/WebScrollbarLayer.h> -#include <wtf/OwnPtr.h> -#include <wtf/PassRefPtr.h> - -namespace WebCore { -class ScrollbarLayerChromium; -} - -namespace WebKit { -class WebLayerImpl; - -class WebScrollbarLayerImpl : public WebScrollbarLayer { -public: - explicit WebScrollbarLayerImpl(PassRefPtr<WebCore::ScrollbarLayerChromium>); - virtual ~WebScrollbarLayerImpl(); - - // WebScrollbarLayer implementation. - virtual WebLayer* layer() OVERRIDE; - virtual void setScrollLayer(WebLayer*) OVERRIDE; - -private: - OwnPtr<WebLayerImpl> m_layer; -}; - -} - -#endif // WebScrollbarLayerImpl_h diff --git a/Source/WebKit/chromium/src/WebImageLayerImpl.cpp b/Source/WebKit/chromium/src/WebSolidColorLayer.cpp index d93af8045..83914b263 100644 --- a/Source/WebKit/chromium/src/WebImageLayerImpl.cpp +++ b/Source/WebKit/chromium/src/WebSolidColorLayer.cpp @@ -24,37 +24,26 @@ */ #include "config.h" -#include "WebImageLayerImpl.h" +#include <public/WebSolidColorLayer.h> -#include "ImageLayerChromium.h" -#include "WebLayerImpl.h" - -using WebCore::ImageLayerChromium; +#include "WebSolidColorLayerImpl.h" +#include <public/WebFloatRect.h> namespace WebKit { -WebImageLayer* WebImageLayer::create() -{ - return new WebImageLayerImpl(WebCore::ImageLayerChromium::create()); -} - -WebImageLayerImpl::WebImageLayerImpl(PassRefPtr<WebCore::ImageLayerChromium> layer) - : m_layer(adoptPtr(new WebLayerImpl(layer))) -{ -} - -WebImageLayerImpl::~WebImageLayerImpl() +WebSolidColorLayer WebSolidColorLayer::create() { + return WebSolidColorLayer(WebSolidColorLayerImpl::create()); } -WebLayer* WebImageLayerImpl::layer() +WebSolidColorLayer::WebSolidColorLayer(const PassRefPtr<WebSolidColorLayerImpl>& node) + : WebLayer(node) { - return m_layer.get(); } -void WebImageLayerImpl::setBitmap(SkBitmap bitmap) +void WebSolidColorLayer::setBackgroundColor(const WebColor& color) { - static_cast<ImageLayerChromium*>(m_layer->layer())->setBitmap(bitmap); + m_private->setBackgroundColor(color); } } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebSolidColorLayerImpl.cpp b/Source/WebKit/chromium/src/WebSolidColorLayerImpl.cpp index 94404262c..33b1a30e3 100644 --- a/Source/WebKit/chromium/src/WebSolidColorLayerImpl.cpp +++ b/Source/WebKit/chromium/src/WebSolidColorLayerImpl.cpp @@ -26,37 +26,24 @@ #include "config.h" #include "WebSolidColorLayerImpl.h" -#include "SolidColorLayerChromium.h" -#include "WebLayerImpl.h" - -using WebCore::SolidColorLayerChromium; +using namespace WebCore; namespace WebKit { -WebSolidColorLayer* WebSolidColorLayer::create() +PassRefPtr<WebSolidColorLayerImpl> WebSolidColorLayerImpl::create() { - return new WebSolidColorLayerImpl(SolidColorLayerChromium::create()); + return adoptRef(new WebSolidColorLayerImpl()); } -WebSolidColorLayerImpl::WebSolidColorLayerImpl(PassRefPtr<SolidColorLayerChromium> layer) - : m_layer(adoptPtr(new WebLayerImpl(layer))) +WebSolidColorLayerImpl::WebSolidColorLayerImpl() + : SolidColorLayerChromium() { - m_layer->layer()->setIsDrawable(true); + setIsDrawable(true); } WebSolidColorLayerImpl::~WebSolidColorLayerImpl() { } -WebLayer* WebSolidColorLayerImpl::layer() -{ - return m_layer.get(); -} - -void WebSolidColorLayerImpl::setBackgroundColor(WebColor color) -{ - m_layer->setBackgroundColor(color); -} - } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebSolidColorLayerImpl.h b/Source/WebKit/chromium/src/WebSolidColorLayerImpl.h index 7742ba492..d2673b42b 100644 --- a/Source/WebKit/chromium/src/WebSolidColorLayerImpl.h +++ b/Source/WebKit/chromium/src/WebSolidColorLayerImpl.h @@ -26,28 +26,18 @@ #ifndef WebSolidColorLayerImpl_h #define WebSolidColorLayerImpl_h -#include <public/WebSolidColorLayer.h> -#include <wtf/OwnPtr.h> +#include "SolidColorLayerChromium.h" #include <wtf/PassRefPtr.h> -namespace WebCore { -class SolidColorLayerChromium; -} - namespace WebKit { -class WebLayerImpl; -class WebSolidColorLayerImpl : public WebSolidColorLayer { +class WebSolidColorLayerImpl : public WebCore::SolidColorLayerChromium { public: - explicit WebSolidColorLayerImpl(PassRefPtr<WebCore::SolidColorLayerChromium>); - virtual ~WebSolidColorLayerImpl(); + static PassRefPtr<WebSolidColorLayerImpl> create(); - // WebSolidColorLayer implementation. - virtual WebLayer* layer() OVERRIDE; - virtual void setBackgroundColor(WebColor) OVERRIDE; - -private: - OwnPtr<WebLayerImpl> m_layer; +protected: + WebSolidColorLayerImpl(); + virtual ~WebSolidColorLayerImpl(); }; } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebVideoLayerImpl.h b/Source/WebKit/chromium/src/WebVideoLayer.cpp index 287e4b5e2..0f342155d 100644 --- a/Source/WebKit/chromium/src/WebVideoLayerImpl.h +++ b/Source/WebKit/chromium/src/WebVideoLayer.cpp @@ -23,32 +23,25 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebVideoLayerImpl_h -#define WebVideoLayerImpl_h - +#include "config.h" +#include "VideoLayerChromium.h" #include <public/WebVideoLayer.h> -namespace WebCore { -class VideoLayerChromium; -} - namespace WebKit { -class WebLayerImpl; - -class WebVideoLayerImpl : public WebVideoLayer { -public: - explicit WebVideoLayerImpl(PassRefPtr<WebCore::VideoLayerChromium>); - virtual ~WebVideoLayerImpl(); - // WebVideoLayer implementation. - virtual WebLayer* layer() OVERRIDE; - virtual bool active() const OVERRIDE; - -private: - OwnPtr<WebLayerImpl> m_layer; -}; +WebVideoLayer WebVideoLayer::create(WebVideoFrameProvider* provider) +{ + return WebVideoLayer(WebCore::VideoLayerChromium::create(provider)); +} +WebVideoLayer::WebVideoLayer(PassRefPtr<WebCore::VideoLayerChromium> layer) + : WebLayer(layer) +{ } -#endif // WebVideoLayerImpl_h +bool WebVideoLayer::active() const +{ + return m_private->layerTreeHost(); +} +} // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index 97339b342..b18e20944 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -408,7 +408,6 @@ WebViewImpl::WebViewImpl(WebViewClient* client) , m_isCancelingFullScreen(false) , m_benchmarkSupport(this) #if USE(ACCELERATED_COMPOSITING) - , m_rootLayer(0) , m_rootGraphicsLayer(0) , m_isAcceleratedCompositingActive(false) , m_compositorCreationFailed(false) @@ -2215,6 +2214,58 @@ bool WebViewImpl::setEditableSelectionOffsets(int start, int end) return editor->setSelectionOffsets(start, end); } +bool WebViewImpl::setCompositionFromExistingText(int compositionStart, int compositionEnd, const WebVector<WebCompositionUnderline>& underlines) +{ + const Frame* focused = focusedWebCoreFrame(); + if (!focused) + return false; + + Editor* editor = focused->editor(); + if (!editor || !editor->canEdit()) + return false; + + editor->cancelComposition(); + + if (compositionStart == compositionEnd) + return true; + + size_t location; + size_t length; + caretOrSelectionRange(&location, &length); + editor->setIgnoreCompositionSelectionChange(true); + editor->setSelectionOffsets(compositionStart, compositionEnd); + String text = editor->selectedText(); + focused->document()->execCommand("delete", true); + editor->setComposition(text, CompositionUnderlineVectorBuilder(underlines), 0, 0); + editor->setSelectionOffsets(location, location + length); + editor->setIgnoreCompositionSelectionChange(false); + + return true; +} + +void WebViewImpl::extendSelectionAndDelete(int before, int after) +{ + const Frame* focused = focusedWebCoreFrame(); + if (!focused) + return; + + Editor* editor = focused->editor(); + if (!editor || !editor->canEdit()) + return; + + FrameSelection* selection = focused->selection(); + if (!selection) + return; + + size_t location; + size_t length; + RefPtr<Range> range = selection->selection().firstRange(); + if (range && TextIterator::getLocationAndLengthFromRange(selection->rootEditableElement(), range.get(), location, length)) { + editor->setSelectionOffsets(max(static_cast<int>(location) - before, 0), location + length + after); + focused->document()->execCommand("delete", true); + } +} + bool WebViewImpl::isSelectionEditable() const { const Frame* frame = focusedWebCoreFrame(); @@ -3513,7 +3564,6 @@ bool WebViewImpl::allowsAcceleratedCompositing() void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer) { m_rootGraphicsLayer = layer; - m_rootLayer = layer ? layer->platformLayer() : 0; setIsAcceleratedCompositingActive(layer); if (m_nonCompositedContentHost) { @@ -3527,8 +3577,11 @@ void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer) m_nonCompositedContentHost->setScrollLayer(scrollLayer); } + if (layer) + m_rootLayer = *layer->platformLayer(); + if (!m_layerTreeView.isNull()) - m_layerTreeView.setRootLayer(m_rootLayer); + m_layerTreeView.setRootLayer(layer ? &m_rootLayer : 0); IntRect damagedRect(0, 0, m_size.width, m_size.height); if (!m_isAcceleratedCompositingActive) @@ -3641,7 +3694,7 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) m_nonCompositedContentHost->setShowDebugBorders(page()->settings()->showDebugBorders()); m_nonCompositedContentHost->setOpaque(!isTransparent()); - m_layerTreeView.initialize(this, *m_rootLayer, layerTreeViewSettings); + m_layerTreeView.initialize(this, m_rootLayer, layerTreeViewSettings); if (!m_layerTreeView.isNull()) { if (m_webSettings->applyDefaultDeviceScaleFactorInCompositor() && page()->deviceScaleFactor() != 1) { ASSERT(page()->deviceScaleFactor()); diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h index 431dad490..b8dcad717 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.h +++ b/Source/WebKit/chromium/src/WebViewImpl.h @@ -162,6 +162,8 @@ public: virtual WebTextInputInfo textInputInfo(); virtual WebTextInputType textInputType(); virtual bool setEditableSelectionOffsets(int start, int end); + virtual bool setCompositionFromExistingText(int compositionStart, int compositionEnd, const WebVector<WebCompositionUnderline>& underlines); + virtual void extendSelectionAndDelete(int before, int after); virtual bool isSelectionEditable() const; virtual WebColor backgroundColor() const; virtual bool selectionBounds(WebRect& start, WebRect& end) const; @@ -814,7 +816,7 @@ private: WebCore::IntRect m_rootLayerScrollDamage; OwnPtr<NonCompositedContentHost> m_nonCompositedContentHost; WebLayerTreeView m_layerTreeView; - WebLayer* m_rootLayer; + WebLayer m_rootLayer; WebCore::GraphicsLayer* m_rootGraphicsLayer; bool m_isAcceleratedCompositingActive; bool m_compositorCreationFailed; |