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

Side by Side Diff: Source/core/svg/graphics/SVGImage.cpp

Issue 336553003: Change Page::m_mainFrame to be a Frame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/TextAutosizer.cpp ('k') | Source/core/testing/Internals.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 SVGImage::SVGImage(ImageObserver* observer) 59 SVGImage::SVGImage(ImageObserver* observer)
60 : Image(observer) 60 : Image(observer)
61 { 61 {
62 } 62 }
63 63
64 SVGImage::~SVGImage() 64 SVGImage::~SVGImage()
65 { 65 {
66 if (m_page) { 66 if (m_page) {
67 // Store m_page in a local variable, clearing m_page, so that SVGImageCh romeClient knows we're destructed. 67 // Store m_page in a local variable, clearing m_page, so that SVGImageCh romeClient knows we're destructed.
68 OwnPtrWillBeRawPtr<Page> currentPage = m_page.release(); 68 OwnPtrWillBeRawPtr<Page> currentPage = m_page.release();
69 currentPage->mainFrame()->loader().frameDetached(); // Break both the lo ader and view references to the frame 69 toLocalFrame(currentPage->mainFrame())->loader().frameDetached(); // Bre ak both the loader and view references to the frame
70 currentPage->willBeDestroyed(); 70 currentPage->willBeDestroyed();
71 } 71 }
72 72
73 // Verify that page teardown destroyed the Chrome 73 // Verify that page teardown destroyed the Chrome
74 ASSERT(!m_chromeClient || !m_chromeClient->image()); 74 ASSERT(!m_chromeClient || !m_chromeClient->image());
75 } 75 }
76 76
77 bool SVGImage::isInSVGImage(const Node* node) 77 bool SVGImage::isInSVGImage(const Node* node)
78 { 78 {
79 ASSERT(node); 79 ASSERT(node);
80 80
81 Page* page = node->document().page(); 81 Page* page = node->document().page();
82 if (!page) 82 if (!page)
83 return false; 83 return false;
84 84
85 return page->chrome().client().isSVGImageChromeClient(); 85 return page->chrome().client().isSVGImageChromeClient();
86 } 86 }
87 87
88 bool SVGImage::currentFrameHasSingleSecurityOrigin() const 88 bool SVGImage::currentFrameHasSingleSecurityOrigin() const
89 { 89 {
90 if (!m_page) 90 if (!m_page)
91 return true; 91 return true;
92 92
93 LocalFrame* frame = m_page->mainFrame(); 93 LocalFrame* frame = toLocalFrame(m_page->mainFrame());
94 94
95 RELEASE_ASSERT(frame->document()->loadEventFinished()); 95 RELEASE_ASSERT(frame->document()->loadEventFinished());
96 96
97 SVGSVGElement* rootElement = frame->document()->accessSVGExtensions().rootEl ement(); 97 SVGSVGElement* rootElement = frame->document()->accessSVGExtensions().rootEl ement();
98 if (!rootElement) 98 if (!rootElement)
99 return true; 99 return true;
100 100
101 // Don't allow foreignObject elements or images that are not known to be 101 // Don't allow foreignObject elements or images that are not known to be
102 // single-origin since these can leak cross-origin information. 102 // single-origin since these can leak cross-origin information.
103 ComposedTreeWalker walker(rootElement); 103 ComposedTreeWalker walker(rootElement);
(...skipping 12 matching lines...) Expand all
116 116
117 // Because SVG image rendering disallows external resources and links, these 117 // Because SVG image rendering disallows external resources and links, these
118 // images effectively are restricted to a single security origin. 118 // images effectively are restricted to a single security origin.
119 return true; 119 return true;
120 } 120 }
121 121
122 static SVGSVGElement* svgRootElement(Page* page) 122 static SVGSVGElement* svgRootElement(Page* page)
123 { 123 {
124 if (!page) 124 if (!page)
125 return 0; 125 return 0;
126 LocalFrame* frame = page->mainFrame(); 126 LocalFrame* frame = toLocalFrame(page->mainFrame());
127 return frame->document()->accessSVGExtensions().rootElement(); 127 return frame->document()->accessSVGExtensions().rootElement();
128 } 128 }
129 129
130 void SVGImage::setContainerSize(const IntSize& size) 130 void SVGImage::setContainerSize(const IntSize& size)
131 { 131 {
132 if (!usesContainerSize()) 132 if (!usesContainerSize())
133 return; 133 return;
134 134
135 SVGSVGElement* rootElement = svgRootElement(m_page.get()); 135 SVGSVGElement* rootElement = svgRootElement(m_page.get());
136 if (!rootElement) 136 if (!rootElement)
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if (!rootElement) 313 if (!rootElement)
314 return 0; 314 return 0;
315 return toRenderBox(rootElement->renderer()); 315 return toRenderBox(rootElement->renderer());
316 } 316 }
317 317
318 FrameView* SVGImage::frameView() const 318 FrameView* SVGImage::frameView() const
319 { 319 {
320 if (!m_page) 320 if (!m_page)
321 return 0; 321 return 0;
322 322
323 return m_page->mainFrame()->view(); 323 return toLocalFrame(m_page->mainFrame())->view();
324 } 324 }
325 325
326 void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrin sicHeight, FloatSize& intrinsicRatio) 326 void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrin sicHeight, FloatSize& intrinsicRatio)
327 { 327 {
328 SVGSVGElement* rootElement = svgRootElement(m_page.get()); 328 SVGSVGElement* rootElement = svgRootElement(m_page.get());
329 if (!rootElement) 329 if (!rootElement)
330 return; 330 return;
331 331
332 intrinsicWidth = rootElement->intrinsicWidth(); 332 intrinsicWidth = rootElement->intrinsicWidth();
333 intrinsicHeight = rootElement->intrinsicHeight(); 333 intrinsicHeight = rootElement->intrinsicHeight();
(...skipping 29 matching lines...) Expand all
363 return; 363 return;
364 rootElement->pauseAnimations(); 364 rootElement->pauseAnimations();
365 rootElement->setCurrentTime(0); 365 rootElement->setCurrentTime(0);
366 } 366 }
367 367
368 bool SVGImage::hasAnimations() const 368 bool SVGImage::hasAnimations() const
369 { 369 {
370 SVGSVGElement* rootElement = svgRootElement(m_page.get()); 370 SVGSVGElement* rootElement = svgRootElement(m_page.get());
371 if (!rootElement) 371 if (!rootElement)
372 return false; 372 return false;
373 return rootElement->timeContainer()->hasAnimations() || m_page->mainFrame()- >document()->timeline().hasPendingUpdates(); 373 return rootElement->timeContainer()->hasAnimations() || toLocalFrame(m_page- >mainFrame())->document()->timeline().hasPendingUpdates();
374 } 374 }
375 375
376 bool SVGImage::dataChanged(bool allDataReceived) 376 bool SVGImage::dataChanged(bool allDataReceived)
377 { 377 {
378 TRACE_EVENT0("webkit", "SVGImage::dataChanged"); 378 TRACE_EVENT0("webkit", "SVGImage::dataChanged");
379 379
380 // Don't do anything if is an empty image. 380 // Don't do anything if is an empty image.
381 if (!data()->size()) 381 if (!data()->size())
382 return true; 382 return true;
383 383
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 425
426 return m_page; 426 return m_page;
427 } 427 }
428 428
429 String SVGImage::filenameExtension() const 429 String SVGImage::filenameExtension() const
430 { 430 {
431 return "svg"; 431 return "svg";
432 } 432 }
433 433
434 } 434 }
OLDNEW
« no previous file with comments | « Source/core/rendering/TextAutosizer.cpp ('k') | Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698