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

Side by Side Diff: Source/web/WebFrameImpl.cpp

Issue 23570006: Refactoring: Add convenience method toPluginContainerImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rework with comments Created 7 years, 3 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
« no previous file with comments | « Source/web/ContextMenuClientImpl.cpp ('k') | Source/web/WebHelperPluginImpl.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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return ++next; 274 return ++next;
275 } 275 }
276 276
277 WebPluginContainerImpl* WebFrameImpl::pluginContainerFromFrame(Frame* frame) 277 WebPluginContainerImpl* WebFrameImpl::pluginContainerFromFrame(Frame* frame)
278 { 278 {
279 if (!frame) 279 if (!frame)
280 return 0; 280 return 0;
281 if (!frame->document() || !frame->document()->isPluginDocument()) 281 if (!frame->document() || !frame->document()->isPluginDocument())
282 return 0; 282 return 0;
283 PluginDocument* pluginDocument = static_cast<PluginDocument*>(frame->documen t()); 283 PluginDocument* pluginDocument = static_cast<PluginDocument*>(frame->documen t());
284 return static_cast<WebPluginContainerImpl *>(pluginDocument->pluginWidget()) ; 284 return toPluginContainerImpl(pluginDocument->pluginWidget());
285 } 285 }
286 286
287 WebPluginContainerImpl* WebFrameImpl::pluginContainerFromNode(WebCore::Frame* fr ame, const WebNode& node) 287 WebPluginContainerImpl* WebFrameImpl::pluginContainerFromNode(WebCore::Frame* fr ame, const WebNode& node)
288 { 288 {
289 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame); 289 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame);
290 if (pluginContainer) 290 if (pluginContainer)
291 return pluginContainer; 291 return pluginContainer;
292 return static_cast<WebPluginContainerImpl*>(node.pluginContainer()); 292 return toPluginContainerImpl(node.pluginContainer());
293 } 293 }
294 294
295 // Simple class to override some of PrintContext behavior. Some of the methods 295 // Simple class to override some of PrintContext behavior. Some of the methods
296 // made virtual so that they can be overridden by ChromePluginPrintContext. 296 // made virtual so that they can be overridden by ChromePluginPrintContext.
297 class ChromePrintContext : public PrintContext { 297 class ChromePrintContext : public PrintContext {
298 WTF_MAKE_NONCOPYABLE(ChromePrintContext); 298 WTF_MAKE_NONCOPYABLE(ChromePrintContext);
299 public: 299 public:
300 ChromePrintContext(Frame* frame) 300 ChromePrintContext(Frame* frame)
301 : PrintContext(frame) 301 : PrintContext(frame)
302 , m_printedPageWidth(0) 302 , m_printedPageWidth(0)
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 int WebFrameImpl::printBegin(const WebPrintParams& printParams, const WebNode& c onstrainToNode, bool* useBrowserOverlays) 1389 int WebFrameImpl::printBegin(const WebPrintParams& printParams, const WebNode& c onstrainToNode, bool* useBrowserOverlays)
1390 { 1390 {
1391 ASSERT(!frame()->document()->isFrameSet()); 1391 ASSERT(!frame()->document()->isFrameSet());
1392 WebPluginContainerImpl* pluginContainer = 0; 1392 WebPluginContainerImpl* pluginContainer = 0;
1393 if (constrainToNode.isNull()) { 1393 if (constrainToNode.isNull()) {
1394 // If this is a plugin document, check if the plugin supports its own 1394 // If this is a plugin document, check if the plugin supports its own
1395 // printing. If it does, we will delegate all printing to that. 1395 // printing. If it does, we will delegate all printing to that.
1396 pluginContainer = pluginContainerFromFrame(frame()); 1396 pluginContainer = pluginContainerFromFrame(frame());
1397 } else { 1397 } else {
1398 // We only support printing plugin nodes for now. 1398 // We only support printing plugin nodes for now.
1399 pluginContainer = static_cast<WebPluginContainerImpl*>(constrainToNode.p luginContainer()); 1399 pluginContainer = toPluginContainerImpl(constrainToNode.pluginContainer( ));
1400 } 1400 }
1401 1401
1402 if (pluginContainer && pluginContainer->supportsPaginatedPrint()) 1402 if (pluginContainer && pluginContainer->supportsPaginatedPrint())
1403 m_printContext = adoptPtr(new ChromePluginPrintContext(frame(), pluginCo ntainer, printParams)); 1403 m_printContext = adoptPtr(new ChromePluginPrintContext(frame(), pluginCo ntainer, printParams));
1404 else 1404 else
1405 m_printContext = adoptPtr(new ChromePrintContext(frame())); 1405 m_printContext = adoptPtr(new ChromePrintContext(frame()));
1406 1406
1407 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width), static_cast<float>(printParams.printContentArea.height)); 1407 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width), static_cast<float>(printParams.printContentArea.height));
1408 m_printContext->begin(rect.width(), rect.height()); 1408 m_printContext->begin(rect.width(), rect.height());
1409 float pageHeight; 1409 float pageHeight;
(...skipping 27 matching lines...) Expand all
1437 1437
1438 void WebFrameImpl::printEnd() 1438 void WebFrameImpl::printEnd()
1439 { 1439 {
1440 ASSERT(m_printContext); 1440 ASSERT(m_printContext);
1441 m_printContext->end(); 1441 m_printContext->end();
1442 m_printContext.clear(); 1442 m_printContext.clear();
1443 } 1443 }
1444 1444
1445 bool WebFrameImpl::isPrintScalingDisabledForPlugin(const WebNode& node) 1445 bool WebFrameImpl::isPrintScalingDisabledForPlugin(const WebNode& node)
1446 { 1446 {
1447 WebPluginContainerImpl* pluginContainer = node.isNull() ? pluginContainerFr omFrame(frame()) : static_cast<WebPluginContainerImpl*>(node.pluginContainer()); 1447 WebPluginContainerImpl* pluginContainer = node.isNull() ? pluginContainerFr omFrame(frame()) : toPluginContainerImpl(node.pluginContainer());
1448 1448
1449 if (!pluginContainer || !pluginContainer->supportsPaginatedPrint()) 1449 if (!pluginContainer || !pluginContainer->supportsPaginatedPrint())
1450 return false; 1450 return false;
1451 1451
1452 return pluginContainer->isPrintScalingDisabled(); 1452 return pluginContainer->isPrintScalingDisabled();
1453 } 1453 }
1454 1454
1455 bool WebFrameImpl::hasCustomPageSizeStyle(int pageIndex) 1455 bool WebFrameImpl::hasCustomPageSizeStyle(int pageIndex)
1456 { 1456 {
1457 return frame()->document()->styleForPage(pageIndex)->pageSizeType() != PAGE_ SIZE_AUTO; 1457 return frame()->document()->styleForPage(pageIndex)->pageSizeType() != PAGE_ SIZE_AUTO;
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 2483
2484 // There is a possibility that the frame being detached was the only 2484 // There is a possibility that the frame being detached was the only
2485 // pending one. We need to make sure final replies can be sent. 2485 // pending one. We need to make sure final replies can be sent.
2486 flushCurrentScopingEffort(m_findRequestIdentifier); 2486 flushCurrentScopingEffort(m_findRequestIdentifier);
2487 2487
2488 cancelPendingScopingEffort(); 2488 cancelPendingScopingEffort();
2489 } 2489 }
2490 } 2490 }
2491 2491
2492 } // namespace WebKit 2492 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/web/ContextMenuClientImpl.cpp ('k') | Source/web/WebHelperPluginImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698