本文整理汇总了C++中LayoutView::documentRect方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutView::documentRect方法的具体用法?C++ LayoutView::documentRect怎么用?C++ LayoutView::documentRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutView
的用法示例。
在下文中一共展示了LayoutView::documentRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computePageRects
void PrintContext::computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight)
{
m_pageRects.clear();
outPageHeight = 0;
if (!m_frame->document() || !m_frame->view() || !m_frame->document()->layoutView())
return;
if (userScaleFactor <= 0) {
WTF_LOG_ERROR("userScaleFactor has bad value %.2f", userScaleFactor);
return;
}
LayoutView* view = m_frame->document()->layoutView();
const IntRect& documentRect = view->documentRect();
FloatSize pageSize = m_frame->resizePageRectsKeepingRatio(FloatSize(printRect.width(), printRect.height()), FloatSize(documentRect.width(), documentRect.height()));
float pageWidth = pageSize.width();
float pageHeight = pageSize.height();
outPageHeight = pageHeight; // this is the height of the page adjusted by margins
pageHeight -= headerHeight + footerHeight;
if (pageHeight <= 0) {
WTF_LOG_ERROR("pageHeight has bad value %.2f", pageHeight);
return;
}
computePageRectsWithPageSizeInternal(FloatSize(pageWidth / userScaleFactor, pageHeight / userScaleFactor));
}
示例2: computePageRectsWithPageSizeInternal
void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels)
{
if (!m_frame->document() || !m_frame->view() || !m_frame->document()->layoutView())
return;
LayoutView* view = m_frame->document()->layoutView();
IntRect docRect = view->documentRect();
int pageWidth = pageSizeInPixels.width();
int pageHeight = pageSizeInPixels.height();
bool isHorizontal = view->style()->isHorizontalWritingMode();
int docLogicalHeight = isHorizontal ? docRect.height() : docRect.width();
int pageLogicalHeight = isHorizontal ? pageHeight : pageWidth;
int pageLogicalWidth = isHorizontal ? pageWidth : pageHeight;
int inlineDirectionStart;
int inlineDirectionEnd;
int blockDirectionStart;
int blockDirectionEnd;
if (isHorizontal) {
if (view->style()->isFlippedBlocksWritingMode()) {
blockDirectionStart = docRect.maxY();
blockDirectionEnd = docRect.y();
} else {
blockDirectionStart = docRect.y();
blockDirectionEnd = docRect.maxY();
}
inlineDirectionStart = view->style()->isLeftToRightDirection() ? docRect.x() : docRect.maxX();
inlineDirectionEnd = view->style()->isLeftToRightDirection() ? docRect.maxX() : docRect.x();
} else {
if (view->style()->isFlippedBlocksWritingMode()) {
blockDirectionStart = docRect.maxX();
blockDirectionEnd = docRect.x();
} else {
blockDirectionStart = docRect.x();
blockDirectionEnd = docRect.maxX();
}
inlineDirectionStart = view->style()->isLeftToRightDirection() ? docRect.y() : docRect.maxY();
inlineDirectionEnd = view->style()->isLeftToRightDirection() ? docRect.maxY() : docRect.y();
}
unsigned pageCount = ceilf((float)docLogicalHeight / pageLogicalHeight);
for (unsigned i = 0; i < pageCount; ++i) {
int pageLogicalTop = blockDirectionEnd > blockDirectionStart ?
blockDirectionStart + i * pageLogicalHeight :
blockDirectionStart - (i + 1) * pageLogicalHeight;
int pageLogicalLeft = inlineDirectionEnd > inlineDirectionStart ? inlineDirectionStart : inlineDirectionStart - pageLogicalWidth;
IntRect pageRect(pageLogicalLeft, pageLogicalTop, pageLogicalWidth, pageLogicalHeight);
if (!isHorizontal)
pageRect = pageRect.transposedRect();
m_pageRects.append(pageRect);
}
}