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

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, 5 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 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 { 1984 {
1985 updateDistribution(); 1985 updateDistribution();
1986 return ensureStyleResolver().styleForPage(pageIndex); 1986 return ensureStyleResolver().styleForPage(pageIndex);
1987 } 1987 }
1988 1988
1989 bool Document::isPageBoxVisible(int pageIndex) 1989 bool Document::isPageBoxVisible(int pageIndex)
1990 { 1990 {
1991 return styleForPage(pageIndex)->visibility() != HIDDEN; // display property doesn't apply to @page. 1991 return styleForPage(pageIndex)->visibility() != HIDDEN; // display property doesn't apply to @page.
1992 } 1992 }
1993 1993
1994 void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft) 1994 void Document::pageSizeAndMarginsInPixels(int pageIndex, FloatSize& pageSize, in t& marginTop, int& marginRight, int& marginBottom, int& marginLeft)
1995 { 1995 {
1996 RefPtr<ComputedStyle> style = styleForPage(pageIndex); 1996 RefPtr<ComputedStyle> style = styleForPage(pageIndex);
1997 1997
1998 int width = pageSize.width(); 1998 float width = pageSize.width();
eae 2016/07/12 22:26:39 This does not look right. Pages are always in full
rhogan 2016/07/13 18:27:13 The main user of this API is print_web_view_helper
eae 2016/07/13 20:42:26 In that case we need to use either LayoutUnits or
1999 int height = pageSize.height(); 1999 float height = pageSize.height();
2000 switch (style->getPageSizeType()) { 2000 switch (style->getPageSizeType()) {
2001 case PAGE_SIZE_AUTO: 2001 case PAGE_SIZE_AUTO:
2002 break; 2002 break;
2003 case PAGE_SIZE_AUTO_LANDSCAPE: 2003 case PAGE_SIZE_AUTO_LANDSCAPE:
2004 if (width < height) 2004 if (width < height)
2005 std::swap(width, height); 2005 std::swap(width, height);
2006 break; 2006 break;
2007 case PAGE_SIZE_AUTO_PORTRAIT: 2007 case PAGE_SIZE_AUTO_PORTRAIT:
2008 if (width > height) 2008 if (width > height)
2009 std::swap(width, height); 2009 std::swap(width, height);
2010 break; 2010 break;
2011 case PAGE_SIZE_RESOLVED: { 2011 case PAGE_SIZE_RESOLVED: {
2012 FloatSize size = style->pageSize(); 2012 FloatSize size = style->pageSize();
2013 width = size.width(); 2013 width = size.width();
2014 height = size.height(); 2014 height = size.height();
2015 break; 2015 break;
2016 } 2016 }
2017 default: 2017 default:
2018 ASSERT_NOT_REACHED(); 2018 ASSERT_NOT_REACHED();
2019 } 2019 }
2020 pageSize = IntSize(width, height); 2020 pageSize = FloatSize(width, height);
2021 2021
2022 // The percentage is calculated with respect to the width even for margin to p and bottom. 2022 // The percentage is calculated with respect to the width even for margin to p and bottom.
2023 // http://www.w3.org/TR/CSS2/box.html#margin-properties 2023 // http://www.w3.org/TR/CSS2/box.html#margin-properties
2024 marginTop = style->marginTop().isAuto() ? marginTop : intValueForLength(styl e->marginTop(), width); 2024 marginTop = style->marginTop().isAuto() ? marginTop : intValueForLength(styl e->marginTop(), width);
2025 marginRight = style->marginRight().isAuto() ? marginRight : intValueForLengt h(style->marginRight(), width); 2025 marginRight = style->marginRight().isAuto() ? marginRight : intValueForLengt h(style->marginRight(), width);
2026 marginBottom = style->marginBottom().isAuto() ? marginBottom : intValueForLe ngth(style->marginBottom(), width); 2026 marginBottom = style->marginBottom().isAuto() ? marginBottom : intValueForLe ngth(style->marginBottom(), width);
2027 marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(s tyle->marginLeft(), width); 2027 marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(s tyle->marginLeft(), width);
2028 } 2028 }
2029 2029
2030 void Document::setIsViewSource(bool isViewSource) 2030 void Document::setIsViewSource(bool isViewSource)
(...skipping 3999 matching lines...) Expand 10 before | Expand all | Expand 10 after
6030 } 6030 }
6031 6031
6032 void showLiveDocumentInstances() 6032 void showLiveDocumentInstances()
6033 { 6033 {
6034 WeakDocumentSet& set = liveDocumentSet(); 6034 WeakDocumentSet& set = liveDocumentSet();
6035 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6035 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6036 for (Document* document : set) 6036 for (Document* document : set)
6037 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6037 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6038 } 6038 }
6039 #endif 6039 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698