Changeset 87880 in webkit
- Timestamp:
- Jun 1, 2011, 11:41:17 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r87879 r87880 1 2011-06-01 Emil A Eklund <eae@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Switch RenderLayer::convertToLayerCoords to use IntPoint 6 https://bugs.webkit.org/show_bug.cgi?id=61818 7 8 Covered by existing tests. 9 10 * platform/graphics/FloatPoint.h: 11 (WebCore::flooredIntSize): 12 * rendering/RenderLayer.cpp: 13 (WebCore::RenderLayer::updateLayerPositions): 14 (WebCore::expandClipRectForDescendantsAndReflection): 15 (WebCore::transparencyClipBox): 16 (WebCore::RenderLayer::convertToLayerCoords): 17 (WebCore::RenderLayer::paintLayer): 18 (WebCore::RenderLayer::paintChildLayerIntoColumns): 19 (WebCore::RenderLayer::createLocalTransformState): 20 (WebCore::RenderLayer::hitTestChildLayerColumns): 21 (WebCore::RenderLayer::calculateClipRects): 22 (WebCore::RenderLayer::calculateRects): 23 (WebCore::RenderLayer::boundingBox): 24 (WebCore::RenderLayer::setBackingNeedsRepaintInRect): 25 * rendering/RenderLayer.h: 26 * rendering/RenderLayerBacking.cpp: 27 (WebCore::RenderLayerBacking::updateCompositedBounds): 28 (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry): 29 * rendering/RenderLayerCompositor.cpp: 30 (WebCore::RenderLayerCompositor::calculateCompositedBounds): 31 (WebCore::RenderLayerCompositor::layerWillBeRemoved): 32 (WebCore::RenderLayerCompositor::recursiveRepaintLayerRect): 33 1 34 2011-06-01 Roland Steiner <rolandsteiner@chromium.org> 2 35 -
trunk/Source/WebCore/platform/graphics/FloatPoint.h
r86705 r87880 64 64 class TransformationMatrix; 65 65 class IntPoint; 66 class IntSize; 66 67 67 68 class FloatPoint { … … 208 209 } 209 210 211 inline IntSize flooredIntSize(const FloatPoint& p) 212 { 213 return IntSize(static_cast<int>(p.x()), static_cast<int>(p.y())); 214 } 215 210 216 float findSlope(const FloatPoint& p1, const FloatPoint& p2, float& c); 211 217 -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r87864 r87880 276 276 cachedOffset->move(m_topLeft.x(), m_topLeft.y()); // Fast case 277 277 else { 278 int x = 0; 279 int y = 0; 280 convertToLayerCoords(root(), x, y); 281 *cachedOffset = IntPoint(x, y); 278 IntPoint offset; 279 convertToLayerCoords(root(), offset); 280 *cachedOffset = offset; 282 281 } 283 282 } 284 283 } 285 284 286 int x = 0; 287 int y = 0; 285 IntPoint offset; 288 286 if (cachedOffset) { 289 x += cachedOffset->x(); 290 y += cachedOffset->y(); 287 offset = *cachedOffset; 291 288 #ifndef NDEBUG 292 int nonCachedX = 0; 293 int nonCachedY = 0; 294 convertToLayerCoords(root(), nonCachedX, nonCachedY); 295 ASSERT(x == nonCachedX); 296 ASSERT(y == nonCachedY); 289 IntPoint nonCachedOffset; 290 convertToLayerCoords(root(), nonCachedOffset); 291 ASSERT(offset == nonCachedOffset); 297 292 #endif 298 293 } else 299 convertToLayerCoords(root(), x, y);300 positionOverflowControls( IntSize(x, y));294 convertToLayerCoords(root(), offset); 295 positionOverflowControls(toSize(offset)); 301 296 302 297 updateVisibilityStatus(); … … 902 897 // size into the parent layer. 903 898 if (l->renderer()->hasReflection()) { 904 int deltaX = 0; 905 int deltaY = 0; 906 l->convertToLayerCoords(rootLayer, deltaX, deltaY); 907 clipRect.move(-deltaX, -deltaY); 899 IntPoint delta; 900 l->convertToLayerCoords(rootLayer, delta); 901 clipRect.move(-delta.x(), -delta.y()); 908 902 clipRect.unite(l->renderBox()->reflectedRect(clipRect)); 909 clipRect.move(delta X, deltaY);903 clipRect.move(delta); 910 904 } 911 905 } … … 920 914 // The best we can do here is to use enclosed bounding boxes to establish a "fuzzy" enough clip to encompass 921 915 // the transformed layer and all of its children. 922 int x = 0; 923 int y = 0; 924 l->convertToLayerCoords(rootLayer, x, y); 916 IntPoint delta; 917 l->convertToLayerCoords(rootLayer, delta); 925 918 926 919 TransformationMatrix transform; 927 transform.translate( x, y);920 transform.translate(delta.x(), delta.y()); 928 921 transform = transform * *l->transform(); 929 922 … … 1113 1106 1114 1107 void 1115 RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, int& xPos, int& yPos) const1108 RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, IntPoint& location) const 1116 1109 { 1117 1110 if (ancestorLayer == this) … … 1123 1116 // localToAbsolute() on the RenderView. 1124 1117 FloatPoint absPos = renderer()->localToAbsolute(FloatPoint(), true); 1125 xPos += absPos.x(); 1126 yPos += absPos.y(); 1118 location += flooredIntSize(absPos); 1127 1119 return; 1128 1120 } … … 1148 1140 1149 1141 if (fixedPositionContainerLayer != ancestorLayer) { 1150 int fixedContainerX = 0; 1151 int fixedContainerY = 0; 1152 convertToLayerCoords(fixedPositionContainerLayer, fixedContainerX, fixedContainerY); 1153 1154 int ancestorX = 0; 1155 int ancestorY = 0; 1156 ancestorLayer->convertToLayerCoords(fixedPositionContainerLayer, ancestorX, ancestorY); 1157 1158 xPos += (fixedContainerX - ancestorX); 1159 yPos += (fixedContainerY - ancestorY); 1142 IntPoint fixedContainerCoords; 1143 convertToLayerCoords(fixedPositionContainerLayer, fixedContainerCoords); 1144 1145 IntPoint ancestorCoords; 1146 ancestorLayer->convertToLayerCoords(fixedPositionContainerLayer, ancestorCoords); 1147 1148 location += (fixedContainerCoords - ancestorCoords); 1160 1149 return; 1161 1150 } … … 1184 1173 RenderLayer* positionedAncestor = parentLayer->enclosingPositionedAncestor(); 1185 1174 1186 int thisX = 0; 1187 int thisY = 0; 1188 convertToLayerCoords(positionedAncestor, thisX, thisY); 1175 IntPoint thisCoords; 1176 convertToLayerCoords(positionedAncestor, thisCoords); 1189 1177 1190 int ancestorX = 0; 1191 int ancestorY = 0; 1192 ancestorLayer->convertToLayerCoords(positionedAncestor, ancestorX, ancestorY); 1193 1194 xPos += (thisX - ancestorX); 1195 yPos += (thisY - ancestorY); 1178 IntPoint ancestorCoords; 1179 ancestorLayer->convertToLayerCoords(positionedAncestor, ancestorCoords); 1180 1181 location += (thisCoords - ancestorCoords); 1196 1182 return; 1197 1183 } … … 1201 1187 if (!parentLayer) 1202 1188 return; 1203 1204 parentLayer->convertToLayerCoords(ancestorLayer, xPos, yPos); 1205 1206 xPos += m_topLeft.x(); 1207 yPos += m_topLeft.y(); 1189 1190 parentLayer->convertToLayerCoords(ancestorLayer, location); 1191 1192 location += toSize(m_topLeft); 1193 } 1194 1195 void 1196 RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, IntRect& rect) const 1197 { 1198 IntPoint delta; 1199 convertToLayerCoords(ancestorLayer, delta); 1200 rect.move(-delta.x(), -delta.y()); 1208 1201 } 1209 1202 … … 2572 2565 // Adjust the transform such that the renderer's upper left corner will paint at (0,0) in user space. 2573 2566 // This involves subtracting out the position of the layer in our current coordinate space. 2574 int x = 0; 2575 int y = 0; 2576 convertToLayerCoords(rootLayer, x, y); 2567 IntPoint delta; 2568 convertToLayerCoords(rootLayer, delta); 2577 2569 TransformationMatrix transform(layerTransform); 2578 transform.translateRight( x, y);2570 transform.translateRight(delta.x(), delta.y()); 2579 2571 2580 2572 // Apply the transform. … … 2766 2758 return; 2767 2759 2768 int layerX = 0; 2769 int layerY = 0; 2770 columnBlock->layer()->convertToLayerCoords(rootLayer, layerX, layerY); 2760 IntPoint layerOffset; 2761 columnBlock->layer()->convertToLayerCoords(rootLayer, layerOffset); 2771 2762 2772 2763 bool isHorizontal = columnBlock->style()->isHorizontalWritingMode(); … … 2782 2773 IntSize offset = isHorizontal ? IntSize(logicalLeftOffset, currLogicalTopOffset) : IntSize(currLogicalTopOffset, logicalLeftOffset); 2783 2774 2784 colRect.move(layer X, layerY);2775 colRect.move(layerOffset); 2785 2776 2786 2777 IntRect localDirtyRect(paintDirtyRect); … … 2812 2803 // Adjust the transform such that the renderer's upper left corner will paint at (0,0) in user space. 2813 2804 // This involves subtracting out the position of the layer in our current coordinate space. 2814 int childX = 0; 2815 int childY = 0; 2816 columnLayers[colIndex - 1]->convertToLayerCoords(rootLayer, childX, childY); 2805 IntPoint childOffset; 2806 columnLayers[colIndex - 1]->convertToLayerCoords(rootLayer, childOffset); 2817 2807 TransformationMatrix transform; 2818 transform.translateRight(child X + offset.width(), childY+ offset.height());2808 transform.translateRight(childOffset.x() + offset.width(), childOffset.y() + offset.height()); 2819 2809 2820 2810 // Apply the transform. … … 2910 2900 { 2911 2901 RefPtr<HitTestingTransformState> transformState; 2912 int offsetX = 0; 2913 int offsetY = 0; 2902 IntPoint offset; 2914 2903 if (containerTransformState) { 2915 2904 // If we're already computing transform state, then it's relative to the container (which we know is non-null). 2916 2905 transformState = HitTestingTransformState::create(*containerTransformState); 2917 convertToLayerCoords(containerLayer, offset X, offsetY);2906 convertToLayerCoords(containerLayer, offset); 2918 2907 } else { 2919 2908 // If this is the first time we need to make transform state, then base it off of hitTestPoint, 2920 2909 // which is relative to rootLayer. 2921 2910 transformState = HitTestingTransformState::create(hitTestPoint, FloatQuad(hitTestRect)); 2922 convertToLayerCoords(rootLayer, offset X, offsetY);2911 convertToLayerCoords(rootLayer, offset); 2923 2912 } 2924 2913 … … 2926 2915 if (renderer()->shouldUseTransformFromContainer(containerRenderer)) { 2927 2916 TransformationMatrix containerTransform; 2928 renderer()->getTransformFromContainer(containerRenderer, IntSize(offsetX, offsetY), containerTransform);2917 renderer()->getTransformFromContainer(containerRenderer, toSize(offset), containerTransform); 2929 2918 transformState->applyTransform(containerTransform, HitTestingTransformState::AccumulateTransform); 2930 2919 } else { 2931 transformState->translate(offset X, offsetY, HitTestingTransformState::AccumulateTransform);2920 transformState->translate(offset.x(), offset.y(), HitTestingTransformState::AccumulateTransform); 2932 2921 } 2933 2922 … … 3238 3227 if (!columnBlock || !columnBlock->hasColumns()) 3239 3228 return 0; 3240 3241 int layerX = 0; 3242 int layerY = 0; 3243 columnBlock->layer()->convertToLayerCoords(rootLayer, layerX, layerY); 3229 3230 IntPoint layerOffset; 3231 columnBlock->layer()->convertToLayerCoords(rootLayer, layerOffset); 3244 3232 3245 3233 ColumnInfo* colInfo = columnBlock->columnInfo(); … … 3269 3257 else 3270 3258 currLogicalTopOffset += blockDelta; 3271 colRect.move(layer X, layerY);3259 colRect.move(layerOffset); 3272 3260 3273 3261 IntRect localClipRect(hitTestRect); … … 3378 3366 if (renderer()->hasOverflowClip() || renderer()->hasClip()) { 3379 3367 // This layer establishes a clip of some kind. 3380 int x = 0; 3381 int y = 0; 3382 convertToLayerCoords(rootLayer, x, y); 3368 IntPoint offset; 3369 convertToLayerCoords(rootLayer, offset); 3383 3370 RenderView* view = renderer()->view(); 3384 3371 ASSERT(view); 3385 3372 if (view && clipRects.fixed() && rootLayer->renderer() == view) { 3386 x -= view->frameView()->scrollXForFixedPosition(); 3387 y -= view->frameView()->scrollYForFixedPosition(); 3373 offset -= view->frameView()->scrollOffsetForFixedPosition(); 3388 3374 } 3389 3375 3390 3376 if (renderer()->hasOverflowClip()) { 3391 IntRect newOverflowClip = toRenderBox(renderer())->overflowClipRect( x, y, relevancy);3377 IntRect newOverflowClip = toRenderBox(renderer())->overflowClipRect(offset.x(), offset.y(), relevancy); 3392 3378 clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRects.overflowClipRect())); 3393 3379 if (renderer()->isPositioned() || renderer()->isRelPositioned()) … … 3395 3381 } 3396 3382 if (renderer()->hasClip()) { 3397 IntRect newPosClip = toRenderBox(renderer())->clipRect( x, y);3383 IntRect newPosClip = toRenderBox(renderer())->clipRect(offset.x(), offset.y()); 3398 3384 clipRects.setPosClipRect(intersection(newPosClip, clipRects.posClipRect())); 3399 3385 clipRects.setOverflowClipRect(intersection(newPosClip, clipRects.overflowClipRect())); … … 3445 3431 outlineRect = backgroundRect; 3446 3432 3447 int x = 0; 3448 int y = 0; 3449 convertToLayerCoords(rootLayer, x, y); 3450 layerBounds = IntRect(IntPoint(x, y), size()); 3433 IntPoint offset; 3434 convertToLayerCoords(rootLayer, offset); 3435 layerBounds = IntRect(offset, size()); 3451 3436 3452 3437 // Update the clip rects that will be passed to child layers. … … 3454 3439 // This layer establishes a clip of some kind. 3455 3440 if (renderer()->hasOverflowClip()) 3456 foregroundRect.intersect(toRenderBox(renderer())->overflowClipRect( x, y, relevancy));3441 foregroundRect.intersect(toRenderBox(renderer())->overflowClipRect(offset.x(), offset.y(), relevancy)); 3457 3442 if (renderer()->hasClip()) { 3458 3443 // Clip applies to *us* as well, so go ahead and update the damageRect. 3459 IntRect newPosClip = toRenderBox(renderer())->clipRect( x, y);3444 IntRect newPosClip = toRenderBox(renderer())->clipRect(offset.x(), offset.y()); 3460 3445 backgroundRect.intersect(newPosClip); 3461 3446 foregroundRect.intersect(newPosClip); … … 3611 3596 else 3612 3597 renderer()->containingBlock()->flipForWritingMode(result); 3613 int deltaX = 0, deltaY = 0;3614 convertToLayerCoords(ancestorLayer, delta X, deltaY);3615 result.move(delta X, deltaY);3598 IntPoint delta; 3599 convertToLayerCoords(ancestorLayer, delta); 3600 result.move(delta); 3616 3601 return result; 3617 3602 } … … 3948 3933 // repaint to the native view system. 3949 3934 IntRect absRect(r); 3950 int x = 0; 3951 int y = 0; 3952 convertToLayerCoords(root(), x, y); 3953 absRect.move(x, y); 3935 IntPoint delta; 3936 convertToLayerCoords(root(), delta); 3937 absRect.move(delta); 3954 3938 3955 3939 RenderView* view = renderer()->view(); -
trunk/Source/WebCore/rendering/RenderLayer.h
r87864 r87880 348 348 #endif 349 349 350 void convertToLayerCoords(const RenderLayer* ancestorLayer, int& x, int& y) const; 350 void convertToLayerCoords(const RenderLayer* ancestorLayer, IntPoint& location) const; 351 void convertToLayerCoords(const RenderLayer* ancestorLayer, IntRect& rect) const; 351 352 352 353 bool hasAutoZIndex() const { return renderer()->style()->hasAutoZIndex(); } -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r87864 r87880 204 204 clippingBounds.intersect(m_owningLayer->backgroundClipRect(rootLayer, true)); 205 205 206 int deltaX = 0; 207 int deltaY = 0; 208 m_owningLayer->convertToLayerCoords(rootLayer, deltaX, deltaY); 209 clippingBounds.move(-deltaX, -deltaY); 206 IntPoint delta; 207 m_owningLayer->convertToLayerCoords(rootLayer, delta); 208 clippingBounds.move(-delta.x(), -delta.y()); 210 209 211 210 layerBounds.intersect(clippingBounds); … … 357 356 358 357 IntRect relativeCompositingBounds(localCompositingBounds); 359 int deltaX = 0, deltaY = 0;360 m_owningLayer->convertToLayerCoords(compAncestor, delta X, deltaY);361 relativeCompositingBounds.move(delta X, deltaY);358 IntPoint delta; 359 m_owningLayer->convertToLayerCoords(compAncestor, delta); 360 relativeCompositingBounds.move(delta); 362 361 363 362 IntPoint graphicsLayerParentLocation; … … 380 379 381 380 // backgroundRect is relative to compAncestor, so subtract deltaX/deltaY to get back to local coords. 382 IntSize rendererOffset(parentClipRect.location().x() - deltaX, parentClipRect.location().y() - deltaY); 383 m_ancestorClippingLayer->setOffsetFromRenderer(rendererOffset); 381 m_ancestorClippingLayer->setOffsetFromRenderer(parentClipRect.location() - delta); 384 382 385 383 // The primary layer is then parented in, and positioned relative to this clipping layer. … … 428 426 429 427 // Get layout bounds in the coords of compAncestor to match relativeCompositingBounds. 430 IntRect layerBounds = IntRect(delta X, deltaY, borderBox.width(), borderBox.height());428 IntRect layerBounds = IntRect(delta, borderBox.size()); 431 429 432 430 // Update properties that depend on layer dimensions -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r87547 r87880 450 450 451 451 if (layer->renderer()->hasOverflowClip() || layer->renderer()->hasMask()) { 452 int ancestorRelX = 0, ancestorRelY = 0;453 layer->convertToLayerCoords(ancestorLayer, ancestorRel X, ancestorRelY);454 boundingBoxRect.move(ancestorRel X, ancestorRelY);452 IntPoint ancestorRelOffset; 453 layer->convertToLayerCoords(ancestorLayer, ancestorRelOffset); 454 boundingBoxRect.move(ancestorRelOffset); 455 455 return boundingBoxRect; 456 456 } … … 504 504 } 505 505 506 int ancestorRelX = 0, ancestorRelY = 0;507 layer->convertToLayerCoords(ancestorLayer, ancestorRel X, ancestorRelY);508 unionBounds.move(ancestorRel X, ancestorRelY);506 IntPoint ancestorRelOffset; 507 layer->convertToLayerCoords(ancestorLayer, ancestorRelOffset); 508 unionBounds.move(ancestorRelOffset); 509 509 510 510 return unionBounds; … … 528 528 IntRect compBounds = child->backing()->compositedBounds(); 529 529 530 int offsetX = 0, offsetY = 0;531 child->convertToLayerCoords(compLayer, offset X, offsetY);532 compBounds.move(offset X, offsetY);530 IntPoint offset; 531 child->convertToLayerCoords(compLayer, offset); 532 compBounds.move(offset); 533 533 534 534 compLayer->setBackingNeedsRepaintInRect(compBounds); … … 1072 1072 for (size_t i = 0; i < listSize; ++i) { 1073 1073 RenderLayer* curLayer = negZOrderList->at(i); 1074 int x = 0;1075 int y = 0;1076 curLayer->convertToLayerCoords(layer, x, y);1077 1074 IntRect childRect(rect); 1078 c hildRect.move(-x, -y);1075 curLayer->convertToLayerCoords(layer, childRect); 1079 1076 recursiveRepaintLayerRect(curLayer, childRect); 1080 1077 } … … 1085 1082 for (size_t i = 0; i < listSize; ++i) { 1086 1083 RenderLayer* curLayer = posZOrderList->at(i); 1087 int x = 0;1088 int y = 0;1089 curLayer->convertToLayerCoords(layer, x, y);1090 1084 IntRect childRect(rect); 1091 c hildRect.move(-x, -y);1085 curLayer->convertToLayerCoords(layer, childRect); 1092 1086 recursiveRepaintLayerRect(curLayer, childRect); 1093 1087 } … … 1098 1092 for (size_t i = 0; i < listSize; ++i) { 1099 1093 RenderLayer* curLayer = normalFlowList->at(i); 1100 int x = 0;1101 int y = 0;1102 curLayer->convertToLayerCoords(layer, x, y);1103 1094 IntRect childRect(rect); 1104 c hildRect.move(-x, -y);1095 curLayer->convertToLayerCoords(layer, childRect); 1105 1096 recursiveRepaintLayerRect(curLayer, childRect); 1106 1097 }
Note:
See TracChangeset
for help on using the changeset viewer.