| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 if (m_currentGraphicsLayer != newGraphicsLayer) { | 151 if (m_currentGraphicsLayer != newGraphicsLayer) { |
| 152 if (m_currentGraphicsLayer) | 152 if (m_currentGraphicsLayer) |
| 153 clearGraphicsLayerLinkHighlightPointer(); | 153 clearGraphicsLayerLinkHighlightPointer(); |
| 154 | 154 |
| 155 m_currentGraphicsLayer = newGraphicsLayer; | 155 m_currentGraphicsLayer = newGraphicsLayer; |
| 156 m_currentGraphicsLayer->addLinkHighlight(this); | 156 m_currentGraphicsLayer->addLinkHighlight(this); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 static void convertTargetSpaceQuadToCompositedLayer( | |
| 161 const FloatQuad& targetSpaceQuad, | |
| 162 LayoutObject* targetLayoutObject, | |
| 163 const LayoutBoxModelObject& paintInvalidationContainer, | |
| 164 FloatQuad& compositedSpaceQuad) { | |
| 165 DCHECK(targetLayoutObject); | |
| 166 for (unsigned i = 0; i < 4; ++i) { | |
| 167 IntPoint point; | |
| 168 switch (i) { | |
| 169 case 0: | |
| 170 point = roundedIntPoint(targetSpaceQuad.p1()); | |
| 171 break; | |
| 172 case 1: | |
| 173 point = roundedIntPoint(targetSpaceQuad.p2()); | |
| 174 break; | |
| 175 case 2: | |
| 176 point = roundedIntPoint(targetSpaceQuad.p3()); | |
| 177 break; | |
| 178 case 3: | |
| 179 point = roundedIntPoint(targetSpaceQuad.p4()); | |
| 180 break; | |
| 181 } | |
| 182 | |
| 183 // FIXME: this does not need to be absolute, just in the paint invalidation | |
| 184 // container's space. | |
| 185 point = targetLayoutObject->frame()->view()->contentsToRootFrame(point); | |
| 186 point = | |
| 187 paintInvalidationContainer.frame()->view()->rootFrameToContents(point); | |
| 188 FloatPoint floatPoint = | |
| 189 paintInvalidationContainer.absoluteToLocal(point, UseTransforms); | |
| 190 PaintLayer::mapPointInPaintInvalidationContainerToBacking( | |
| 191 paintInvalidationContainer, floatPoint); | |
| 192 | |
| 193 switch (i) { | |
| 194 case 0: | |
| 195 compositedSpaceQuad.setP1(floatPoint); | |
| 196 break; | |
| 197 case 1: | |
| 198 compositedSpaceQuad.setP2(floatPoint); | |
| 199 break; | |
| 200 case 2: | |
| 201 compositedSpaceQuad.setP3(floatPoint); | |
| 202 break; | |
| 203 case 3: | |
| 204 compositedSpaceQuad.setP4(floatPoint); | |
| 205 break; | |
| 206 } | |
| 207 } | |
| 208 } | |
| 209 | |
| 210 static void addQuadToPath(const FloatQuad& quad, Path& path) { | 160 static void addQuadToPath(const FloatQuad& quad, Path& path) { |
| 211 // FIXME: Make this create rounded quad-paths, just like the axis-aligned | 161 // FIXME: Make this create rounded quad-paths, just like the axis-aligned |
| 212 // case. | 162 // case. |
| 213 path.moveTo(quad.p1()); | 163 path.moveTo(quad.p1()); |
| 214 path.addLineTo(quad.p2()); | 164 path.addLineTo(quad.p2()); |
| 215 path.addLineTo(quad.p3()); | 165 path.addLineTo(quad.p3()); |
| 216 path.addLineTo(quad.p4()); | 166 path.addLineTo(quad.p4()); |
| 217 path.closeSubpath(); | 167 path.closeSubpath(); |
| 218 } | 168 } |
| 219 | 169 |
| 220 void LinkHighlightImpl::computeQuads(const Node& node, | 170 void LinkHighlightImpl::computeQuads(const Node& node, |
| 221 Vector<FloatQuad>& outQuads) const { | 171 Vector<FloatQuad>& outQuads) const { |
| 222 if (!node.layoutObject()) | 172 if (!node.layoutObject()) |
| 223 return; | 173 return; |
| 224 | 174 |
| 225 LayoutObject* layoutObject = node.layoutObject(); | 175 LayoutObject* layoutObject = node.layoutObject(); |
| 226 | 176 |
| 227 // For inline elements, absoluteQuads will return a line box based on the | 177 // For inline elements, absoluteQuads will return a line box based on the |
| 228 // line-height and font metrics, which is technically incorrect as replaced | 178 // line-height and font metrics, which is technically incorrect as replaced |
| 229 // elements like images should use their intristic height and expand the | 179 // elements like images should use their intristic height and expand the |
| 230 // linebox as needed. To get an appropriately sized highlight we descend | 180 // linebox as needed. To get an appropriately sized highlight we descend |
| 231 // into the children and have them add their boxes. | 181 // into the children and have them add their boxes. |
| 232 if (layoutObject->isLayoutInline()) { | 182 if (layoutObject->isLayoutInline()) { |
| 233 for (Node* child = LayoutTreeBuilderTraversal::firstChild(node); child; | 183 for (Node* child = LayoutTreeBuilderTraversal::firstChild(node); child; |
| 234 child = LayoutTreeBuilderTraversal::nextSibling(*child)) | 184 child = LayoutTreeBuilderTraversal::nextSibling(*child)) |
| 235 computeQuads(*child, outQuads); | 185 computeQuads(*child, outQuads); |
| 236 } else { | 186 } else { |
| 237 // FIXME: this does not need to be absolute, just in the paint invalidation | 187 // FIXME: this does not need to be absolute, just in the paint invalidation |
| 238 // container's space. | 188 // container's space. |
| 239 layoutObject->absoluteQuads(outQuads); | 189 layoutObject->absoluteQuads(outQuads, TraverseDocumentBoundaries); |
| 240 } | 190 } |
| 241 } | 191 } |
| 242 | 192 |
| 243 bool LinkHighlightImpl::computeHighlightLayerPathAndPosition( | 193 bool LinkHighlightImpl::computeHighlightLayerPathAndPosition( |
| 244 const LayoutBoxModelObject& paintInvalidationContainer) { | 194 const LayoutBoxModelObject& paintInvalidationContainer) { |
| 245 if (!m_node || !m_node->layoutObject() || !m_currentGraphicsLayer) | 195 if (!m_node || !m_node->layoutObject() || !m_currentGraphicsLayer) |
| 246 return false; | 196 return false; |
| 247 | 197 |
| 248 // FIXME: This is defensive code to avoid crashes such as those described in | 198 // FIXME: This is defensive code to avoid crashes such as those described in |
| 249 // crbug.com/440887. This should be cleaned up once we fix the root cause of | 199 // crbug.com/440887. This should be cleaned up once we fix the root cause of |
| (...skipping 13 matching lines...) Expand all Loading... |
| 263 | 213 |
| 264 // Scrolling content layers have the same offset from layout object as the | 214 // Scrolling content layers have the same offset from layout object as the |
| 265 // non-scrolling layers. Thus we need to adjust for their scroll offset. | 215 // non-scrolling layers. Thus we need to adjust for their scroll offset. |
| 266 if (m_isScrollingGraphicsLayer) { | 216 if (m_isScrollingGraphicsLayer) { |
| 267 FloatPoint scrollPosition = paintInvalidationContainer.layer() | 217 FloatPoint scrollPosition = paintInvalidationContainer.layer() |
| 268 ->getScrollableArea() | 218 ->getScrollableArea() |
| 269 ->scrollPosition(); | 219 ->scrollPosition(); |
| 270 absoluteQuad.move(toScrollOffset(scrollPosition)); | 220 absoluteQuad.move(toScrollOffset(scrollPosition)); |
| 271 } | 221 } |
| 272 | 222 |
| 273 // Transform node quads in target absolute coords to local coordinates in | 223 absoluteQuad.setP1(roundedIntPoint(absoluteQuad.p1())); |
| 274 // the compositor layer. | 224 absoluteQuad.setP2(roundedIntPoint(absoluteQuad.p2())); |
| 275 FloatQuad transformedQuad; | 225 absoluteQuad.setP3(roundedIntPoint(absoluteQuad.p3())); |
| 276 convertTargetSpaceQuadToCompositedLayer( | 226 absoluteQuad.setP4(roundedIntPoint(absoluteQuad.p4())); |
| 277 absoluteQuad, m_node->layoutObject(), paintInvalidationContainer, | 227 FloatQuad transformedQuad = paintInvalidationContainer.absoluteToLocalQuad( |
| 278 transformedQuad); | 228 absoluteQuad, UseTransforms | TraverseDocumentBoundaries); |
| 229 FloatPoint offsetToBacking; |
| 230 |
| 231 // Adjust for squashing. |
| 232 if (paintInvalidationContainer.layer()->groupedMapping()) { |
| 233 PaintLayer::mapPointInPaintInvalidationContainerToBacking( |
| 234 paintInvalidationContainer, offsetToBacking); |
| 235 } |
| 236 |
| 237 // Adjust for offset from LayoutObject. |
| 238 offsetToBacking.move(-m_currentGraphicsLayer->offsetFromLayoutObject()); |
| 239 |
| 240 transformedQuad.move(toFloatSize(offsetToBacking)); |
| 279 | 241 |
| 280 // FIXME: for now, we'll only use rounded paths if we have a single node | 242 // FIXME: for now, we'll only use rounded paths if we have a single node |
| 281 // quad. The reason for this is that we may sometimes get a chain of | 243 // quad. The reason for this is that we may sometimes get a chain of |
| 282 // adjacent boxes (e.g. for text nodes) which end up looking like sausage | 244 // adjacent boxes (e.g. for text nodes) which end up looking like sausage |
| 283 // links: these should ideally be merged into a single rect before creating | 245 // links: these should ideally be merged into a single rect before creating |
| 284 // the path, but that's another CL. | 246 // the path, but that's another CL. |
| 285 if (quads.size() == 1 && transformedQuad.isRectilinear() && | 247 if (quads.size() == 1 && transformedQuad.isRectilinear() && |
| 286 !m_owningWebViewImpl->settingsImpl() | 248 !m_owningWebViewImpl->settingsImpl() |
| 287 ->mockGestureTapHighlightsEnabled()) { | 249 ->mockGestureTapHighlightsEnabled()) { |
| 288 FloatSize rectRoundingRadii(3, 3); | 250 FloatSize rectRoundingRadii(3, 3); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 405 |
| 444 WebLayer* LinkHighlightImpl::layer() { | 406 WebLayer* LinkHighlightImpl::layer() { |
| 445 return clipLayer(); | 407 return clipLayer(); |
| 446 } | 408 } |
| 447 | 409 |
| 448 CompositorAnimationPlayer* LinkHighlightImpl::compositorPlayer() const { | 410 CompositorAnimationPlayer* LinkHighlightImpl::compositorPlayer() const { |
| 449 return m_compositorPlayer.get(); | 411 return m_compositorPlayer.get(); |
| 450 } | 412 } |
| 451 | 413 |
| 452 } // namespace blink | 414 } // namespace blink |
| OLD | NEW |