Commit bf5f64e9 authored by pilgrim's avatar pilgrim Committed by Commit bot

[Layout API] Convert PrintContext to use Document::layoutViewItem()

There were several references to Document::layoutView()
which is deprecated by the new layout API. I converted them to use
layoutViewItem() instead. No new API methods were required.

There are no functional changes.

BUG=499321

Review URL: https://codereview.chromium.org/1892153002

Cr-Commit-Position: refs/heads/master@{#388639}
parent 3287e205
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "core/frame/FrameView.h" #include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/layout/LayoutView.h" #include "core/layout/LayoutView.h"
#include "core/layout/api/LayoutViewItem.h"
#include "platform/graphics/GraphicsContext.h" #include "platform/graphics/GraphicsContext.h"
namespace blink { namespace blink {
...@@ -58,7 +59,7 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig ...@@ -58,7 +59,7 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig
m_pageRects.clear(); m_pageRects.clear();
outPageHeight = 0; outPageHeight = 0;
if (!m_frame->document() || !m_frame->view() || !m_frame->document()->layoutView()) if (!m_frame->document() || !m_frame->view() || m_frame->document()->layoutViewItem().isNull())
return; return;
if (userScaleFactor <= 0) { if (userScaleFactor <= 0) {
...@@ -66,8 +67,8 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig ...@@ -66,8 +67,8 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig
return; return;
} }
LayoutView* view = m_frame->document()->layoutView(); LayoutViewItem view = m_frame->document()->layoutViewItem();
const IntRect& documentRect = view->documentRect(); const IntRect& documentRect = view.documentRect();
FloatSize pageSize = m_frame->resizePageRectsKeepingRatio(FloatSize(printRect.width(), printRect.height()), FloatSize(documentRect.width(), documentRect.height())); FloatSize pageSize = m_frame->resizePageRectsKeepingRatio(FloatSize(printRect.width(), printRect.height()), FloatSize(documentRect.width(), documentRect.height()));
float pageWidth = pageSize.width(); float pageWidth = pageSize.width();
float pageHeight = pageSize.height(); float pageHeight = pageSize.height();
...@@ -91,12 +92,12 @@ void PrintContext::computePageRectsWithPageSize(const FloatSize& pageSizeInPixel ...@@ -91,12 +92,12 @@ void PrintContext::computePageRectsWithPageSize(const FloatSize& pageSizeInPixel
void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels) void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels)
{ {
if (!m_frame->document() || !m_frame->view() || !m_frame->document()->layoutView()) if (!m_frame->document() || !m_frame->view() || m_frame->document()->layoutViewItem().isNull())
return; return;
LayoutView* view = m_frame->document()->layoutView(); LayoutViewItem view = m_frame->document()->layoutViewItem();
IntRect docRect = view->documentRect(); IntRect docRect = view.documentRect();
int pageWidth = pageSizeInPixels.width(); int pageWidth = pageSizeInPixels.width();
// We scaled with floating point arithmetic and need to ensure results like 13329.99 // We scaled with floating point arithmetic and need to ensure results like 13329.99
...@@ -104,7 +105,7 @@ void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz ...@@ -104,7 +105,7 @@ void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz
// stray pixel. // stray pixel.
int pageHeight = pageSizeInPixels.height() + LayoutUnit::epsilon(); int pageHeight = pageSizeInPixels.height() + LayoutUnit::epsilon();
bool isHorizontal = view->style()->isHorizontalWritingMode(); bool isHorizontal = view.style()->isHorizontalWritingMode();
int docLogicalHeight = isHorizontal ? docRect.height() : docRect.width(); int docLogicalHeight = isHorizontal ? docRect.height() : docRect.width();
int pageLogicalHeight = isHorizontal ? pageHeight : pageWidth; int pageLogicalHeight = isHorizontal ? pageHeight : pageWidth;
...@@ -115,25 +116,25 @@ void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz ...@@ -115,25 +116,25 @@ void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz
int blockDirectionStart; int blockDirectionStart;
int blockDirectionEnd; int blockDirectionEnd;
if (isHorizontal) { if (isHorizontal) {
if (view->style()->isFlippedBlocksWritingMode()) { if (view.style()->isFlippedBlocksWritingMode()) {
blockDirectionStart = docRect.maxY(); blockDirectionStart = docRect.maxY();
blockDirectionEnd = docRect.y(); blockDirectionEnd = docRect.y();
} else { } else {
blockDirectionStart = docRect.y(); blockDirectionStart = docRect.y();
blockDirectionEnd = docRect.maxY(); blockDirectionEnd = docRect.maxY();
} }
inlineDirectionStart = view->style()->isLeftToRightDirection() ? docRect.x() : docRect.maxX(); inlineDirectionStart = view.style()->isLeftToRightDirection() ? docRect.x() : docRect.maxX();
inlineDirectionEnd = view->style()->isLeftToRightDirection() ? docRect.maxX() : docRect.x(); inlineDirectionEnd = view.style()->isLeftToRightDirection() ? docRect.maxX() : docRect.x();
} else { } else {
if (view->style()->isFlippedBlocksWritingMode()) { if (view.style()->isFlippedBlocksWritingMode()) {
blockDirectionStart = docRect.maxX(); blockDirectionStart = docRect.maxX();
blockDirectionEnd = docRect.x(); blockDirectionEnd = docRect.x();
} else { } else {
blockDirectionStart = docRect.x(); blockDirectionStart = docRect.x();
blockDirectionEnd = docRect.maxX(); blockDirectionEnd = docRect.maxX();
} }
inlineDirectionStart = view->style()->isLeftToRightDirection() ? docRect.y() : docRect.maxY(); inlineDirectionStart = view.style()->isLeftToRightDirection() ? docRect.y() : docRect.maxY();
inlineDirectionEnd = view->style()->isLeftToRightDirection() ? docRect.maxY() : docRect.y(); inlineDirectionEnd = view.style()->isLeftToRightDirection() ? docRect.maxY() : docRect.y();
} }
unsigned pageCount = ceilf((float)docLogicalHeight / pageLogicalHeight); unsigned pageCount = ceilf((float)docLogicalHeight / pageLogicalHeight);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment