void RenderLineBoxList::paint(RenderBoxModelObject* renderer, PaintInfo& paintInfo, const LayoutPoint& paintOffset) const { // Only paint during the foreground/selection phases. if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseOutline && paintInfo.phase != PaintPhaseSelfOutline && paintInfo.phase != PaintPhaseChildOutlines && paintInfo.phase != PaintPhaseTextClip && paintInfo.phase != PaintPhaseMask) return; ASSERT(renderer->isRenderBlock() || (renderer->isRenderInline() && renderer->hasLayer())); // The only way an inline could paint like this is if it has a layer. // If we have no lines then we have no work to do. if (!firstLineBox()) return; if (!anyLineIntersectsRect(renderer, paintInfo.rect, paintOffset)) return; PaintInfo info(paintInfo); ListHashSet<RenderInline*> outlineObjects; info.setOutlineObjects(&outlineObjects); // See if our root lines intersect with the dirty rect. If so, then we paint // them. Note that boxes can easily overlap, so we can't make any assumptions // based off positions of our first line box or our last line box. for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { if (lineIntersectsDirtyRect(renderer, curr, info, paintOffset)) { RootInlineBox& root = curr->root(); curr->paint(info, paintOffset, root.lineTop(), root.lineBottom()); } } if (info.phase == PaintPhaseOutline || info.phase == PaintPhaseSelfOutline || info.phase == PaintPhaseChildOutlines) { ListHashSet<RenderInline*>::iterator end = info.outlineObjects()->end(); for (ListHashSet<RenderInline*>::iterator it = info.outlineObjects()->begin(); it != end; ++it) { RenderInline* flow = *it; flow->paintOutline(info, paintOffset); } info.outlineObjects()->clear(); } }
void RenderLineBoxList::paint(RenderBoxModelObject* renderer, PaintInfo& paintInfo, const LayoutPoint& paintOffset) const { ASSERT(renderer->isRenderBlock() || (renderer->isRenderInline() && renderer->hasLayer())); // The only way an inline could paint like this is if it has a layer. // If we have no lines then we have no work to do. if (!firstLineBox()) return; // FIXME: Paint-time pagination is obsolete and is now only used by embedded WebViews inside AppKit // NSViews. Do not add any more code for this. RenderView& v = renderer->view(); bool usePrintRect = !v.printRect().isEmpty(); if (!anyLineIntersectsRect(renderer, paintInfo.rect, paintOffset, usePrintRect)) return; PaintInfo info(paintInfo); ListHashSet<RenderInline*> outlineObjects; info.outlineObjects = &outlineObjects; // See if our root lines intersect with the dirty rect. If so, then we paint // them. Note that boxes can easily overlap, so we can't make any assumptions // based off positions of our first line box or our last line box. for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { if (usePrintRect) { // FIXME: This is the deprecated pagination model that is still needed // for embedded views inside AppKit. AppKit is incapable of paginating vertical // text pages, so we don't have to deal with vertical lines at all here. const RootInlineBox& rootBox = curr->root(); LayoutUnit topForPaginationCheck = curr->logicalTopVisualOverflow(rootBox.lineTop()); LayoutUnit bottomForPaginationCheck = curr->logicalLeftVisualOverflow(); if (!curr->parent()) { // We're a root box. Use lineTop and lineBottom as well here. topForPaginationCheck = std::min(topForPaginationCheck, rootBox.lineTop()); bottomForPaginationCheck = std::max(bottomForPaginationCheck, rootBox.lineBottom()); } if (bottomForPaginationCheck - topForPaginationCheck <= v.printRect().height()) { if (paintOffset.y() + bottomForPaginationCheck > v.printRect().maxY()) { if (RootInlineBox* nextRootBox = rootBox.nextRootBox()) bottomForPaginationCheck = std::min(bottomForPaginationCheck, std::min<LayoutUnit>(nextRootBox->logicalTopVisualOverflow(), nextRootBox->lineTop())); } if (paintOffset.y() + bottomForPaginationCheck > v.printRect().maxY()) { if (paintOffset.y() + topForPaginationCheck < v.truncatedAt()) v.setBestTruncatedAt(paintOffset.y() + topForPaginationCheck, renderer); // If we were able to truncate, don't paint. if (paintOffset.y() + topForPaginationCheck >= v.truncatedAt()) break; } } } if (lineIntersectsDirtyRect(renderer, curr, info, paintOffset)) { const RootInlineBox& rootBox = curr->root(); curr->paint(info, paintOffset, rootBox.lineTop(), rootBox.lineBottom()); } } if (info.phase == PaintPhaseOutline || info.phase == PaintPhaseSelfOutline || info.phase == PaintPhaseChildOutlines) { ListHashSet<RenderInline*>::iterator end = info.outlineObjects->end(); for (ListHashSet<RenderInline*>::iterator it = info.outlineObjects->begin(); it != end; ++it) { RenderInline* flow = *it; flow->paintOutline(info, paintOffset); } info.outlineObjects->clear(); } }
void RenderLineBoxList::paint(RenderBoxModelObject* renderer, RenderObject::PaintInfo& paintInfo, int tx, int ty) const { // Only paint during the foreground/selection phases.(只有画前景和选择才会跑到这里) if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseOutline && paintInfo.phase != PaintPhaseSelfOutline && paintInfo.phase != PaintPhaseChildOutlines && paintInfo.phase != PaintPhaseTextClip && paintInfo.phase != PaintPhaseMask) return; ASSERT(renderer->isRenderBlock() || (renderer->isRenderInline() && renderer->hasLayer())); // The only way an inline could paint like this is if it has a layer. // If we have no lines then we have no work to do. if (!firstLineBox()) return; // We can check the first box and last box and avoid painting if we don't // intersect. This is a quick short-circuit that we can take to avoid walking any lines. // FIXME: This check is flawed in the following extremely obscure way: // if some line in the middle has a huge overflow, it might actually extend below the last line. int yPos = firstLineBox()->topVisibleOverflow() - renderer->maximalOutlineSize(paintInfo.phase); int h = renderer->maximalOutlineSize(paintInfo.phase) + lastLineBox()->bottomVisibleOverflow() - yPos; // 要画的inline块(从第一行到最后一行的)整个高度 yPos += ty; // 起始高度 if (yPos >= paintInfo.rect.bottom() || yPos + h <= paintInfo.rect.y()) return; RenderObject::PaintInfo info(paintInfo); ListHashSet<RenderInline*> outlineObjects; info.outlineObjects = &outlineObjects; // See if our root lines intersect with the dirty rect. If so, then we paint // them. Note that boxes can easily overlap, so we can't make any assumptions // based off positions of our first line box or our last line box. RenderView* v = renderer->view(); bool usePrintRect = !v->printRect().isEmpty(); for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { // 开始对每行进行绘制 if (usePrintRect) { // FIXME: This is a feeble effort to avoid splitting a line across two pages. // It is utterly inadequate, and this should not be done at paint time at all. // The whole way objects break across pages needs to be redone. // Try to avoid splitting a line vertically, but only if it's less than the height // of the entire page. if (curr->bottomVisibleOverflow() - curr->topVisibleOverflow() <= v->printRect().height()) { if (ty + curr->bottomVisibleOverflow() > v->printRect().bottom()) { if (ty + curr->topVisibleOverflow() < v->truncatedAt()) v->setBestTruncatedAt(ty + curr->root()->topVisibleOverflow(), renderer); // If we were able to truncate, don't paint. if (ty + curr->topVisibleOverflow() >= v->truncatedAt()) break; } } } int top = min(curr->topVisibleOverflow(), curr->root()->selectionTop()) - renderer->maximalOutlineSize(info.phase); // 高点 int bottom = curr->bottomVisibleOverflow() + renderer->maximalOutlineSize(info.phase); // 底点 h = bottom - top; // 高度 yPos = ty + top; // 开始绘制点 v->setMinimumColumnHeight(h); if (yPos < info.rect.bottom() && yPos + h > info.rect.y()) curr->paint(info, tx, ty); // 开始绘制该行 } if (info.phase == PaintPhaseOutline || info.phase == PaintPhaseSelfOutline || info.phase == PaintPhaseChildOutlines) { ListHashSet<RenderInline*>::iterator end = info.outlineObjects->end(); for (ListHashSet<RenderInline*>::iterator it = info.outlineObjects->begin(); it != end; ++it) { RenderInline* flow = *it; flow->paintOutline(info.context, tx, ty); } info.outlineObjects->clear(); } }