| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
| 3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
| 4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
| 5 * 2000 Simon Hausmann <hausmann@kde.org> | 5 * 2000 Simon Hausmann <hausmann@kde.org> |
| 6 * 2000 Stefan Schimanski <1Stein@gmx.de> | 6 * 2000 Stefan Schimanski <1Stein@gmx.de> |
| 7 * 2001 George Staikos <staikos@kde.org> | 7 * 2001 George Staikos <staikos@kde.org> |
| 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> | 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> |
| 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 void Frame::setPrinting(bool printing, const FloatSize& pageSize, const FloatSiz
e& originalPageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustV
iewSize) | 515 void Frame::setPrinting(bool printing, const FloatSize& pageSize, const FloatSiz
e& originalPageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustV
iewSize) |
| 516 { | 516 { |
| 517 // In setting printing, we should not validate resources already cached for
the document. | 517 // In setting printing, we should not validate resources already cached for
the document. |
| 518 // See https://bugs.webkit.org/show_bug.cgi?id=43704 | 518 // See https://bugs.webkit.org/show_bug.cgi?id=43704 |
| 519 ResourceCacheValidationSuppressor validationSuppressor(m_doc->cachedResource
Loader()); | 519 ResourceCacheValidationSuppressor validationSuppressor(m_doc->cachedResource
Loader()); |
| 520 | 520 |
| 521 m_doc->setPrinting(printing); | 521 m_doc->setPrinting(printing); |
| 522 view()->adjustMediaTypeForPrinting(printing); | 522 view()->adjustMediaTypeForPrinting(printing); |
| 523 | 523 |
| 524 m_doc->styleResolverChanged(RecalcStyleImmediately); | 524 m_doc->styleResolverChanged(RecalcStyleImmediately); |
| 525 if (printing && !tree()->parent()) { | 525 if (shouldUsePrintingLayout()) { |
| 526 // Only root frame should be fit to page size. Subframes should be const
rained by parents only. | |
| 527 view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShri
nkRatio, shouldAdjustViewSize); | 526 view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShri
nkRatio, shouldAdjustViewSize); |
| 528 } else { | 527 } else { |
| 529 view()->forceLayout(); | 528 view()->forceLayout(); |
| 530 if (shouldAdjustViewSize == AdjustViewSize) | 529 if (shouldAdjustViewSize == AdjustViewSize) |
| 531 view()->adjustViewSize(); | 530 view()->adjustViewSize(); |
| 532 } | 531 } |
| 533 | 532 |
| 534 // Subframes of the one we're printing don't lay out to the page size. | 533 // Subframes of the one we're printing don't lay out to the page size. |
| 535 for (Frame* child = tree()->firstChild(); child; child = child->tree()->next
Sibling()) | 534 for (Frame* child = tree()->firstChild(); child; child = child->tree()->next
Sibling()) |
| 536 child->setPrinting(printing, FloatSize(), FloatSize(), 0, shouldAdjustVi
ewSize); | 535 child->setPrinting(printing, FloatSize(), FloatSize(), 0, shouldAdjustVi
ewSize); |
| 537 } | 536 } |
| 538 | 537 |
| 538 bool Frame::shouldUsePrintingLayout() const |
| 539 { |
| 540 // Only top frame being printed should be fit to page size. |
| 541 // Subframes should be constrained by parents only. |
| 542 return m_doc->printing() && (!tree()->parent() || !tree()->parent()->m_doc->
printing()); |
| 543 } |
| 544 |
| 539 FloatSize Frame::resizePageRectsKeepingRatio(const FloatSize& originalSize, cons
t FloatSize& expectedSize) | 545 FloatSize Frame::resizePageRectsKeepingRatio(const FloatSize& originalSize, cons
t FloatSize& expectedSize) |
| 540 { | 546 { |
| 541 FloatSize resultSize; | 547 FloatSize resultSize; |
| 542 if (!contentRenderer()) | 548 if (!contentRenderer()) |
| 543 return FloatSize(); | 549 return FloatSize(); |
| 544 | 550 |
| 545 if (contentRenderer()->style()->isHorizontalWritingMode()) { | 551 if (contentRenderer()->style()->isHorizontalWritingMode()) { |
| 546 ASSERT(fabs(originalSize.width()) > numeric_limits<float>::epsilon()); | 552 ASSERT(fabs(originalSize.width()) > numeric_limits<float>::epsilon()); |
| 547 float ratio = originalSize.height() / originalSize.width(); | 553 float ratio = originalSize.height() / originalSize.width(); |
| 548 resultSize.setWidth(floorf(expectedSize.width())); | 554 resultSize.setWidth(floorf(expectedSize.width())); |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 | 1122 |
| 1117 m_view->paintContents(buffer->context(), paintingRect); | 1123 m_view->paintContents(buffer->context(), paintingRect); |
| 1118 | 1124 |
| 1119 RefPtr<Image> image = buffer->copyImage(); | 1125 RefPtr<Image> image = buffer->copyImage(); |
| 1120 return createDragImageFromImage(image.get()); | 1126 return createDragImageFromImage(image.get()); |
| 1121 } | 1127 } |
| 1122 | 1128 |
| 1123 #endif | 1129 #endif |
| 1124 | 1130 |
| 1125 } // namespace WebCore | 1131 } // namespace WebCore |
| OLD | NEW |