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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // Store m_page in a local variable, clearing m_page, so that SVGImageCh
romeClient knows we're destructed. | 72 // Store m_page in a local variable, clearing m_page, so that SVGImageCh
romeClient knows we're destructed. |
73 Page* currentPage = m_page.release(); | 73 Page* currentPage = m_page.release(); |
74 // Break both the loader and view references to the frame | 74 // Break both the loader and view references to the frame |
75 currentPage->willBeDestroyed(); | 75 currentPage->willBeDestroyed(); |
76 } | 76 } |
77 | 77 |
78 // Verify that page teardown destroyed the Chrome | 78 // Verify that page teardown destroyed the Chrome |
79 ASSERT(!m_chromeClient || !m_chromeClient->image()); | 79 ASSERT(!m_chromeClient || !m_chromeClient->image()); |
80 } | 80 } |
81 | 81 |
82 LayoutRect SVGImage::visualRect() const | |
83 { | |
84 // TODO(chrishtr): fix this. | |
85 return LayoutRect(); | |
86 } | |
87 | |
88 bool SVGImage::isInSVGImage(const Node* node) | 82 bool SVGImage::isInSVGImage(const Node* node) |
89 { | 83 { |
90 ASSERT(node); | 84 ASSERT(node); |
91 | 85 |
92 Page* page = node->document().page(); | 86 Page* page = node->document().page(); |
93 if (!page) | 87 if (!page) |
94 return false; | 88 return false; |
95 | 89 |
96 return page->chromeClient().isSVGImageChromeClient(); | 90 return page->chromeClient().isSVGImageChromeClient(); |
97 } | 91 } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 { | 270 { |
277 // Tile adjusted for scaling/stretch. | 271 // Tile adjusted for scaling/stretch. |
278 FloatRect tile(srcRect); | 272 FloatRect tile(srcRect); |
279 tile.scale(tileScale.width(), tileScale.height()); | 273 tile.scale(tileScale.width(), tileScale.height()); |
280 | 274 |
281 // Expand the tile to account for repeat spacing. | 275 // Expand the tile to account for repeat spacing. |
282 FloatRect spacedTile(tile); | 276 FloatRect spacedTile(tile); |
283 spacedTile.expand(FloatSize(repeatSpacing)); | 277 spacedTile.expand(FloatSize(repeatSpacing)); |
284 | 278 |
285 SkPictureBuilder patternPicture(spacedTile, nullptr, &context); | 279 SkPictureBuilder patternPicture(spacedTile, nullptr, &context); |
286 if (!DrawingRecorder::useCachedDrawingIfPossible(patternPicture.context(), *
this, DisplayItem::Type::SVGImage)) { | 280 { |
287 DrawingRecorder patternPictureRecorder(patternPicture.context(), *this,
DisplayItem::Type::SVGImage, spacedTile); | 281 DrawingRecorder patternPictureRecorder(patternPicture.context(), pattern
Picture, DisplayItem::Type::SVGImage, spacedTile); |
288 // When generating an expanded tile, make sure we don't draw into the sp
acing area. | 282 // When generating an expanded tile, make sure we don't draw into the sp
acing area. |
289 if (tile != spacedTile) | 283 if (tile != spacedTile) |
290 patternPicture.context().clip(tile); | 284 patternPicture.context().clip(tile); |
291 SkPaint paint; | 285 SkPaint paint; |
292 drawForContainer(patternPicture.context().canvas(), paint, containerSize
, zoom, tile, srcRect, url); | 286 drawForContainer(patternPicture.context().canvas(), paint, containerSize
, zoom, tile, srcRect, url); |
293 } | 287 } |
294 RefPtr<SkPicture> tilePicture = patternPicture.endRecording(); | 288 RefPtr<SkPicture> tilePicture = patternPicture.endRecording(); |
295 | 289 |
296 SkMatrix patternTransform; | 290 SkMatrix patternTransform; |
297 patternTransform.setTranslate(phase.x() + spacedTile.x(), phase.y() + spaced
Tile.y()); | 291 patternTransform.setTranslate(phase.x() + spacedTile.x(), phase.y() + spaced
Tile.y()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 { | 339 { |
346 FrameView* view = frameView(); | 340 FrameView* view = frameView(); |
347 view->resize(containerSize()); | 341 view->resize(containerSize()); |
348 | 342 |
349 // Always call processUrlFragment, even if the url is empty, because | 343 // Always call processUrlFragment, even if the url is empty, because |
350 // there may have been a previous url/fragment that needs to be reset. | 344 // there may have been a previous url/fragment that needs to be reset. |
351 view->processUrlFragment(url); | 345 view->processUrlFragment(url); |
352 | 346 |
353 SkPictureBuilder imagePicture(dstRect); | 347 SkPictureBuilder imagePicture(dstRect); |
354 { | 348 { |
355 ClipRecorder clipRecorder(imagePicture.context(), *this, DisplayItem::Cl
ipNodeImage, LayoutRect(enclosingIntRect(dstRect))); | 349 ClipRecorder clipRecorder(imagePicture.context(), imagePicture, DisplayI
tem::ClipNodeImage, LayoutRect(enclosingIntRect(dstRect))); |
356 | 350 |
357 // We can only draw the entire frame, clipped to the rect we want. So co
mpute where the top left | 351 // We can only draw the entire frame, clipped to the rect we want. So co
mpute where the top left |
358 // of the image would be if we were drawing without clipping, and transl
ate accordingly. | 352 // of the image would be if we were drawing without clipping, and transl
ate accordingly. |
359 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / sr
cRect.height()); | 353 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / sr
cRect.height()); |
360 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.
location().y() * scale.height()); | 354 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.
location().y() * scale.height()); |
361 FloatPoint destOffset = dstRect.location() - topLeftOffset; | 355 FloatPoint destOffset = dstRect.location() - topLeftOffset; |
362 AffineTransform transform = AffineTransform::translation(destOffset.x(),
destOffset.y()); | 356 AffineTransform transform = AffineTransform::translation(destOffset.x(),
destOffset.y()); |
363 transform.scale(scale.width(), scale.height()); | 357 transform.scale(scale.width(), scale.height()); |
364 TransformRecorder transformRecorder(imagePicture.context(), *this, trans
form); | 358 TransformRecorder transformRecorder(imagePicture.context(), imagePicture
, transform); |
365 | 359 |
366 view->updateAllLifecyclePhasesExceptPaint(); | 360 view->updateAllLifecyclePhasesExceptPaint(); |
367 view->paint(imagePicture.context(), CullRect(enclosingIntRect(srcRect)))
; | 361 view->paint(imagePicture.context(), CullRect(enclosingIntRect(srcRect)))
; |
368 ASSERT(!view->needsLayout()); | 362 ASSERT(!view->needsLayout()); |
369 } | 363 } |
370 | 364 |
371 { | 365 { |
372 SkAutoCanvasRestore ar(canvas, false); | 366 SkAutoCanvasRestore ar(canvas, false); |
373 if (drawNeedsLayer(paint)) { | 367 if (drawNeedsLayer(paint)) { |
374 SkRect layerRect = dstRect; | 368 SkRect layerRect = dstRect; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 | 535 |
542 return m_page; | 536 return m_page; |
543 } | 537 } |
544 | 538 |
545 String SVGImage::filenameExtension() const | 539 String SVGImage::filenameExtension() const |
546 { | 540 { |
547 return "svg"; | 541 return "svg"; |
548 } | 542 } |
549 | 543 |
550 } // namespace blink | 544 } // namespace blink |
OLD | NEW |