| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/canvas2d/CanvasRenderingContext2D.h" | 5 #include "modules/canvas2d/CanvasRenderingContext2D.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
| 10 #include "core/html/HTMLCanvasElement.h" | 10 #include "core/html/HTMLCanvasElement.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 HitRegionOptions options; | 289 HitRegionOptions options; |
| 290 options.setControl(buttonElement); | 290 options.setControl(buttonElement); |
| 291 | 291 |
| 292 context->beginPath(); | 292 context->beginPath(); |
| 293 context->rect(10, 10, 40, 40); | 293 context->rect(10, 10, 40, 40); |
| 294 context->addHitRegion(options, exceptionState); | 294 context->addHitRegion(options, exceptionState); |
| 295 | 295 |
| 296 AXObjectCacheImpl* axObjectCache = toAXObjectCacheImpl(document().existingAX
ObjectCache()); | 296 AXObjectCacheImpl* axObjectCache = toAXObjectCacheImpl(document().existingAX
ObjectCache()); |
| 297 AXObject* axObject = axObjectCache->getOrCreate(buttonElement); | 297 AXObject* axObject = axObjectCache->getOrCreate(buttonElement); |
| 298 | 298 |
| 299 EXPECT_EQ(25, axObject->elementRect().x().toInt()); | 299 LayoutRect axBounds = axObject->getBoundsInFrameCoordinates(); |
| 300 EXPECT_EQ(25, axObject->elementRect().y().toInt()); | 300 EXPECT_EQ(25, axBounds.x().toInt()); |
| 301 EXPECT_EQ(40, axObject->elementRect().width().toInt()); | 301 EXPECT_EQ(25, axBounds.y().toInt()); |
| 302 EXPECT_EQ(40, axObject->elementRect().height().toInt()); | 302 EXPECT_EQ(40, axBounds.width().toInt()); |
| 303 EXPECT_EQ(40, axBounds.height().toInt()); |
| 303 } | 304 } |
| 304 | 305 |
| 305 TEST_F(CanvasRenderingContext2DAPITest, AccessibilityRectTestForDrawFocusIfNeede
d) | 306 TEST_F(CanvasRenderingContext2DAPITest, AccessibilityRectTestForDrawFocusIfNeede
d) |
| 306 { | 307 { |
| 307 resetCanvasForAccessibilityRectTest(document()); | 308 resetCanvasForAccessibilityRectTest(document()); |
| 308 | 309 |
| 309 Element* buttonElement = document().getElementById("button"); | 310 Element* buttonElement = document().getElementById("button"); |
| 310 HTMLCanvasElement* canvas = toHTMLCanvasElement(document().getElementById("c
anvas")); | 311 HTMLCanvasElement* canvas = toHTMLCanvasElement(document().getElementById("c
anvas")); |
| 311 CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(c
anvas->renderingContext()); | 312 CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(c
anvas->renderingContext()); |
| 312 | 313 |
| 313 document().updateStyleAndLayoutTreeForNode(canvas); | 314 document().updateStyleAndLayoutTreeForNode(canvas); |
| 314 | 315 |
| 315 context->beginPath(); | 316 context->beginPath(); |
| 316 context->rect(10, 10, 40, 40); | 317 context->rect(10, 10, 40, 40); |
| 317 context->drawFocusIfNeeded(buttonElement); | 318 context->drawFocusIfNeeded(buttonElement); |
| 318 | 319 |
| 319 AXObjectCacheImpl* axObjectCache = toAXObjectCacheImpl(document().existingAX
ObjectCache()); | 320 AXObjectCacheImpl* axObjectCache = toAXObjectCacheImpl(document().existingAX
ObjectCache()); |
| 320 AXObject* axObject = axObjectCache->getOrCreate(buttonElement); | 321 AXObject* axObject = axObjectCache->getOrCreate(buttonElement); |
| 321 | 322 |
| 322 EXPECT_EQ(25, axObject->elementRect().x().toInt()); | 323 LayoutRect axBounds = axObject->getBoundsInFrameCoordinates(); |
| 323 EXPECT_EQ(25, axObject->elementRect().y().toInt()); | 324 EXPECT_EQ(25, axBounds.x().toInt()); |
| 324 EXPECT_EQ(40, axObject->elementRect().width().toInt()); | 325 EXPECT_EQ(25, axBounds.y().toInt()); |
| 325 EXPECT_EQ(40, axObject->elementRect().height().toInt()); | 326 EXPECT_EQ(40, axBounds.width().toInt()); |
| 327 EXPECT_EQ(40, axBounds.height().toInt()); |
| 326 } | 328 } |
| 327 | 329 |
| 328 } // namespace blink | 330 } // namespace blink |
| OLD | NEW |