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

Side by Side Diff: sky/engine/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 878303002: Remove more scrolling code from Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
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 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 1071
1072 StrokeData strokeData; 1072 StrokeData strokeData;
1073 strokeData.setThickness(lineWidth()); 1073 strokeData.setThickness(lineWidth());
1074 strokeData.setLineCap(getLineCap()); 1074 strokeData.setLineCap(getLineCap());
1075 strokeData.setLineJoin(getLineJoin()); 1075 strokeData.setLineJoin(getLineJoin());
1076 strokeData.setMiterLimit(miterLimit()); 1076 strokeData.setMiterLimit(miterLimit());
1077 strokeData.setLineDash(getLineDash(), lineDashOffset()); 1077 strokeData.setLineDash(getLineDash(), lineDashOffset());
1078 return path.strokeContains(transformedPoint, strokeData); 1078 return path.strokeContains(transformedPoint, strokeData);
1079 } 1079 }
1080 1080
1081 void CanvasRenderingContext2D::scrollPathIntoView()
1082 {
1083 scrollPathIntoViewInternal(m_path);
1084 }
1085
1086 void CanvasRenderingContext2D::scrollPathIntoView(Path2D* path2d)
1087 {
1088 scrollPathIntoViewInternal(path2d->path());
1089 }
1090
1091 void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path)
1092 {
1093 RenderObject* renderer = canvas()->renderer();
1094 RenderBox* renderBox = canvas()->renderBox();
1095 if (!renderer || !renderBox || !state().m_invertibleCTM || path.isEmpty())
1096 return;
1097
1098 canvas()->document().updateLayout();
1099
1100 // Apply transformation and get the bounding rect
1101 Path transformedPath = path;
1102 transformedPath.transform(state().m_transform);
1103 FloatRect boundingRect = transformedPath.boundingRect();
1104
1105 // Offset by the canvas rect
1106 LayoutRect pathRect(boundingRect);
1107 IntRect canvasRect = renderBox->absoluteContentBox();
1108 pathRect.move(canvasRect.x(), canvasRect.y());
1109
1110 renderer->scrollRectToVisible(
1111 pathRect, ScrollAlignment::alignCenterAlways, ScrollAlignment::alignTopA lways);
1112
1113 // TODO: should implement "inform the user" that the caret and/or
1114 // selection the specified rectangle of the canvas. See http://crbug.com/357 987
1115 }
1116
1117 void CanvasRenderingContext2D::clearRect(float x, float y, float width, float he ight) 1081 void CanvasRenderingContext2D::clearRect(float x, float y, float width, float he ight)
1118 { 1082 {
1119 if (!validateRectForCanvas(x, y, width, height)) 1083 if (!validateRectForCanvas(x, y, width, height))
1120 return; 1084 return;
1121 GraphicsContext* context = drawingContext(); 1085 GraphicsContext* context = drawingContext();
1122 if (!context) 1086 if (!context)
1123 return; 1087 return;
1124 if (!state().m_invertibleCTM) 1088 if (!state().m_invertibleCTM)
1125 return; 1089 return;
1126 FloatRect rect(x, y, width, height); 1090 FloatRect rect(x, y, width, height);
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 2208
2245 unsigned CanvasRenderingContext2D::hitRegionsCount() const 2209 unsigned CanvasRenderingContext2D::hitRegionsCount() const
2246 { 2210 {
2247 if (m_hitRegionManager) 2211 if (m_hitRegionManager)
2248 return m_hitRegionManager->getHitRegionsCount(); 2212 return m_hitRegionManager->getHitRegionsCount();
2249 2213
2250 return 0; 2214 return 0;
2251 } 2215 }
2252 2216
2253 } // namespace blink 2217 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/html/canvas/CanvasRenderingContext2D.h ('k') | sky/engine/core/html/canvas/CanvasRenderingContext2D.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698