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

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

Issue 354333002: Add path option(path2d) for hit regions on canvas2d. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add test for transform Created 6 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
« no previous file with comments | « Source/bindings/v8/Dictionary.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 { 2366 {
2367 HitRegionOptions passOptions; 2367 HitRegionOptions passOptions;
2368 2368
2369 options.getWithUndefinedOrNullCheck("id", passOptions.id); 2369 options.getWithUndefinedOrNullCheck("id", passOptions.id);
2370 options.getWithUndefinedOrNullCheck("control", passOptions.control); 2370 options.getWithUndefinedOrNullCheck("control", passOptions.control);
2371 if (passOptions.id.isEmpty() && !passOptions.control) { 2371 if (passOptions.id.isEmpty() && !passOptions.control) {
2372 exceptionState.throwDOMException(NotSupportedError, "Both id and control are null."); 2372 exceptionState.throwDOMException(NotSupportedError, "Both id and control are null.");
2373 return; 2373 return;
2374 } 2374 }
2375 2375
2376 RefPtr<Path2D> path2d;
2377 options.getWithUndefinedOrNullCheck("path", path2d);
2378
2379 Path specifiedPath;
2380 if (path2d)
2381 specifiedPath = path2d->path();
2382 else
2383 specifiedPath = m_path;
2384
c.shu 2014/07/01 02:03:28 The above can be simplified as Path specifiedPath
zino 2014/07/01 05:37:28 Done.
2376 FloatRect clipBounds; 2385 FloatRect clipBounds;
2377 GraphicsContext* context = drawingContext(); 2386 GraphicsContext* context = drawingContext();
2378 2387
2379 if (m_path.isEmpty() || !context || !state().m_invertibleCTM 2388 if (specifiedPath.isEmpty() || !context || !state().m_invertibleCTM
2380 || !context->getTransformedClipBounds(&clipBounds)) { 2389 || !context->getTransformedClipBounds(&clipBounds)) {
2381 exceptionState.throwDOMException(NotSupportedError, "The specified path has no pixels."); 2390 exceptionState.throwDOMException(NotSupportedError, "The specified path has no pixels.");
Rik 2014/06/30 16:42:00 I know this isn't part of this CL but we really sh
zino 2014/07/01 05:37:28 I'm not sure but, According to the spec, if the sp
2382 return; 2391 return;
2383 } 2392 }
2384 2393
2385 Path specifiedPath = m_path;
2386 specifiedPath.transform(state().m_transform); 2394 specifiedPath.transform(state().m_transform);
2387 2395
2388 if (context->isClipMode()) { 2396 if (context->isClipMode()) {
2389 // FIXME: The hit regions should take clipping region into account. 2397 // FIXME: The hit regions should take clipping region into account.
2390 // However, we have no way to get the region from canvas state stack by now. 2398 // However, we have no way to get the region from canvas state stack by now.
2391 // See http://crbug.com/387057 2399 // See http://crbug.com/387057
2392 exceptionState.throwDOMException(NotSupportedError, "The specified path has no pixels."); 2400 exceptionState.throwDOMException(NotSupportedError, "The specified path has no pixels.");
2393 return; 2401 return;
2394 } 2402 }
2395 2403
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 2449
2442 unsigned CanvasRenderingContext2D::hitRegionsCount() const 2450 unsigned CanvasRenderingContext2D::hitRegionsCount() const
2443 { 2451 {
2444 if (m_hitRegionManager) 2452 if (m_hitRegionManager)
2445 return m_hitRegionManager->getHitRegionsCount(); 2453 return m_hitRegionManager->getHitRegionsCount();
2446 2454
2447 return 0; 2455 return 0;
2448 } 2456 }
2449 2457
2450 } // namespace WebCore 2458 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/Dictionary.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698