| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> |
| 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
| 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "core/paint/FloatClipRecorder.h" | 40 #include "core/paint/FloatClipRecorder.h" |
| 41 #include "core/paint/TransformRecorder.h" | 41 #include "core/paint/TransformRecorder.h" |
| 42 #include "core/svg/SVGDocumentExtensions.h" | 42 #include "core/svg/SVGDocumentExtensions.h" |
| 43 #include "core/svg/SVGFEImageElement.h" | 43 #include "core/svg/SVGFEImageElement.h" |
| 44 #include "core/svg/SVGImageElement.h" | 44 #include "core/svg/SVGImageElement.h" |
| 45 #include "core/svg/SVGSVGElement.h" | 45 #include "core/svg/SVGSVGElement.h" |
| 46 #include "core/svg/animation/SMILTimeContainer.h" | 46 #include "core/svg/animation/SMILTimeContainer.h" |
| 47 #include "core/svg/graphics/SVGImageChromeClient.h" | 47 #include "core/svg/graphics/SVGImageChromeClient.h" |
| 48 #include "platform/EventDispatchForbiddenScope.h" | 48 #include "platform/EventDispatchForbiddenScope.h" |
| 49 #include "platform/LengthFunctions.h" | 49 #include "platform/LengthFunctions.h" |
| 50 #include "platform/ScriptForbiddenScope.h" |
| 50 #include "platform/TraceEvent.h" | 51 #include "platform/TraceEvent.h" |
| 51 #include "platform/geometry/IntRect.h" | 52 #include "platform/geometry/IntRect.h" |
| 52 #include "platform/graphics/GraphicsContext.h" | 53 #include "platform/graphics/GraphicsContext.h" |
| 53 #include "platform/graphics/ImageBuffer.h" | 54 #include "platform/graphics/ImageBuffer.h" |
| 54 #include "platform/graphics/ImageObserver.h" | 55 #include "platform/graphics/ImageObserver.h" |
| 55 #include "platform/graphics/paint/ClipRecorder.h" | 56 #include "platform/graphics/paint/ClipRecorder.h" |
| 56 #include "platform/graphics/paint/CullRect.h" | 57 #include "platform/graphics/paint/CullRect.h" |
| 57 #include "platform/graphics/paint/DrawingRecorder.h" | 58 #include "platform/graphics/paint/DrawingRecorder.h" |
| 58 #include "platform/graphics/paint/SkPictureBuilder.h" | 59 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 59 #include "third_party/skia/include/core/SkPicture.h" | 60 #include "third_party/skia/include/core/SkPicture.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 { | 331 { |
| 331 if (!m_page) | 332 if (!m_page) |
| 332 return; | 333 return; |
| 333 | 334 |
| 334 drawInternal(canvas, paint, dstRect, srcRect, shouldRespectImageOrientation,
clampMode, KURL()); | 335 drawInternal(canvas, paint, dstRect, srcRect, shouldRespectImageOrientation,
clampMode, KURL()); |
| 335 } | 336 } |
| 336 | 337 |
| 337 void SVGImage::drawInternal(SkCanvas* canvas, const SkPaint& paint, const FloatR
ect& dstRect, const FloatRect& srcRect, | 338 void SVGImage::drawInternal(SkCanvas* canvas, const SkPaint& paint, const FloatR
ect& dstRect, const FloatRect& srcRect, |
| 338 RespectImageOrientationEnum, ImageClampingMode, const KURL& url) | 339 RespectImageOrientationEnum, ImageClampingMode, const KURL& url) |
| 339 { | 340 { |
| 340 FrameView* view = frameView(); | 341 DCHECK(m_page); |
| 342 FrameView* view = toLocalFrame(m_page->mainFrame())->view(); |
| 341 view->resize(containerSize()); | 343 view->resize(containerSize()); |
| 342 | 344 |
| 343 // Always call processUrlFragment, even if the url is empty, because | 345 // Always call processUrlFragment, even if the url is empty, because |
| 344 // there may have been a previous url/fragment that needs to be reset. | 346 // there may have been a previous url/fragment that needs to be reset. |
| 345 view->processUrlFragment(url); | 347 view->processUrlFragment(url); |
| 346 | 348 |
| 347 SkPictureBuilder imagePicture(dstRect); | 349 SkPictureBuilder imagePicture(dstRect); |
| 348 { | 350 { |
| 349 ClipRecorder clipRecorder(imagePicture.context(), imagePicture, DisplayI
tem::ClipNodeImage, LayoutRect(enclosingIntRect(dstRect))); | 351 ClipRecorder clipRecorder(imagePicture.context(), imagePicture, DisplayI
tem::ClipNodeImage, LayoutRect(enclosingIntRect(dstRect))); |
| 350 | 352 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 } | 384 } |
| 383 | 385 |
| 384 LayoutReplaced* SVGImage::embeddedReplacedContent() const | 386 LayoutReplaced* SVGImage::embeddedReplacedContent() const |
| 385 { | 387 { |
| 386 SVGSVGElement* rootElement = svgRootElement(m_page.get()); | 388 SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
| 387 if (!rootElement) | 389 if (!rootElement) |
| 388 return nullptr; | 390 return nullptr; |
| 389 return toLayoutSVGRoot(rootElement->layoutObject()); | 391 return toLayoutSVGRoot(rootElement->layoutObject()); |
| 390 } | 392 } |
| 391 | 393 |
| 392 FrameView* SVGImage::frameView() const | |
| 393 { | |
| 394 if (!m_page) | |
| 395 return nullptr; | |
| 396 | |
| 397 return toLocalFrame(m_page->mainFrame())->view(); | |
| 398 } | |
| 399 | |
| 400 // FIXME: support CatchUpAnimation = CatchUp. | 394 // FIXME: support CatchUpAnimation = CatchUp. |
| 401 void SVGImage::startAnimation(CatchUpAnimation) | 395 void SVGImage::startAnimation(CatchUpAnimation) |
| 402 { | 396 { |
| 403 SVGSVGElement* rootElement = svgRootElement(m_page.get()); | 397 SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
| 404 if (!rootElement || !rootElement->animationsPaused()) | 398 if (!rootElement) |
| 405 return; | 399 return; |
| 406 rootElement->unpauseAnimations(); | 400 m_chromeClient->resumeAnimation(); |
| 401 if (rootElement->animationsPaused()) |
| 402 rootElement->unpauseAnimations(); |
| 407 } | 403 } |
| 408 | 404 |
| 409 void SVGImage::stopAnimation() | 405 void SVGImage::stopAnimation() |
| 410 { | 406 { |
| 411 SVGSVGElement* rootElement = svgRootElement(m_page.get()); | 407 SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
| 412 if (!rootElement) | 408 if (!rootElement) |
| 413 return; | 409 return; |
| 410 m_chromeClient->suspendAnimation(); |
| 414 rootElement->pauseAnimations(); | 411 rootElement->pauseAnimations(); |
| 415 } | 412 } |
| 416 | 413 |
| 417 void SVGImage::resetAnimation() | 414 void SVGImage::resetAnimation() |
| 418 { | 415 { |
| 419 SVGSVGElement* rootElement = svgRootElement(m_page.get()); | 416 SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
| 420 if (!rootElement) | 417 if (!rootElement) |
| 421 return; | 418 return; |
| 419 m_chromeClient->suspendAnimation(); |
| 422 rootElement->pauseAnimations(); | 420 rootElement->pauseAnimations(); |
| 423 rootElement->setCurrentTime(0); | 421 rootElement->setCurrentTime(0); |
| 424 } | 422 } |
| 425 | 423 |
| 426 bool SVGImage::hasAnimations() const | 424 bool SVGImage::hasAnimations() const |
| 427 { | 425 { |
| 428 SVGSVGElement* rootElement = svgRootElement(m_page.get()); | 426 SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
| 429 if (!rootElement) | 427 if (!rootElement) |
| 430 return false; | 428 return false; |
| 431 return rootElement->timeContainer()->hasAnimations() || toLocalFrame(m_page-
>mainFrame())->document()->timeline().hasPendingUpdates(); | 429 return rootElement->timeContainer()->hasAnimations() |
| 430 || toLocalFrame(m_page->mainFrame())->document()->timeline().hasPendingU
pdates(); |
| 431 } |
| 432 |
| 433 void SVGImage::serviceAnimations(double monotonicAnimationStartTime) |
| 434 { |
| 435 // If none of our observers (sic!) are visible, or for some other reason |
| 436 // does not want us to keep running animations, stop them until further |
| 437 // notice (next paint.) |
| 438 if (getImageObserver()->shouldPauseAnimation(this)) { |
| 439 stopAnimation(); |
| 440 return; |
| 441 } |
| 442 |
| 443 // serviceScriptedAnimations runs requestAnimationFrame callbacks, but SVG |
| 444 // images can't have any so we assert there's no script. |
| 445 ScriptForbiddenScope forbidScript; |
| 446 |
| 447 // The calls below may trigger GCs, so set up the required persistent |
| 448 // reference on the ImageResource which owns this SVGImage. By transitivity, |
| 449 // that will keep the associated SVGImageChromeClient object alive. |
| 450 Persistent<ImageObserver> protect(getImageObserver()); |
| 451 m_page->animator().serviceScriptedAnimations(monotonicAnimationStartTime); |
| 452 m_page->animator().updateAllLifecyclePhases(*toLocalFrame(m_page->mainFrame(
))); |
| 432 } | 453 } |
| 433 | 454 |
| 434 void SVGImage::advanceAnimationForTesting() | 455 void SVGImage::advanceAnimationForTesting() |
| 435 { | 456 { |
| 436 if (SVGSVGElement* rootElement = svgRootElement(m_page.get())) { | 457 if (SVGSVGElement* rootElement = svgRootElement(m_page.get())) { |
| 437 rootElement->timeContainer()->advanceFrameForTesting(); | 458 rootElement->timeContainer()->advanceFrameForTesting(); |
| 438 | 459 |
| 439 // The following triggers animation updates which can issue a new draw | 460 // The following triggers animation updates which can issue a new draw |
| 440 // but will not permanently change the animation timeline. | 461 // but will not permanently change the animation timeline. |
| 441 // TODO(pdr): Actually advance the document timeline so CSS animations | 462 // TODO(pdr): Actually advance the document timeline so CSS animations |
| 442 // can be properly tested. | 463 // can be properly tested. |
| 443 rootElement->document().page()->animator().serviceScriptedAnimations(roo
tElement->getCurrentTime()); | 464 m_page->animator().serviceScriptedAnimations(rootElement->getCurrentTime
()); |
| 444 getImageObserver()->animationAdvanced(this); | 465 getImageObserver()->animationAdvanced(this); |
| 445 } | 466 } |
| 446 } | 467 } |
| 447 | 468 |
| 448 void SVGImage::updateUseCounters(Document& document) const | 469 void SVGImage::updateUseCounters(Document& document) const |
| 449 { | 470 { |
| 450 if (SVGSVGElement* rootElement = svgRootElement(m_page.get())) { | 471 if (SVGSVGElement* rootElement = svgRootElement(m_page.get())) { |
| 451 if (rootElement->timeContainer()->hasAnimations()) | 472 if (rootElement->timeContainer()->hasAnimations()) |
| 452 Deprecation::countDeprecation(document, UseCounter::SVGSMILAnimation
InImageRegardlessOfCache); | 473 Deprecation::countDeprecation(document, UseCounter::SVGSMILAnimation
InImageRegardlessOfCache); |
| 453 } | 474 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 556 |
| 536 return m_page; | 557 return m_page; |
| 537 } | 558 } |
| 538 | 559 |
| 539 String SVGImage::filenameExtension() const | 560 String SVGImage::filenameExtension() const |
| 540 { | 561 { |
| 541 return "svg"; | 562 return "svg"; |
| 542 } | 563 } |
| 543 | 564 |
| 544 } // namespace blink | 565 } // namespace blink |
| OLD | NEW |