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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2116283002: Don't let rounding prematurely influence document size when printing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@620456-2
Patch Set: bug 467579 Created 4 years, 4 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 { 1992 {
1993 updateDistribution(); 1993 updateDistribution();
1994 return ensureStyleResolver().styleForPage(pageIndex); 1994 return ensureStyleResolver().styleForPage(pageIndex);
1995 } 1995 }
1996 1996
1997 bool Document::isPageBoxVisible(int pageIndex) 1997 bool Document::isPageBoxVisible(int pageIndex)
1998 { 1998 {
1999 return styleForPage(pageIndex)->visibility() != HIDDEN; // display property doesn't apply to @page. 1999 return styleForPage(pageIndex)->visibility() != HIDDEN; // display property doesn't apply to @page.
2000 } 2000 }
2001 2001
2002 void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft) 2002 void Document::pageSizeAndMarginsInPixels(int pageIndex, DoubleSize& pageSize, i nt& marginTop, int& marginRight, int& marginBottom, int& marginLeft)
2003 { 2003 {
2004 RefPtr<ComputedStyle> style = styleForPage(pageIndex); 2004 RefPtr<ComputedStyle> style = styleForPage(pageIndex);
2005 2005
2006 int width = pageSize.width(); 2006 double width = pageSize.width();
2007 int height = pageSize.height(); 2007 double height = pageSize.height();
2008 switch (style->getPageSizeType()) { 2008 switch (style->getPageSizeType()) {
2009 case PAGE_SIZE_AUTO: 2009 case PAGE_SIZE_AUTO:
2010 break; 2010 break;
2011 case PAGE_SIZE_AUTO_LANDSCAPE: 2011 case PAGE_SIZE_AUTO_LANDSCAPE:
2012 if (width < height) 2012 if (width < height)
2013 std::swap(width, height); 2013 std::swap(width, height);
2014 break; 2014 break;
2015 case PAGE_SIZE_AUTO_PORTRAIT: 2015 case PAGE_SIZE_AUTO_PORTRAIT:
2016 if (width > height) 2016 if (width > height)
2017 std::swap(width, height); 2017 std::swap(width, height);
2018 break; 2018 break;
2019 case PAGE_SIZE_RESOLVED: { 2019 case PAGE_SIZE_RESOLVED: {
2020 FloatSize size = style->pageSize(); 2020 FloatSize size = style->pageSize();
2021 width = size.width(); 2021 width = size.width();
2022 height = size.height(); 2022 height = size.height();
2023 break; 2023 break;
2024 } 2024 }
2025 default: 2025 default:
2026 ASSERT_NOT_REACHED(); 2026 ASSERT_NOT_REACHED();
2027 } 2027 }
2028 pageSize = IntSize(width, height); 2028 pageSize = DoubleSize(width, height);
2029 2029
2030 // The percentage is calculated with respect to the width even for margin to p and bottom. 2030 // The percentage is calculated with respect to the width even for margin to p and bottom.
2031 // http://www.w3.org/TR/CSS2/box.html#margin-properties 2031 // http://www.w3.org/TR/CSS2/box.html#margin-properties
2032 marginTop = style->marginTop().isAuto() ? marginTop : intValueForLength(styl e->marginTop(), width); 2032 marginTop = style->marginTop().isAuto() ? marginTop : intValueForLength(styl e->marginTop(), width);
2033 marginRight = style->marginRight().isAuto() ? marginRight : intValueForLengt h(style->marginRight(), width); 2033 marginRight = style->marginRight().isAuto() ? marginRight : intValueForLengt h(style->marginRight(), width);
2034 marginBottom = style->marginBottom().isAuto() ? marginBottom : intValueForLe ngth(style->marginBottom(), width); 2034 marginBottom = style->marginBottom().isAuto() ? marginBottom : intValueForLe ngth(style->marginBottom(), width);
2035 marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(s tyle->marginLeft(), width); 2035 marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(s tyle->marginLeft(), width);
2036 } 2036 }
2037 2037
2038 void Document::setIsViewSource(bool isViewSource) 2038 void Document::setIsViewSource(bool isViewSource)
(...skipping 3995 matching lines...) Expand 10 before | Expand all | Expand 10 after
6034 } 6034 }
6035 6035
6036 void showLiveDocumentInstances() 6036 void showLiveDocumentInstances()
6037 { 6037 {
6038 WeakDocumentSet& set = liveDocumentSet(); 6038 WeakDocumentSet& set = liveDocumentSet();
6039 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6039 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6040 for (Document* document : set) 6040 for (Document* document : set)
6041 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6041 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6042 } 6042 }
6043 #endif 6043 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/page/PrintContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698