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

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

Issue 196243007: Implement CRC2D.scrollPathIntoView() on Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: TestExpectations Created 6 years, 9 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
Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index fa06fb6c7fd360cb6c68f7a9e3931c09964e9563..5f04210aaf1f75ec83ecb70aa3bb63555c57f311 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -1113,6 +1113,50 @@ bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, const f
return path.strokeContains(transformedPoint, strokeData);
}
+void CanvasRenderingContext2D::scrollPathIntoView()
+{
+ scrollPathIntoViewInternal(m_path);
+}
+
+void CanvasRenderingContext2D::scrollPathIntoView(Path2D* path2d, ExceptionState& exceptionState)
+{
+ if (!path2d) {
+ exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::argumentNullOrIncorrectType(1, "Path2D"));
+ return;
+ }
+
+ scrollPathIntoViewInternal(path2d->path());
+}
+
+void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path)
+{
+ if (!state().m_invertibleCTM || path.isEmpty())
+ return;
+
+ canvas()->document().updateLayoutIgnorePendingStylesheets();
+
+ // Apply transformation and get the bounding rect
+ Path transformedPath = 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);
+ }
+
+ // TODO: should implement "inform the user" that the caret and/or
+ // selection the specified rectangle of the canvas. See http://crbug.com/357987
+}
+
void CanvasRenderingContext2D::clearRect(float x, float y, float width, float height)
{
if (!validateRectForCanvas(x, y, width, height))
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.h ('k') | Source/core/html/canvas/CanvasRenderingContext2D.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698