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

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 238863002: Implement drawFocusIfNeeded with Path2D parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 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 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2312 2312
2313 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib utes() const 2313 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib utes() const
2314 { 2314 {
2315 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr eate(); 2315 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr eate();
2316 attributes->setAlpha(m_hasAlpha); 2316 attributes->setAlpha(m_hasAlpha);
2317 return attributes.release(); 2317 return attributes.release();
2318 } 2318 }
2319 2319
2320 void CanvasRenderingContext2D::drawFocusIfNeeded(Element* element) 2320 void CanvasRenderingContext2D::drawFocusIfNeeded(Element* element)
2321 { 2321 {
2322 if (!focusRingCallIsValid(m_path, element)) 2322 drawFocusIfNeededInternal(m_path, element);
2323 }
2324
2325 void CanvasRenderingContext2D::drawFocusIfNeeded(Path2D* path2d, Element* elemen t)
2326 {
2327 drawFocusIfNeededInternal(path2d->path(), element);
2328 }
2329
2330 void CanvasRenderingContext2D::drawFocusIfNeededInternal(const Path& path, Eleme nt* element)
2331 {
2332 if (!focusRingCallIsValid(path, element))
2323 return; 2333 return;
2324 2334
2325 updateFocusRingAccessibility(m_path, element); 2335 updateFocusRingAccessibility(path, element);
2326 // Note: we need to check document->focusedElement() rather than just callin g 2336 // Note: we need to check document->focusedElement() rather than just callin g
2327 // element->focused(), because element->focused() isn't updated until after 2337 // element->focused(), because element->focused() isn't updated until after
2328 // focus events fire. 2338 // focus events fire.
2329 if (element->document().focusedElement() == element) 2339 if (element->document().focusedElement() == element)
2330 drawFocusRing(m_path); 2340 drawFocusRing(path);
2331 } 2341 }
2332 2342
2333 bool CanvasRenderingContext2D::drawCustomFocusRing(Element* element) 2343 bool CanvasRenderingContext2D::drawCustomFocusRing(Element* element)
2334 { 2344 {
2335 if (!focusRingCallIsValid(m_path, element)) 2345 if (!focusRingCallIsValid(m_path, element))
2336 return false; 2346 return false;
2337 2347
2338 updateFocusRingAccessibility(m_path, element); 2348 updateFocusRingAccessibility(m_path, element);
2339 2349
2340 // Return true if the application should draw the focus ring. The spec allow s us to 2350 // Return true if the application should draw the focus ring. The spec allow s us to
(...skipping 19 matching lines...) Expand all
2360 if (!canvas()->renderer()) 2370 if (!canvas()->renderer())
2361 return; 2371 return;
2362 2372
2363 // If accessibility is already enabled in this frame, associate this path's 2373 // If accessibility is already enabled in this frame, associate this path's
2364 // bounding box with the accessible object. Do this even if the element 2374 // bounding box with the accessible object. Do this even if the element
2365 // isn't focused because assistive technology might try to explore the objec t's 2375 // isn't focused because assistive technology might try to explore the objec t's
2366 // location before it gets focus. 2376 // location before it gets focus.
2367 if (AXObjectCache* axObjectCache = element->document().existingAXObjectCache ()) { 2377 if (AXObjectCache* axObjectCache = element->document().existingAXObjectCache ()) {
2368 if (AXObject* obj = axObjectCache->getOrCreate(element)) { 2378 if (AXObject* obj = axObjectCache->getOrCreate(element)) {
2369 // Get the bounding rect and apply transformations. 2379 // Get the bounding rect and apply transformations.
2370 FloatRect bounds = m_path.boundingRect(); 2380 FloatRect bounds = path.boundingRect();
2371 AffineTransform ctm = state().m_transform; 2381 AffineTransform ctm = state().m_transform;
2372 FloatRect transformedBounds = ctm.mapRect(bounds); 2382 FloatRect transformedBounds = ctm.mapRect(bounds);
2373 LayoutRect elementRect = LayoutRect(transformedBounds); 2383 LayoutRect elementRect = LayoutRect(transformedBounds);
2374 2384
2375 // Offset by the canvas rect and set the bounds of the accessible el ement. 2385 // Offset by the canvas rect and set the bounds of the accessible el ement.
2376 IntRect canvasRect = canvas()->renderer()->absoluteBoundingBoxRect() ; 2386 IntRect canvasRect = canvas()->renderer()->absoluteBoundingBoxRect() ;
2377 elementRect.moveBy(canvasRect.location()); 2387 elementRect.moveBy(canvasRect.location());
2378 obj->setElementRect(elementRect); 2388 obj->setElementRect(elementRect);
2379 2389
2380 // Set the bounds of any ancestor accessible elements, up to the can vas element, 2390 // Set the bounds of any ancestor accessible elements, up to the can vas element,
(...skipping 30 matching lines...) Expand all
2411 c->setAlphaAsFloat(1.0); 2421 c->setAlphaAsFloat(1.0);
2412 c->clearShadow(); 2422 c->clearShadow();
2413 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); 2423 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal);
2414 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); 2424 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor);
2415 c->restore(); 2425 c->restore();
2416 2426
2417 didDraw(dirtyRect); 2427 didDraw(dirtyRect);
2418 } 2428 }
2419 2429
2420 } // namespace WebCore 2430 } // namespace WebCore
OLDNEW
« 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