Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Side by Side Diff: Source/WebKit/chromium/src/NonCompositedContentHost.cpp

Issue 13959008: Remove NonCompositedContentHost (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Adding back LCD text workaround Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"
27
28 #include "NonCompositedContentHost.h"
29
30 #include "FloatPoint.h"
31 #include "FloatRect.h"
32 #include "GraphicsLayer.h"
33 #include "GraphicsLayerChromium.h"
34 #include "PlatformContextSkia.h"
35 #include "Settings.h"
36 #include "WebViewImpl.h"
37 #include <public/WebContentLayer.h>
38 #include <public/WebFloatPoint.h>
39
40 namespace WebKit {
41
42 NonCompositedContentHost::NonCompositedContentHost(WebViewImpl* webView, WebCore ::GraphicsLayerFactory* graphicsLayerFactory)
43 : m_webView(webView)
44 , m_showDebugBorders(false)
45 {
46 m_graphicsLayer = WebCore::GraphicsLayer::create(graphicsLayerFactory, this) ;
47 #ifndef NDEBUG
48 m_graphicsLayer->setName("non-composited content");
49 #endif
50 m_graphicsLayer->setDrawsContent(true);
51 m_graphicsLayer->setContentsOpaque(true);
52 // FIXME: Remove LCD text setting after it is implemented in chromium.
53 WebContentLayer* layer = static_cast<WebCore::GraphicsLayerChromium*>(m_grap hicsLayer.get())->contentLayer();
54 layer->setUseLCDText(true);
55 #if !OS(ANDROID)
56 layer->setDrawCheckerboardForMissingTiles(true);
57 #endif
58 }
59
60 NonCompositedContentHost::~NonCompositedContentHost()
61 {
62 }
63
64 WebCore::Color NonCompositedContentHost::backgroundColor() const {
65 return m_graphicsLayer->platformLayer()->backgroundColor();
66 }
67
68 void NonCompositedContentHost::setBackgroundColor(const WebCore::Color& color)
69 {
70 m_graphicsLayer->platformLayer()->setBackgroundColor(color.rgb());
71 }
72
73 void NonCompositedContentHost::setOpaque(bool opaque)
74 {
75 m_graphicsLayer->setContentsOpaque(opaque);
76 }
77
78 void NonCompositedContentHost::setScrollLayer(WebCore::GraphicsLayer* layer)
79 {
80 m_graphicsLayer->setNeedsDisplay();
81
82 if (!layer) {
83 m_graphicsLayer->removeFromParent();
84 return;
85 }
86
87 if (layer->platformLayer() == scrollLayer())
88 return;
89
90 layer->addChildAtIndex(m_graphicsLayer.get(), 0);
91 ASSERT(haveScrollLayer());
92 }
93
94 void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin)
95 {
96 if (!haveScrollLayer())
97 return;
98
99 bool visibleRectChanged = m_viewportSize != viewportSize;
100
101 m_viewportSize = viewportSize;
102 WebLayer* layer = scrollLayer();
103 layer->setScrollPosition(scrollPosition + scrollOrigin);
104 layer->setPosition(WebFloatPoint(-scrollPosition));
105 // Due to the possibility of pinch zoom, the noncomposited layer is always
106 // assumed to be scrollable.
107 layer->setScrollable(true);
108 m_graphicsLayer->setSize(contentsSize);
109
110 // In RTL-style pages, the origin of the initial containing block for the
111 // root layer may be positive; translate the layer to avoid negative
112 // coordinates.
113 m_layerAdjust = -toIntSize(scrollOrigin);
114 if (m_graphicsLayer->transform().m41() != m_layerAdjust.width() || m_graphic sLayer->transform().m42() != m_layerAdjust.height()) {
115 WebCore::TransformationMatrix transform = m_graphicsLayer->transform();
116 transform.setM41(m_layerAdjust.width());
117 transform.setM42(m_layerAdjust.height());
118 m_graphicsLayer->setTransform(transform);
119
120 // If a tiled layer is shifted left or right, the content that goes into
121 // each tile will change. Invalidate the entire layer when this happens.
122 m_graphicsLayer->setNeedsDisplay();
123 } else if (visibleRectChanged)
124 m_graphicsLayer->setNeedsDisplay();
125 }
126
127 bool NonCompositedContentHost::haveScrollLayer()
128 {
129 return m_graphicsLayer->parent();
130 }
131
132 WebLayer* NonCompositedContentHost::scrollLayer()
133 {
134 if (!m_graphicsLayer->parent())
135 return 0;
136 return m_graphicsLayer->parent()->platformLayer();
137 }
138
139 void NonCompositedContentHost::invalidateRect(const WebCore::IntRect& rect)
140 {
141 WebCore::IntRect layerRect = rect;
142 layerRect.move(-m_layerAdjust);
143 m_graphicsLayer->setNeedsDisplayInRect(WebCore::FloatRect(layerRect));
144 }
145
146 void NonCompositedContentHost::notifyAnimationStarted(const WebCore::GraphicsLay er*, double /* time */)
147 {
148 // Intentionally left empty since we don't support animations on the non-com posited content.
149 }
150
151 void NonCompositedContentHost::paintContents(const WebCore::GraphicsLayer*, WebC ore::GraphicsContext& context, WebCore::GraphicsLayerPaintingPhase, const WebCor e::IntRect& clipRect)
152 {
153 context.translate(-m_layerAdjust);
154 WebCore::IntRect adjustedClipRect = clipRect;
155 adjustedClipRect.move(m_layerAdjust);
156 m_webView->paintRootLayer(context, adjustedClipRect);
157 }
158
159 void NonCompositedContentHost::setShowDebugBorders(bool showDebugBorders)
160 {
161 m_showDebugBorders = showDebugBorders;
162 m_graphicsLayer->updateDebugIndicators();
163 }
164
165 bool NonCompositedContentHost::isTrackingRepaints() const
166 {
167 return m_webView->isTrackingRepaints();
168 }
169
170 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698