| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "core/frame/ImageBitmap.h" | 48 #include "core/frame/ImageBitmap.h" |
| 49 #include "core/html/HTMLCanvasElement.h" | 49 #include "core/html/HTMLCanvasElement.h" |
| 50 #include "core/html/HTMLImageElement.h" | 50 #include "core/html/HTMLImageElement.h" |
| 51 #include "core/html/HTMLMediaElement.h" | 51 #include "core/html/HTMLMediaElement.h" |
| 52 #include "core/html/HTMLVideoElement.h" | 52 #include "core/html/HTMLVideoElement.h" |
| 53 #include "core/html/ImageData.h" | 53 #include "core/html/ImageData.h" |
| 54 #include "core/html/TextMetrics.h" | 54 #include "core/html/TextMetrics.h" |
| 55 #include "core/html/canvas/CanvasGradient.h" | 55 #include "core/html/canvas/CanvasGradient.h" |
| 56 #include "core/html/canvas/CanvasPattern.h" | 56 #include "core/html/canvas/CanvasPattern.h" |
| 57 #include "core/html/canvas/CanvasStyle.h" | 57 #include "core/html/canvas/CanvasStyle.h" |
| 58 #include "core/html/canvas/HitRegionOptions.h" | |
| 59 #include "core/html/canvas/Path2D.h" | 58 #include "core/html/canvas/Path2D.h" |
| 60 #include "core/rendering/RenderImage.h" | 59 #include "core/rendering/RenderImage.h" |
| 61 #include "core/rendering/RenderLayer.h" | 60 #include "core/rendering/RenderLayer.h" |
| 62 #include "core/rendering/RenderTheme.h" | 61 #include "core/rendering/RenderTheme.h" |
| 63 #include "platform/fonts/FontCache.h" | 62 #include "platform/fonts/FontCache.h" |
| 64 #include "platform/geometry/FloatQuad.h" | 63 #include "platform/geometry/FloatQuad.h" |
| 65 #include "platform/graphics/DrawLooperBuilder.h" | 64 #include "platform/graphics/DrawLooperBuilder.h" |
| 66 #include "platform/graphics/GraphicsContextStateSaver.h" | 65 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 67 #include "platform/text/TextRun.h" | 66 #include "platform/text/TextRun.h" |
| 68 #include "wtf/CheckedArithmetic.h" | 67 #include "wtf/CheckedArithmetic.h" |
| (...skipping 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2383 c->clearShadow(); | 2382 c->clearShadow(); |
| 2384 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); | 2383 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); |
| 2385 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); | 2384 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); |
| 2386 c->restore(); | 2385 c->restore(); |
| 2387 validateStateStack(); | 2386 validateStateStack(); |
| 2388 didDraw(dirtyRect); | 2387 didDraw(dirtyRect); |
| 2389 } | 2388 } |
| 2390 | 2389 |
| 2391 void CanvasRenderingContext2D::addHitRegion(const HitRegionOptions& options, Exc
eptionState& exceptionState) | 2390 void CanvasRenderingContext2D::addHitRegion(const HitRegionOptions& options, Exc
eptionState& exceptionState) |
| 2392 { | 2391 { |
| 2393 HitRegionOptionsInternal passOptions; | 2392 if (options.id().isEmpty() && !options.control()) { |
| 2394 passOptions.id = options.id(); | |
| 2395 passOptions.control = options.control(); | |
| 2396 if (passOptions.id.isEmpty() && !passOptions.control) { | |
| 2397 exceptionState.throwDOMException(NotSupportedError, "Both id and control
are null."); | 2393 exceptionState.throwDOMException(NotSupportedError, "Both id and control
are null."); |
| 2398 return; | 2394 return; |
| 2399 } | 2395 } |
| 2400 | 2396 |
| 2401 Path hitRegionPath = options.hasPath() ? options.path()->path() : m_path; | 2397 Path hitRegionPath = options.hasPath() ? options.path()->path() : m_path; |
| 2402 | 2398 |
| 2403 FloatRect clipBounds; | 2399 FloatRect clipBounds; |
| 2404 GraphicsContext* context = drawingContext(); | 2400 GraphicsContext* context = drawingContext(); |
| 2405 | 2401 |
| 2406 if (hitRegionPath.isEmpty() || !context || !state().m_invertibleCTM | 2402 if (hitRegionPath.isEmpty() || !context || !state().m_invertibleCTM |
| 2407 || !context->getTransformedClipBounds(&clipBounds)) { | 2403 || !context->getTransformedClipBounds(&clipBounds)) { |
| 2408 exceptionState.throwDOMException(NotSupportedError, "The specified path
has no pixels."); | 2404 exceptionState.throwDOMException(NotSupportedError, "The specified path
has no pixels."); |
| 2409 return; | 2405 return; |
| 2410 } | 2406 } |
| 2411 | 2407 |
| 2412 hitRegionPath.transform(state().m_transform); | 2408 hitRegionPath.transform(state().m_transform); |
| 2413 | 2409 |
| 2414 if (hasClip()) { | 2410 if (hasClip()) { |
| 2415 // FIXME: The hit regions should take clipping region into account. | 2411 // FIXME: The hit regions should take clipping region into account. |
| 2416 // However, we have no way to get the region from canvas state stack by
now. | 2412 // However, we have no way to get the region from canvas state stack by
now. |
| 2417 // See http://crbug.com/387057 | 2413 // See http://crbug.com/387057 |
| 2418 exceptionState.throwDOMException(NotSupportedError, "The specified path
has no pixels."); | 2414 exceptionState.throwDOMException(NotSupportedError, "The specified path
has no pixels."); |
| 2419 return; | 2415 return; |
| 2420 } | 2416 } |
| 2421 | 2417 |
| 2422 passOptions.path = hitRegionPath; | |
| 2423 | |
| 2424 if (options.fillRule() != "evenodd") | |
| 2425 passOptions.fillRule = RULE_NONZERO; | |
| 2426 else | |
| 2427 passOptions.fillRule = RULE_EVENODD; | |
| 2428 | |
| 2429 addHitRegionInternal(passOptions, exceptionState); | |
| 2430 } | |
| 2431 | |
| 2432 void CanvasRenderingContext2D::addHitRegionInternal(const HitRegionOptionsIntern
al& options, ExceptionState& exceptionState) | |
| 2433 { | |
| 2434 if (!m_hitRegionManager) | 2418 if (!m_hitRegionManager) |
| 2435 m_hitRegionManager = HitRegionManager::create(); | 2419 m_hitRegionManager = HitRegionManager::create(); |
| 2436 | 2420 |
| 2437 // Remove previous region (with id or control) | 2421 // Remove previous region (with id or control) |
| 2438 m_hitRegionManager->removeHitRegionById(options.id); | 2422 m_hitRegionManager->removeHitRegionById(options.id()); |
| 2439 m_hitRegionManager->removeHitRegionByControl(options.control.get()); | 2423 m_hitRegionManager->removeHitRegionByControl(options.control().get()); |
| 2440 | 2424 |
| 2441 RefPtrWillBeRawPtr<HitRegion> hitRegion = HitRegion::create(options); | 2425 RefPtrWillBeRawPtr<HitRegion> hitRegion = HitRegion::create(hitRegionPath, o
ptions); |
| 2442 hitRegion->updateAccessibility(canvas()); | 2426 hitRegion->updateAccessibility(canvas()); |
| 2443 m_hitRegionManager->addHitRegion(hitRegion.release()); | 2427 m_hitRegionManager->addHitRegion(hitRegion.release()); |
| 2444 } | 2428 } |
| 2445 | 2429 |
| 2446 void CanvasRenderingContext2D::removeHitRegion(const String& id) | 2430 void CanvasRenderingContext2D::removeHitRegion(const String& id) |
| 2447 { | 2431 { |
| 2448 if (m_hitRegionManager) | 2432 if (m_hitRegionManager) |
| 2449 m_hitRegionManager->removeHitRegionById(id); | 2433 m_hitRegionManager->removeHitRegionById(id); |
| 2450 } | 2434 } |
| 2451 | 2435 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2465 | 2449 |
| 2466 unsigned CanvasRenderingContext2D::hitRegionsCount() const | 2450 unsigned CanvasRenderingContext2D::hitRegionsCount() const |
| 2467 { | 2451 { |
| 2468 if (m_hitRegionManager) | 2452 if (m_hitRegionManager) |
| 2469 return m_hitRegionManager->getHitRegionsCount(); | 2453 return m_hitRegionManager->getHitRegionsCount(); |
| 2470 | 2454 |
| 2471 return 0; | 2455 return 0; |
| 2472 } | 2456 } |
| 2473 | 2457 |
| 2474 } // namespace blink | 2458 } // namespace blink |
| OLD | NEW |