Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp |
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
index 1b703c02d21e33e3f5823e906fd79d95c83a5fa9..eb9f97969a360791879c2337a310e3d9e05d36ab 100644 |
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
@@ -1109,6 +1109,40 @@ bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, const f |
return path.strokeContains(transformedPoint, strokeData); |
} |
+void CanvasRenderingContext2D::scrollPathIntoView() |
+{ |
+ scrollPathIntoViewInternal(m_path); |
Rik
2014/03/20 16:22:19
Does this take the current CTM into account?
I bel
|
+} |
+ |
+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 || !canvas() || path.isEmpty()) |
Rik
2014/03/20 16:22:19
scrollPathIntoView() should take ctm into account.
Justin Novosad
2014/03/20 20:03:12
I agree, all the other methods on CanvasRenderingC
|
+ return; |
+ |
+ canvas()->document().updateLayoutIgnorePendingStylesheets(); |
+ |
+ LayoutRect pathRect; |
+ absoluteBoundingPathRect(path, pathRect); |
+ |
+ 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. |
+} |
+ |
void CanvasRenderingContext2D::clearRect(float x, float y, float width, float height) |
{ |
if (!validateRectForCanvas(x, y, width, height)) |
@@ -2147,6 +2181,22 @@ void CanvasRenderingContext2D::inflateStrokeRect(FloatRect& rect) const |
rect.inflate(delta); |
} |
+void CanvasRenderingContext2D::absoluteBoundingPathRect(const Path& path, LayoutRect& rect) const |
+{ |
+ // Get the bounding rect and apply transformations. |
+ FloatRect bounds = path.boundingRect(); |
+ AffineTransform ctm = state().m_transform; |
+ FloatRect transformedBounds = ctm.mapRect(bounds); |
+ rect = LayoutRect(transformedBounds); |
Justin Novosad
2014/03/20 20:03:12
This works if the transform has only translation a
|
+ |
+ // Offset by the canvas rect (We should take border and padding into account). |
+ IntRect canvasRect = canvas()->renderer()->absoluteBoundingBoxRect(); |
+ RenderBoxModelObject* rbmo = canvas()->renderBoxModelObject(); |
+ canvasRect.move(rbmo->borderLeft() + rbmo->paddingLeft(), |
+ rbmo->borderTop() + rbmo->paddingTop()); |
+ rect.moveBy(canvasRect.location()); |
+} |
+ |
const Font& CanvasRenderingContext2D::accessFont() |
{ |
// This needs style to be up to date, but can't assert so because drawTextInternal |
@@ -2255,15 +2305,9 @@ void CanvasRenderingContext2D::updateFocusRingAccessibility(const Path& path, El |
// location before it gets focus. |
if (AXObjectCache* axObjectCache = element->document().existingAXObjectCache()) { |
if (AXObject* obj = axObjectCache->getOrCreate(element)) { |
- // Get the bounding rect and apply transformations. |
- FloatRect bounds = m_path.boundingRect(); |
- AffineTransform ctm = state().m_transform; |
- FloatRect transformedBounds = ctm.mapRect(bounds); |
- LayoutRect elementRect = LayoutRect(transformedBounds); |
- |
- // Offset by the canvas rect and set the bounds of the accessible element. |
- IntRect canvasRect = canvas()->renderer()->absoluteBoundingBoxRect(); |
- elementRect.moveBy(canvasRect.location()); |
+ // set the bounds of the accessible element. |
+ LayoutRect elementRect; |
+ absoluteBoundingPathRect(path, elementRect); |
obj->setElementRect(elementRect); |
// Set the bounds of any ancestor accessible elements, up to the canvas element, |