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

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

Issue 19786002: Implement canvas focus ring methods. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
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 Intel Corporation. All rights reserved. 8 * Copyright (C) 2012 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 16 matching lines...) Expand all
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
28 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33 #include "config.h" 33 #include "config.h"
34 #include "core/html/canvas/CanvasRenderingContext2D.h" 34 #include "core/html/canvas/CanvasRenderingContext2D.h"
35 35
36 #include "CSSPropertyNames.h" 36 #include "CSSPropertyNames.h"
37 #include "core/accessibility/AXObjectCache.h"
Stephen White 2013/07/19 14:37:11 It seems unfortunate to add this dependency direct
37 #include "core/css/CSSFontSelector.h" 38 #include "core/css/CSSFontSelector.h"
38 #include "core/css/CSSParser.h" 39 #include "core/css/CSSParser.h"
39 #include "core/css/StylePropertySet.h" 40 #include "core/css/StylePropertySet.h"
40 #include "core/css/resolver/StyleResolver.h" 41 #include "core/css/resolver/StyleResolver.h"
41 #include "core/dom/ExceptionCode.h" 42 #include "core/dom/ExceptionCode.h"
42 #include "core/dom/ExceptionCodePlaceholder.h" 43 #include "core/dom/ExceptionCodePlaceholder.h"
43 #include "core/html/HTMLCanvasElement.h" 44 #include "core/html/HTMLCanvasElement.h"
44 #include "core/html/HTMLImageElement.h" 45 #include "core/html/HTMLImageElement.h"
45 #include "core/html/HTMLMediaElement.h" 46 #include "core/html/HTMLMediaElement.h"
46 #include "core/html/HTMLVideoElement.h" 47 #include "core/html/HTMLVideoElement.h"
(...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 c->setImageInterpolationQuality(enabled ? DefaultInterpolationQuality : InterpolationNone); 2301 c->setImageInterpolationQuality(enabled ? DefaultInterpolationQuality : InterpolationNone);
2301 } 2302 }
2302 2303
2303 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib utes() const 2304 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib utes() const
2304 { 2305 {
2305 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr eate(); 2306 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr eate();
2306 attributes->setAlpha(m_hasAlpha); 2307 attributes->setAlpha(m_hasAlpha);
2307 return attributes.release(); 2308 return attributes.release();
2308 } 2309 }
2309 2310
2311 void CanvasRenderingContext2D::drawSystemFocusRing(Element* element)
2312 {
2313 drawFocusRing(m_path, element, false);
2314 }
2315
2316 void CanvasRenderingContext2D::drawSystemFocusRing(DOMPath* path, Element* eleme nt)
2317 {
2318 drawFocusRing(path->path(), element, false);
2319 }
2320
2321 bool CanvasRenderingContext2D::drawCustomFocusRing(Element* element)
2322 {
2323 drawFocusRing(m_path, element, true);
2324 // Blink doesn't draw a custom focus ring; we always return false to inform the web app it should draw it.
2325 return false;
2326 }
2327
2328 bool CanvasRenderingContext2D::drawCustomFocusRing(DOMPath* path, Element* eleme nt)
2329 {
2330 drawFocusRing(path->path(), element, true);
2331 // Blink doesn't draw a custom focus ring; we always return false to inform the web app it should draw it.
2332 return false;
2333 }
2334
2335 void CanvasRenderingContext2D::drawFocusRing(const Path& path, Element* element, bool custom)
2336 {
2337 GraphicsContext* c = drawingContext();
2338 if (!c)
2339 return;
2340 if (!state().m_invertibleCTM)
2341 return;
2342 if (path.isEmpty())
2343 return;
2344 FloatRect boundingRect = path.boundingRect();
2345
2346 // If accessibility is enabled, associate this bounding box with the element .
2347 if (AXObjectCache* axObjectCache = element->document()->existingAXObjectCach e()) {
2348 if (AccessibilityObject* obj = axObjectCache->getOrCreate(element)) {
2349 IntRect canvasRect = canvas()->renderer()->absoluteBoundingBoxRect() ;
2350 LayoutRect rect = LayoutRect(boundingRect);
2351 rect.moveBy(canvasRect.location());
2352 obj->setElementRect(rect);
2353 }
2354 }
2355
2356 // Only draw if the element is focused and if the function called wasn't dra wCustomFocusRing.
2357 if (custom || !element->focused())
2358 return;
2359
2360 // Get the outline style from the element and use it to draw the focus ring on the canvas.
2361 RenderStyle* style = element->computedStyle();
2362 if (!style)
2363 return;
2364
2365 c->save();
2366 c->setAlpha(1.0);
2367 c->clearShadow();
2368 Vector<IntRect> rects;
2369 rects.append(pixelSnappedIntRect(LayoutRect(boundingRect)));
2370 c->drawFocusRing(rects, style->outlineWidth(), style->outlineOffset(), style ->visitedDependentColor(CSSPropertyOutlineColor));
2371 c->restore();
2372 didDraw(boundingRect);
2373 }
2374
2310 } // namespace WebCore 2375 } // 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