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

Side by Side Diff: Source/web/LinkHighlight.cpp

Issue 302993003: Route selection bounds updates through WebLayerTreeView (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 4 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
« no previous file with comments | « Source/web/ChromeClientImpl.cpp ('k') | Source/web/WebRuntimeFeatures.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
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/RenderPart.h" 37 #include "core/rendering/RenderPart.h"
38 #include "core/rendering/RenderView.h" 38 #include "core/rendering/RenderView.h"
39 #include "core/rendering/compositing/CompositedLayerMapping.h" 39 #include "core/rendering/compositing/CompositedLayerMapping.h"
40 #include "core/rendering/compositing/RenderLayerCompositor.h"
40 #include "core/rendering/style/ShadowData.h" 41 #include "core/rendering/style/ShadowData.h"
41 #include "platform/graphics/Color.h" 42 #include "platform/graphics/Color.h"
42 #include "public/platform/Platform.h" 43 #include "public/platform/Platform.h"
43 #include "public/platform/WebAnimationCurve.h" 44 #include "public/platform/WebAnimationCurve.h"
44 #include "public/platform/WebCompositorSupport.h" 45 #include "public/platform/WebCompositorSupport.h"
45 #include "public/platform/WebFloatAnimationCurve.h" 46 #include "public/platform/WebFloatAnimationCurve.h"
46 #include "public/platform/WebFloatPoint.h" 47 #include "public/platform/WebFloatPoint.h"
47 #include "public/platform/WebRect.h" 48 #include "public/platform/WebRect.h"
48 #include "public/platform/WebSize.h" 49 #include "public/platform/WebSize.h"
49 #include "public/web/WebKit.h" 50 #include "public/web/WebKit.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return m_clipLayer.get(); 101 return m_clipLayer.get();
101 } 102 }
102 103
103 void LinkHighlight::releaseResources() 104 void LinkHighlight::releaseResources()
104 { 105 {
105 m_node.clear(); 106 m_node.clear();
106 } 107 }
107 108
108 RenderLayer* LinkHighlight::computeEnclosingCompositingLayer() 109 RenderLayer* LinkHighlight::computeEnclosingCompositingLayer()
109 { 110 {
110 if (!m_node || !m_node->renderer()) 111 RenderLayer* newRenderLayer;
112 GraphicsLayer* newGraphicsLayer;
113 if (!RenderLayerCompositor::computeEnclosingCompositingLayer(m_node.get(), n ewRenderLayer, newGraphicsLayer))
111 return 0; 114 return 0;
112 115
113 // Find the nearest enclosing composited layer and attach to it. We may need to cross frame boundaries
114 // to find a suitable layer.
115 RenderObject* renderer = m_node->renderer();
116 RenderLayer* renderLayer;
117 do {
118 renderLayer = renderer->enclosingLayer()->enclosingLayerForPaintInvalida tion();
119 if (!renderLayer) {
120 renderer = renderer->frame()->ownerRenderer();
121 if (!renderer)
122 return 0;
123 }
124 } while (!renderLayer);
125
126 ASSERT(renderLayer->compositingState() != NotComposited);
127
128 GraphicsLayer* newGraphicsLayer = renderLayer->graphicsLayerBacking();
129 if (!newGraphicsLayer->drawsContent()) {
130 newGraphicsLayer = renderLayer->graphicsLayerBackingForScrolling();
131 }
132
133 m_clipLayer->setTransform(SkMatrix44(SkMatrix44::kIdentity_Constructor)); 116 m_clipLayer->setTransform(SkMatrix44(SkMatrix44::kIdentity_Constructor));
134 117
135 if (m_currentGraphicsLayer != newGraphicsLayer) { 118 if (m_currentGraphicsLayer != newGraphicsLayer) {
136 if (m_currentGraphicsLayer) 119 if (m_currentGraphicsLayer)
137 clearGraphicsLayerLinkHighlightPointer(); 120 clearGraphicsLayerLinkHighlightPointer();
138 121
139 m_currentGraphicsLayer = newGraphicsLayer; 122 m_currentGraphicsLayer = newGraphicsLayer;
140 m_currentGraphicsLayer->addLinkHighlight(this); 123 m_currentGraphicsLayer->addLinkHighlight(this);
141 } 124 }
142 125
143 return renderLayer; 126 return newRenderLayer;
144 }
145
146 static void convertTargetSpaceQuadToCompositedLayer(const FloatQuad& targetSpace Quad, RenderObject* targetRenderer, RenderObject* compositedRenderer, FloatQuad& compositedSpaceQuad)
147 {
148 ASSERT(targetRenderer);
149 ASSERT(compositedRenderer);
150
151 for (unsigned i = 0; i < 4; ++i) {
152 IntPoint point;
153 switch (i) {
154 case 0: point = roundedIntPoint(targetSpaceQuad.p1()); break;
155 case 1: point = roundedIntPoint(targetSpaceQuad.p2()); break;
156 case 2: point = roundedIntPoint(targetSpaceQuad.p3()); break;
157 case 3: point = roundedIntPoint(targetSpaceQuad.p4()); break;
158 }
159
160 point = targetRenderer->frame()->view()->contentsToWindow(point);
161 point = compositedRenderer->frame()->view()->windowToContents(point);
162 FloatPoint floatPoint = compositedRenderer->absoluteToLocal(point, UseTr ansforms);
163
164 switch (i) {
165 case 0: compositedSpaceQuad.setP1(floatPoint); break;
166 case 1: compositedSpaceQuad.setP2(floatPoint); break;
167 case 2: compositedSpaceQuad.setP3(floatPoint); break;
168 case 3: compositedSpaceQuad.setP4(floatPoint); break;
169 }
170 }
171 } 127 }
172 128
173 static void addQuadToPath(const FloatQuad& quad, Path& path) 129 static void addQuadToPath(const FloatQuad& quad, Path& path)
174 { 130 {
175 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca se. 131 // FIXME: Make this create rounded quad-paths, just like the axis-aligned ca se.
176 path.moveTo(quad.p1()); 132 path.moveTo(quad.p1());
177 path.addLineTo(quad.p2()); 133 path.addLineTo(quad.p2());
178 path.addLineTo(quad.p3()); 134 path.addLineTo(quad.p3());
179 path.addLineTo(quad.p4()); 135 path.addLineTo(quad.p4());
180 path.closeSubpath(); 136 path.closeSubpath();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // Adjust for offset between target graphics layer and the node's renderer. 172 // Adjust for offset between target graphics layer and the node's renderer.
217 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende rer()); 173 FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRende rer());
218 174
219 Path newPath; 175 Path newPath;
220 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { 176 for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) {
221 FloatQuad absoluteQuad = quads[quadIndex]; 177 FloatQuad absoluteQuad = quads[quadIndex];
222 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y()); 178 absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y());
223 179
224 // Transform node quads in target absolute coords to local coordinates i n the compositor layer. 180 // Transform node quads in target absolute coords to local coordinates i n the compositor layer.
225 FloatQuad transformedQuad; 181 FloatQuad transformedQuad;
226 convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->renderer() , compositingLayer->renderer(), transformedQuad); 182 RenderLayerCompositor::convertTargetSpaceQuadToCompositedLayer(absoluteQ uad, m_node->renderer(), compositingLayer->renderer(), transformedQuad);
227 183
228 // FIXME: for now, we'll only use rounded paths if we have a single node quad. The reason for this is that 184 // FIXME: for now, we'll only use rounded paths if we have a single node quad. The reason for this is that
229 // we may sometimes get a chain of adjacent boxes (e.g. for text nodes) which end up looking like sausage 185 // we may sometimes get a chain of adjacent boxes (e.g. for text nodes) which end up looking like sausage
230 // links: these should ideally be merged into a single rect before creat ing the path, but that's 186 // links: these should ideally be merged into a single rect before creat ing the path, but that's
231 // another CL. 187 // another CL.
232 if (quads.size() == 1 && transformedQuad.isRectilinear()) { 188 if (quads.size() == 1 && transformedQuad.isRectilinear()) {
233 FloatSize rectRoundingRadii(3, 3); 189 FloatSize rectRoundingRadii(3, 3);
234 newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRa dii); 190 newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRa dii);
235 } else 191 } else
236 addQuadToPath(transformedQuad, newPath); 192 addQuadToPath(transformedQuad, newPath);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // Make sure we update geometry on the next callback from WebViewImpl::layou t(). 308 // Make sure we update geometry on the next callback from WebViewImpl::layou t().
353 m_geometryNeedsUpdate = true; 309 m_geometryNeedsUpdate = true;
354 } 310 }
355 311
356 WebLayer* LinkHighlight::layer() 312 WebLayer* LinkHighlight::layer()
357 { 313 {
358 return clipLayer(); 314 return clipLayer();
359 } 315 }
360 316
361 } // namespace WeKit 317 } // namespace WeKit
OLDNEW
« no previous file with comments | « Source/web/ChromeClientImpl.cpp ('k') | Source/web/WebRuntimeFeatures.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698