OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 18 matching lines...) Expand all Loading... | |
29 | 29 |
30 #include "SkMatrix44.h" | 30 #include "SkMatrix44.h" |
31 #include "core/dom/Node.h" | 31 #include "core/dom/Node.h" |
32 #include "core/frame/FrameView.h" | 32 #include "core/frame/FrameView.h" |
33 #include "core/frame/LocalFrame.h" | 33 #include "core/frame/LocalFrame.h" |
34 #include "core/rendering/RenderLayer.h" | 34 #include "core/rendering/RenderLayer.h" |
35 #include "core/rendering/RenderLayerModelObject.h" | 35 #include "core/rendering/RenderLayerModelObject.h" |
36 #include "core/rendering/RenderObject.h" | 36 #include "core/rendering/RenderObject.h" |
37 #include "core/rendering/RenderView.h" | 37 #include "core/rendering/RenderView.h" |
38 #include "core/rendering/compositing/CompositedLayerMapping.h" | 38 #include "core/rendering/compositing/CompositedLayerMapping.h" |
39 #include "core/rendering/compositing/RenderLayerCompositor.h" | |
39 #include "core/rendering/style/ShadowData.h" | 40 #include "core/rendering/style/ShadowData.h" |
40 #include "platform/graphics/Color.h" | 41 #include "platform/graphics/Color.h" |
41 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
42 #include "public/platform/WebAnimationCurve.h" | 43 #include "public/platform/WebAnimationCurve.h" |
43 #include "public/platform/WebCompositorSupport.h" | 44 #include "public/platform/WebCompositorSupport.h" |
44 #include "public/platform/WebFloatAnimationCurve.h" | 45 #include "public/platform/WebFloatAnimationCurve.h" |
45 #include "public/platform/WebFloatPoint.h" | 46 #include "public/platform/WebFloatPoint.h" |
46 #include "public/platform/WebRect.h" | 47 #include "public/platform/WebRect.h" |
47 #include "public/platform/WebSize.h" | 48 #include "public/platform/WebSize.h" |
48 #include "public/web/WebKit.h" | 49 #include "public/web/WebKit.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 WebLayer* LinkHighlight::clipLayer() | 98 WebLayer* LinkHighlight::clipLayer() |
98 { | 99 { |
99 return m_clipLayer.get(); | 100 return m_clipLayer.get(); |
100 } | 101 } |
101 | 102 |
102 void LinkHighlight::releaseResources() | 103 void LinkHighlight::releaseResources() |
103 { | 104 { |
104 m_node.clear(); | 105 m_node.clear(); |
105 } | 106 } |
106 | 107 |
107 RenderLayer* LinkHighlight::computeEnclosingCompositingLayer() | 108 RenderLayer* LinkHighlight::computeEnclosingCompositingLayer() |
abarth-chromium
2014/06/13 21:38:15
LinkHighlight is hacked into the system. It's not
jdduke (slow)
2014/06/20 17:15:59
OK, I was pointed to LinkHighlight as a model of h
| |
108 { | 109 { |
109 if (!m_node || !m_node->renderer()) | 110 RenderLayer* newRenderLayer; |
111 GraphicsLayer* newGraphicsLayer; | |
112 if (!RenderLayerCompositor::computeEnclosingCompositingLayer(m_node.get(), n ewRenderLayer, newGraphicsLayer)) | |
110 return 0; | 113 return 0; |
111 | 114 |
112 // Find the nearest enclosing composited layer and attach to it. We may need to cross frame boundaries | |
113 // to find a suitable layer. | |
114 RenderObject* renderer = m_node->renderer(); | |
115 RenderLayer* renderLayer; | |
116 do { | |
117 renderLayer = renderer->enclosingLayer()->enclosingCompositingLayerForRe paint(); | |
118 if (!renderLayer) { | |
119 renderer = renderer->frame()->ownerRenderer(); | |
120 if (!renderer) | |
121 return 0; | |
122 } | |
123 } while (!renderLayer); | |
124 | |
125 CompositedLayerMappingPtr compositedLayerMapping = renderLayer->compositingS tate() == PaintsIntoGroupedBacking ? renderLayer->groupedMapping() : renderLayer ->compositedLayerMapping(); | |
126 GraphicsLayer* newGraphicsLayer = renderLayer->compositingState() == PaintsI ntoGroupedBacking ? compositedLayerMapping->squashingLayer() : compositedLayerMa pping->mainGraphicsLayer(); | |
127 | |
128 m_clipLayer->setTransform(SkMatrix44(SkMatrix44::kIdentity_Constructor)); | 115 m_clipLayer->setTransform(SkMatrix44(SkMatrix44::kIdentity_Constructor)); |
129 | 116 |
130 if (!newGraphicsLayer->drawsContent()) { | |
131 if (renderLayer->scrollableArea() && renderLayer->scrollableArea()->uses CompositedScrolling()) { | |
132 ASSERT(renderLayer->hasCompositedLayerMapping() && renderLayer->comp ositedLayerMapping()->scrollingContentsLayer()); | |
133 newGraphicsLayer = compositedLayerMapping->scrollingContentsLayer(); | |
134 } | |
135 } | |
136 | |
137 if (m_currentGraphicsLayer != newGraphicsLayer) { | 117 if (m_currentGraphicsLayer != newGraphicsLayer) { |
138 if (m_currentGraphicsLayer) | 118 if (m_currentGraphicsLayer) |
139 clearGraphicsLayerLinkHighlightPointer(); | 119 clearGraphicsLayerLinkHighlightPointer(); |
140 | 120 |
141 m_currentGraphicsLayer = newGraphicsLayer; | 121 m_currentGraphicsLayer = newGraphicsLayer; |
142 m_currentGraphicsLayer->addLinkHighlight(this); | 122 m_currentGraphicsLayer->addLinkHighlight(this); |
143 } | 123 } |
144 | 124 |
145 return renderLayer; | 125 return newRenderLayer; |
146 } | |
147 | |
148 static void convertTargetSpaceQuadToCompositedLayer(const FloatQuad& targetSpace Quad, RenderObject* targetRenderer, RenderObject* compositedRenderer, FloatQuad& compositedSpaceQuad) | |
149 { | |
150 ASSERT(targetRenderer); | |
151 ASSERT(compositedRenderer); | |
152 | |
153 for (unsigned i = 0; i < 4; ++i) { | |
154 IntPoint point; | |
155 switch (i) { | |
156 case 0: point = roundedIntPoint(targetSpaceQuad.p1()); break; | |
157 case 1: point = roundedIntPoint(targetSpaceQuad.p2()); break; | |
158 case 2: point = roundedIntPoint(targetSpaceQuad.p3()); break; | |
159 case 3: point = roundedIntPoint(targetSpaceQuad.p4()); break; | |
160 } | |
161 | |
162 point = targetRenderer->frame()->view()->contentsToWindow(point); | |
163 point = compositedRenderer->frame()->view()->windowToContents(point); | |
164 FloatPoint floatPoint = compositedRenderer->absoluteToLocal(point, UseTr ansforms); | |
165 | |
166 switch (i) { | |
167 case 0: compositedSpaceQuad.setP1(floatPoint); break; | |
168 case 1: compositedSpaceQuad.setP2(floatPoint); break; | |
169 case 2: compositedSpaceQuad.setP3(floatPoint); break; | |
170 case 3: compositedSpaceQuad.setP4(floatPoint); break; | |
171 } | |
172 } | |
173 } | 126 } |
174 | 127 |
175 static void addQuadToPath(const FloatQuad& quad, Path& path) | 128 static void addQuadToPath(const FloatQuad& quad, Path& path) |
176 { | 129 { |
177 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca se. | 130 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca se. |
178 path.moveTo(quad.p1()); | 131 path.moveTo(quad.p1()); |
179 path.addLineTo(quad.p2()); | 132 path.addLineTo(quad.p2()); |
180 path.addLineTo(quad.p3()); | 133 path.addLineTo(quad.p3()); |
181 path.addLineTo(quad.p4()); | 134 path.addLineTo(quad.p4()); |
182 path.closeSubpath(); | 135 path.closeSubpath(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 // Adjust for offset between target graphics layer and the node's renderer. | 171 // Adjust for offset between target graphics layer and the node's renderer. |
219 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende rer()); | 172 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende rer()); |
220 | 173 |
221 Path newPath; | 174 Path newPath; |
222 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { | 175 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { |
223 FloatQuad absoluteQuad = quads[quadIndex]; | 176 FloatQuad absoluteQuad = quads[quadIndex]; |
224 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y()); | 177 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y()); |
225 | 178 |
226 // Transform node quads in target absolute coords to local coordinates i n the compositor layer. | 179 // Transform node quads in target absolute coords to local coordinates i n the compositor layer. |
227 FloatQuad transformedQuad; | 180 FloatQuad transformedQuad; |
228 convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->renderer() , compositingLayer->renderer(), transformedQuad); | 181 RenderLayerCompositor::convertTargetSpaceQuadToCompositedLayer(absoluteQ uad, m_node->renderer(), compositingLayer->renderer(), transformedQuad); |
229 | 182 |
230 // FIXME: for now, we'll only use rounded paths if we have a single node quad. The reason for this is that | 183 // FIXME: for now, we'll only use rounded paths if we have a single node quad. The reason for this is that |
231 // we may sometimes get a chain of adjacent boxes (e.g. for text nodes) which end up looking like sausage | 184 // we may sometimes get a chain of adjacent boxes (e.g. for text nodes) which end up looking like sausage |
232 // links: these should ideally be merged into a single rect before creat ing the path, but that's | 185 // links: these should ideally be merged into a single rect before creat ing the path, but that's |
233 // another CL. | 186 // another CL. |
234 if (quads.size() == 1 && transformedQuad.isRectilinear()) { | 187 if (quads.size() == 1 && transformedQuad.isRectilinear()) { |
235 FloatSize rectRoundingRadii(3, 3); | 188 FloatSize rectRoundingRadii(3, 3); |
236 newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRa dii); | 189 newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRa dii); |
237 } else | 190 } else |
238 addQuadToPath(transformedQuad, newPath); | 191 addQuadToPath(transformedQuad, newPath); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 // Make sure we update geometry on the next callback from WebViewImpl::layou t(). | 307 // Make sure we update geometry on the next callback from WebViewImpl::layou t(). |
355 m_geometryNeedsUpdate = true; | 308 m_geometryNeedsUpdate = true; |
356 } | 309 } |
357 | 310 |
358 WebLayer* LinkHighlight::layer() | 311 WebLayer* LinkHighlight::layer() |
359 { | 312 { |
360 return clipLayer(); | 313 return clipLayer(); |
361 } | 314 } |
362 | 315 |
363 } // namespace WeKit | 316 } // namespace WeKit |
OLD | NEW |