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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 2417683002: Disable scroll anchoring when in printing mode (Closed)
Patch Set: Add comment Created 4 years, 2 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
OLDNEW
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 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
9 * rights reserved. 9 * rights reserved.
10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 } 544 }
545 545
546 void LocalFrame::setPrinting(bool printing, 546 void LocalFrame::setPrinting(bool printing,
547 const FloatSize& pageSize, 547 const FloatSize& pageSize,
548 const FloatSize& originalPageSize, 548 const FloatSize& originalPageSize,
549 float maximumShrinkRatio) { 549 float maximumShrinkRatio) {
550 // In setting printing, we should not validate resources already cached for 550 // In setting printing, we should not validate resources already cached for
551 // the document. See https://bugs.webkit.org/show_bug.cgi?id=43704 551 // the document. See https://bugs.webkit.org/show_bug.cgi?id=43704
552 ResourceCacheValidationSuppressor validationSuppressor(document()->fetcher()); 552 ResourceCacheValidationSuppressor validationSuppressor(document()->fetcher());
553 553
554 document()->setPrinting(printing); 554 document()->setPrinting(printing ? Document::Printing
555 : Document::FinishingPrinting);
555 view()->adjustMediaTypeForPrinting(printing); 556 view()->adjustMediaTypeForPrinting(printing);
556 557
557 if (shouldUsePrintingLayout()) { 558 if (shouldUsePrintingLayout()) {
558 view()->forceLayoutForPagination(pageSize, originalPageSize, 559 view()->forceLayoutForPagination(pageSize, originalPageSize,
559 maximumShrinkRatio); 560 maximumShrinkRatio);
560 } else { 561 } else {
561 if (LayoutView* layoutView = view()->layoutView()) { 562 if (LayoutView* layoutView = view()->layoutView()) {
562 layoutView->setPreferredLogicalWidthsDirty(); 563 layoutView->setPreferredLogicalWidthsDirty();
563 layoutView->setNeedsLayout(LayoutInvalidationReason::PrintingChanged); 564 layoutView->setNeedsLayout(LayoutInvalidationReason::PrintingChanged);
564 layoutView->setShouldDoFullPaintInvalidationForViewAndAllDescendants(); 565 layoutView->setShouldDoFullPaintInvalidationForViewAndAllDescendants();
565 } 566 }
566 view()->layout(); 567 view()->layout();
567 view()->adjustViewSize(); 568 view()->adjustViewSize();
568 } 569 }
569 570
570 // Subframes of the one we're printing don't lay out to the page size. 571 // Subframes of the one we're printing don't lay out to the page size.
571 for (Frame* child = tree().firstChild(); child; 572 for (Frame* child = tree().firstChild(); child;
572 child = child->tree().nextSibling()) { 573 child = child->tree().nextSibling()) {
573 if (child->isLocalFrame()) 574 if (child->isLocalFrame())
574 toLocalFrame(child)->setPrinting(printing, FloatSize(), FloatSize(), 0); 575 toLocalFrame(child)->setPrinting(printing, FloatSize(), FloatSize(), 0);
575 } 576 }
577
578 if (!printing)
579 document()->setPrinting(Document::NotPrinting);
576 } 580 }
577 581
578 bool LocalFrame::shouldUsePrintingLayout() const { 582 bool LocalFrame::shouldUsePrintingLayout() const {
579 // Only top frame being printed should be fit to page size. 583 // Only top frame being printed should be fit to page size.
580 // Subframes should be constrained by parents only. 584 // Subframes should be constrained by parents only.
581 return document()->printing() && 585 return document()->printing() &&
582 (!tree().parent() || !tree().parent()->isLocalFrame() || 586 (!tree().parent() || !tree().parent()->isLocalFrame() ||
583 !toLocalFrame(tree().parent())->document()->printing()); 587 !toLocalFrame(tree().parent())->document()->printing());
584 } 588 }
585 589
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) 902 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext())
899 m_frame->client()->frameBlameContext()->Enter(); 903 m_frame->client()->frameBlameContext()->Enter();
900 } 904 }
901 905
902 ScopedFrameBlamer::~ScopedFrameBlamer() { 906 ScopedFrameBlamer::~ScopedFrameBlamer() {
903 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) 907 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext())
904 m_frame->client()->frameBlameContext()->Leave(); 908 m_frame->client()->frameBlameContext()->Leave();
905 } 909 }
906 910
907 } // namespace blink 911 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698