OLD | NEW |
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 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 { | 2371 { |
2372 HitRegionOptions passOptions; | 2372 HitRegionOptions passOptions; |
2373 | 2373 |
2374 options.getWithUndefinedOrNullCheck("id", passOptions.id); | 2374 options.getWithUndefinedOrNullCheck("id", passOptions.id); |
2375 options.getWithUndefinedOrNullCheck("control", passOptions.control); | 2375 options.getWithUndefinedOrNullCheck("control", passOptions.control); |
2376 if (passOptions.id.isEmpty() && !passOptions.control) { | 2376 if (passOptions.id.isEmpty() && !passOptions.control) { |
2377 exceptionState.throwDOMException(NotSupportedError, "Both id and control
are null."); | 2377 exceptionState.throwDOMException(NotSupportedError, "Both id and control
are null."); |
2378 return; | 2378 return; |
2379 } | 2379 } |
2380 | 2380 |
| 2381 RefPtr<Path2D> path2d; |
| 2382 options.getWithUndefinedOrNullCheck("path", path2d); |
| 2383 Path hitRegionPath = path2d ? path2d->path() : m_path; |
| 2384 |
2381 FloatRect clipBounds; | 2385 FloatRect clipBounds; |
2382 GraphicsContext* context = drawingContext(); | 2386 GraphicsContext* context = drawingContext(); |
2383 | 2387 |
2384 if (m_path.isEmpty() || !context || !state().m_invertibleCTM | 2388 if (hitRegionPath.isEmpty() || !context || !state().m_invertibleCTM |
2385 || !context->getTransformedClipBounds(&clipBounds)) { | 2389 || !context->getTransformedClipBounds(&clipBounds)) { |
2386 exceptionState.throwDOMException(NotSupportedError, "The specified path
has no pixels."); | 2390 exceptionState.throwDOMException(NotSupportedError, "The specified path
has no pixels."); |
2387 return; | 2391 return; |
2388 } | 2392 } |
2389 | 2393 |
2390 Path specifiedPath = m_path; | 2394 hitRegionPath.transform(state().m_transform); |
2391 specifiedPath.transform(state().m_transform); | |
2392 | 2395 |
2393 if (hasClip()) { | 2396 if (hasClip()) { |
2394 // FIXME: The hit regions should take clipping region into account. | 2397 // FIXME: The hit regions should take clipping region into account. |
2395 // 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. |
2396 // See http://crbug.com/387057 | 2399 // See http://crbug.com/387057 |
2397 exceptionState.throwDOMException(NotSupportedError, "The specified path
has no pixels."); | 2400 exceptionState.throwDOMException(NotSupportedError, "The specified path
has no pixels."); |
2398 return; | 2401 return; |
2399 } | 2402 } |
2400 | 2403 |
2401 passOptions.path = specifiedPath; | 2404 passOptions.path = hitRegionPath; |
2402 | 2405 |
2403 String fillRuleString; | 2406 String fillRuleString; |
2404 options.getWithUndefinedOrNullCheck("fillRule", fillRuleString); | 2407 options.getWithUndefinedOrNullCheck("fillRule", fillRuleString); |
2405 if (fillRuleString.isEmpty() || fillRuleString != "evenodd") | 2408 if (fillRuleString.isEmpty() || fillRuleString != "evenodd") |
2406 passOptions.fillRule = RULE_NONZERO; | 2409 passOptions.fillRule = RULE_NONZERO; |
2407 else | 2410 else |
2408 passOptions.fillRule = RULE_EVENODD; | 2411 passOptions.fillRule = RULE_EVENODD; |
2409 | 2412 |
2410 addHitRegionInternal(passOptions, exceptionState); | 2413 addHitRegionInternal(passOptions, exceptionState); |
2411 } | 2414 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2446 | 2449 |
2447 unsigned CanvasRenderingContext2D::hitRegionsCount() const | 2450 unsigned CanvasRenderingContext2D::hitRegionsCount() const |
2448 { | 2451 { |
2449 if (m_hitRegionManager) | 2452 if (m_hitRegionManager) |
2450 return m_hitRegionManager->getHitRegionsCount(); | 2453 return m_hitRegionManager->getHitRegionsCount(); |
2451 | 2454 |
2452 return 0; | 2455 return 0; |
2453 } | 2456 } |
2454 | 2457 |
2455 } // namespace WebCore | 2458 } // namespace WebCore |
OLD | NEW |