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

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: 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
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;
Rik 2014/06/29 03:22:22 Will the current CTM be applied to the path that y
zino 2014/06/29 04:07:18 Yes, you can see here. 2394 specifiedPath.tran
2384
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.");
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 2441
2434 unsigned CanvasRenderingContext2D::hitRegionsCount() const 2442 unsigned CanvasRenderingContext2D::hitRegionsCount() const
2435 { 2443 {
2436 if (m_hitRegionManager) 2444 if (m_hitRegionManager)
2437 return m_hitRegionManager->getHitRegionsCount(); 2445 return m_hitRegionManager->getHitRegionsCount();
2438 2446
2439 return 0; 2447 return 0;
2440 } 2448 }
2441 2449
2442 } // namespace WebCore 2450 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698