Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp |
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
index bf0c2ddd0bc8a5c7cd80bb9e4eca00155cf403a3..4dbcff499629dce12578b41a4241e194885a3d30 100644 |
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
@@ -1181,7 +1181,9 @@ void CanvasRenderingContext2D::scrollPathIntoView(Path2D* path2d) |
void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path) |
{ |
- if (!state().m_invertibleCTM || path.isEmpty()) |
+ RenderObject* renderer = canvas()->renderer(); |
+ RenderBox* renderBox = canvas()->renderBox(); |
+ if (!renderer || !renderBox || !state().m_invertibleCTM || path.isEmpty()) |
return; |
canvas()->document().updateLayoutIgnorePendingStylesheets(); |
@@ -1191,18 +1193,13 @@ void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path) |
transformedPath.transform(state().m_transform); |
FloatRect boundingRect = transformedPath.boundingRect(); |
- // Offset by the canvas rect (We should take border and padding into account). |
- RenderBoxModelObject* rbmo = canvas()->renderBoxModelObject(); |
- IntRect canvasRect = canvas()->renderer()->absoluteBoundingBoxRect(); |
- canvasRect.move(rbmo->borderLeft() + rbmo->paddingLeft(), |
- rbmo->borderTop() + rbmo->paddingTop()); |
- LayoutRect pathRect = enclosingLayoutRect(boundingRect); |
- pathRect.moveBy(canvasRect.location()); |
- |
- if (canvas()->renderer()) { |
- canvas()->renderer()->scrollRectToVisible( |
- pathRect, ScrollAlignment::alignCenterAlways, ScrollAlignment::alignTopAlways); |
- } |
+ // Offset by the canvas rect |
+ LayoutRect pathRect(boundingRect); |
+ IntRect canvasRect = renderBox->absoluteContentBox(); |
+ pathRect.move(canvasRect.x(), canvasRect.y()); |
+ |
+ renderer->scrollRectToVisible( |
+ pathRect, ScrollAlignment::alignCenterAlways, ScrollAlignment::alignTopAlways); |
// TODO: should implement "inform the user" that the caret and/or |
// selection the specified rectangle of the canvas. See http://crbug.com/357987 |