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

Unified Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 367113007: Refactor CanvasRenderingContext2D::scrollPathIntoViewInternal(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698