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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved.
9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
10 * 10 *
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 scrollPathIntoViewInternal(m_path); 1174 scrollPathIntoViewInternal(m_path);
1175 } 1175 }
1176 1176
1177 void CanvasRenderingContext2D::scrollPathIntoView(Path2D* path2d) 1177 void CanvasRenderingContext2D::scrollPathIntoView(Path2D* path2d)
1178 { 1178 {
1179 scrollPathIntoViewInternal(path2d->path()); 1179 scrollPathIntoViewInternal(path2d->path());
1180 } 1180 }
1181 1181
1182 void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path) 1182 void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path)
1183 { 1183 {
1184 if (!state().m_invertibleCTM || path.isEmpty()) 1184 RenderObject* renderer = canvas()->renderer();
1185 RenderBox* renderBox = canvas()->renderBox();
1186 if (!renderer || !renderBox || !state().m_invertibleCTM || path.isEmpty())
1185 return; 1187 return;
1186 1188
1187 canvas()->document().updateLayoutIgnorePendingStylesheets(); 1189 canvas()->document().updateLayoutIgnorePendingStylesheets();
1188 1190
1189 // Apply transformation and get the bounding rect 1191 // Apply transformation and get the bounding rect
1190 Path transformedPath = path; 1192 Path transformedPath = path;
1191 transformedPath.transform(state().m_transform); 1193 transformedPath.transform(state().m_transform);
1192 FloatRect boundingRect = transformedPath.boundingRect(); 1194 FloatRect boundingRect = transformedPath.boundingRect();
1193 1195
1194 // Offset by the canvas rect (We should take border and padding into account ). 1196 // Offset by the canvas rect
1195 RenderBoxModelObject* rbmo = canvas()->renderBoxModelObject(); 1197 LayoutRect pathRect(boundingRect);
1196 IntRect canvasRect = canvas()->renderer()->absoluteBoundingBoxRect(); 1198 IntRect canvasRect = renderBox->absoluteContentBox();
1197 canvasRect.move(rbmo->borderLeft() + rbmo->paddingLeft(), 1199 pathRect.move(canvasRect.x(), canvasRect.y());
1198 rbmo->borderTop() + rbmo->paddingTop());
1199 LayoutRect pathRect = enclosingLayoutRect(boundingRect);
1200 pathRect.moveBy(canvasRect.location());
1201 1200
1202 if (canvas()->renderer()) { 1201 renderer->scrollRectToVisible(
1203 canvas()->renderer()->scrollRectToVisible( 1202 pathRect, ScrollAlignment::alignCenterAlways, ScrollAlignment::alignTopA lways);
1204 pathRect, ScrollAlignment::alignCenterAlways, ScrollAlignment::align TopAlways);
1205 }
1206 1203
1207 // TODO: should implement "inform the user" that the caret and/or 1204 // TODO: should implement "inform the user" that the caret and/or
1208 // selection the specified rectangle of the canvas. See http://crbug.com/357 987 1205 // selection the specified rectangle of the canvas. See http://crbug.com/357 987
1209 } 1206 }
1210 1207
1211 void CanvasRenderingContext2D::clearRect(float x, float y, float width, float he ight) 1208 void CanvasRenderingContext2D::clearRect(float x, float y, float width, float he ight)
1212 { 1209 {
1213 if (!validateRectForCanvas(x, y, width, height)) 1210 if (!validateRectForCanvas(x, y, width, height))
1214 return; 1211 return;
1215 GraphicsContext* context = drawingContext(); 1212 GraphicsContext* context = drawingContext();
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 2439
2443 unsigned CanvasRenderingContext2D::hitRegionsCount() const 2440 unsigned CanvasRenderingContext2D::hitRegionsCount() const
2444 { 2441 {
2445 if (m_hitRegionManager) 2442 if (m_hitRegionManager)
2446 return m_hitRegionManager->getHitRegionsCount(); 2443 return m_hitRegionManager->getHitRegionsCount();
2447 2444
2448 return 0; 2445 return 0;
2449 } 2446 }
2450 2447
2451 } // namespace WebCore 2448 } // namespace WebCore
OLDNEW
« 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