📄 render_object.cpp
字号:
case BSBottom: drawBorder(p, x1+QMAX(( adjbw1*2+1)/3,0), y1 , x2-QMAX(( adjbw2*2+1)/3,0), y1+third, s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird); drawBorder(p, x1+QMAX((-adjbw1*2+1)/3,0), y2-third, x2-QMAX((-adjbw2*2+1)/3,0), y2 , s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird); break; case BSRight: drawBorder(p, x1 , y1+QMAX(( adjbw1*2+1)/3,0), x1+third, y2-QMAX(( adjbw2*2+1)/3,0), s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird); drawBorder(p, x2-third, y1+QMAX((-adjbw1*2+1)/3,0), x2 , y2-QMAX((-adjbw2*2+1)/3,0), s, c, textcolor, SOLID, adjbw1bigthird, adjbw2bigthird); break; default: break; } } break; } case RIDGE: case GROOVE: { EBorderStyle s1; EBorderStyle s2; if (style==GROOVE) { s1 = INSET; s2 = OUTSET; } else { s1 = OUTSET; s2 = INSET; } int adjbw1bighalf; int adjbw2bighalf; if (adjbw1>0) adjbw1bighalf=adjbw1+1; else adjbw1bighalf=adjbw1-1; adjbw1bighalf/=2; if (adjbw2>0) adjbw2bighalf=adjbw2+1; else adjbw2bighalf=adjbw2-1; adjbw2bighalf/=2; switch (s) { case BSTop: drawBorder(p, x1+QMAX(-adjbw1 ,0)/2, y1 , x2-QMAX(-adjbw2,0)/2, (y1+y2+1)/2, s, c, textcolor, s1, adjbw1bighalf, adjbw2bighalf); drawBorder(p, x1+QMAX( adjbw1+1,0)/2, (y1+y2+1)/2, x2-QMAX( adjbw2+1,0)/2, y2 , s, c, textcolor, s2, adjbw1/2, adjbw2/2); break; case BSLeft: drawBorder(p, x1 , y1+QMAX(-adjbw1 ,0)/2, (x1+x2+1)/2, y2-QMAX(-adjbw2,0)/2, s, c, textcolor, s1, adjbw1bighalf, adjbw2bighalf); drawBorder(p, (x1+x2+1)/2, y1+QMAX( adjbw1+1,0)/2, x2 , y2-QMAX( adjbw2+1,0)/2, s, c, textcolor, s2, adjbw1/2, adjbw2/2); break; case BSBottom: drawBorder(p, x1+QMAX( adjbw1 ,0)/2, y1 , x2-QMAX( adjbw2,0)/2, (y1+y2+1)/2, s, c, textcolor, s2, adjbw1bighalf, adjbw2bighalf); drawBorder(p, x1+QMAX(-adjbw1+1,0)/2, (y1+y2+1)/2, x2-QMAX(-adjbw2+1,0)/2, y2 , s, c, textcolor, s1, adjbw1/2, adjbw2/2); break; case BSRight: drawBorder(p, x1 , y1+QMAX( adjbw1 ,0)/2, (x1+x2+1)/2, y2-QMAX( adjbw2,0)/2, s, c, textcolor, s2, adjbw1bighalf, adjbw2bighalf); drawBorder(p, (x1+x2+1)/2, y1+QMAX(-adjbw1+1,0)/2, x2 , y2-QMAX(-adjbw2+1,0)/2, s, c, textcolor, s1, adjbw1/2, adjbw2/2); break; } break; } case INSET: if(s == BSTop || s == BSLeft) c = c.dark(); /* nobreak; */ case OUTSET: if(style == OUTSET && (s == BSBottom || s == BSRight)) c = c.dark(); /* nobreak; */ case SOLID: QPointArray quad(4); p->setPen(Qt::NoPen); p->setBrush(c); Q_ASSERT(x2>=x1); Q_ASSERT(y2>=y1); if (adjbw1==0 && adjbw2 == 0) { p->drawRect(x1,y1,x2-x1,y2-y1); return; } switch(s) { case BSTop: quad.setPoints(4, x1+QMAX(-adjbw1,0), y1, x1+QMAX( adjbw1,0), y2, x2-QMAX( adjbw2,0), y2, x2-QMAX(-adjbw2,0), y1); break; case BSBottom: quad.setPoints(4, x1+QMAX( adjbw1,0), y1, x1+QMAX(-adjbw1,0), y2, x2-QMAX(-adjbw2,0), y2, x2-QMAX( adjbw2,0), y1); break; case BSLeft: quad.setPoints(4, x1, y1+QMAX(-adjbw1,0), x1, y2-QMAX(-adjbw2,0), x2, y2-QMAX( adjbw2,0), x2, y1+QMAX( adjbw1,0)); break; case BSRight: quad.setPoints(4, x1, y1+QMAX( adjbw1,0), x1, y2-QMAX( adjbw2,0), x2, y2-QMAX(-adjbw2,0), x2, y1+QMAX(-adjbw1,0)); break; } p->drawConvexPolygon(quad); break; } if(invalidisInvert && p->rasterOp() == Qt::XorROP) p->setRasterOp(Qt::CopyROP);}void RenderObject::paintBorder(QPainter *p, int _tx, int _ty, int w, int h, const RenderStyle* style, bool begin, bool end){ const QColor& tc = style->borderTopColor(); const QColor& bc = style->borderBottomColor(); const QColor& lc = style->borderLeftColor(); const QColor& rc = style->borderRightColor(); bool tt = style->borderTopIsTransparent(); bool bt = style->borderBottomIsTransparent(); bool rt = style->borderRightIsTransparent(); bool lt = style->borderLeftIsTransparent(); EBorderStyle ts = style->borderTopStyle(); EBorderStyle bs = style->borderBottomStyle(); EBorderStyle ls = style->borderLeftStyle(); EBorderStyle rs = style->borderRightStyle(); bool render_t = ts > BHIDDEN && !tt; bool render_l = ls > BHIDDEN && begin && !lt; bool render_r = rs > BHIDDEN && end && !rt; bool render_b = bs > BHIDDEN && !bt; if(render_t) { bool ignore_left = (tc == lc) && (tt == lt) && (ts >= OUTSET) && (ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET); bool ignore_right = (tc == rc) && (tt == rt) && (ts >= OUTSET) && (rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET); drawBorder(p, _tx, _ty, _tx + w, _ty + style->borderTopWidth(), BSTop, tc, style->color(), ts, ignore_left?0:style->borderLeftWidth(), ignore_right?0:style->borderRightWidth()); } if(render_b) { bool ignore_left = (bc == lc) && (bt == lt) && (bs >= OUTSET) && (ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET); bool ignore_right = (bc == rc) && (bt == rt) && (bs >= OUTSET) && (rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET); drawBorder(p, _tx, _ty + h - style->borderBottomWidth(), _tx + w, _ty + h, BSBottom, bc, style->color(), bs, ignore_left?0:style->borderLeftWidth(), ignore_right?0:style->borderRightWidth()); } if(render_l) { bool ignore_top = (tc == lc) && (tt == lt) && (ls >= OUTSET) && (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET); bool ignore_bottom = (bc == lc) && (bt == lt) && (ls >= OUTSET) && (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET); drawBorder(p, _tx, _ty, _tx + style->borderLeftWidth(), _ty + h, BSLeft, lc, style->color(), ls, ignore_top?0:style->borderTopWidth(), ignore_bottom?0:style->borderBottomWidth()); } if(render_r) { bool ignore_top = (tc == rc) && (tt == rt) && (rs >= DOTTED || rs == INSET) && (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET); bool ignore_bottom = (bc == rc) && (bt == rt) && (rs >= DOTTED || rs == INSET) && (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET); drawBorder(p, _tx + w - style->borderRightWidth(), _ty, _tx + w, _ty + h, BSRight, rc, style->color(), rs, ignore_top?0:style->borderTopWidth(), ignore_bottom?0:style->borderBottomWidth()); }}void RenderObject::absoluteRects(QValueList<QRect>& rects, int _tx, int _ty){ // For blocks inside inlines, we go ahead and include margins so that we run right up to the // inline boxes above and below us (thus getting merged with them to form a single irregular // shape). if (continuation()) { rects.append(QRect(_tx, _ty - collapsedMarginTop(), width(), height()+collapsedMarginTop()+collapsedMarginBottom())); continuation()->absoluteRects(rects, _tx - xPos() + continuation()->containingBlock()->xPos(), _ty - yPos() + continuation()->containingBlock()->yPos()); } else rects.append(QRect(_tx, _ty, width(), height()));}QRect RenderObject::absoluteBoundingBoxRect(){ int x, y; absolutePosition(x, y); QValueList<QRect> rects; absoluteRects(rects, x, y); QValueList<QRect>::ConstIterator it = rects.begin(); QRect result = *it; while (++it != rects.end()) { result = result.unite(*it); } return result;}void RenderObject::addAbsoluteRectForLayer(QRect& result){ if (layer()) { result = result.unite(absoluteBoundingBoxRect()); } for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { current->addAbsoluteRectForLayer(result); }}QRect RenderObject::paintingRootRect(QRect& topLevelRect){ QRect result = absoluteBoundingBoxRect(); topLevelRect = result; for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { current->addAbsoluteRectForLayer(result); } return result;}#if APPLE_CHANGESvoid RenderObject::addFocusRingRects(QPainter *p, int _tx, int _ty){ // For blocks inside inlines, we go ahead and include margins so that we run right up to the // inline boxes above and below us (thus getting merged with them to form a single irregular // shape). if (continuation()) { p->addFocusRingRect(_tx, _ty - collapsedMarginTop(), width(), height()+collapsedMarginTop()+collapsedMarginBottom()); continuation()->addFocusRingRects(p, _tx - xPos() + continuation()->containingBlock()->xPos(), _ty - yPos() + continuation()->containingBlock()->yPos()); } else p->addFocusRingRect(_tx, _ty, width(), height());}#endifvoid RenderObject::paintOutline(QPainter *p, int _tx, int _ty, int w, int h, const RenderStyle* style){ int ow = style->outlineWidth(); if(!ow) return; EBorderStyle os = style->outlineStyle(); if (os <= BHIDDEN) return; QColor oc = style->outlineColor(); if (!oc.isValid()) oc = style->color(); int offset = style->outlineOffset(); #ifdef APPLE_CHANGES if (style->outlineStyleIsAuto()) { p->initFocusRing(ow, offset, oc); addFocusRingRects(p, _tx, _ty); p->drawFocusRing(); p->clearFocusRing(); return; }#endif _tx -= offset; _ty -= offset; w += 2*offset; h += 2*offset; drawBorder(p, _tx-ow, _ty-ow, _tx, _ty+h+ow, BSLeft, QColor(oc), style->color(), os, ow, ow, true); drawBorder(p, _tx-ow, _ty-ow, _tx+w+ow, _ty, BSTop, QColor(oc), style->color(), os, ow, ow, true); drawBorder(p, _tx+w, _ty-ow, _tx+w+ow, _ty+h+ow, BSRight, QColor(oc), style->color(), os, ow, ow, true); drawBorder(p, _tx-ow, _ty+h, _tx+w+ow, _ty+h+ow, BSBottom, QColor(oc), style->color(), os, ow, ow, true);}void RenderObject::paint(PaintInfo& i, int tx, int ty){}void RenderObject::repaint(bool immediate){ // Can't use canvas(), since we might be unrooted. RenderObject* o = this; while ( o->parent() ) o = o->parent(); if (!o->isCanvas()) return; RenderCanvas* c = static_cast<RenderCanvas*>(o); if (c->printingMode()) return; // Don't repaint if we're printing. c->repaintViewRectangle(getAbsoluteRepaintRect(), immediate); }void RenderObject::repaintRectangle(const QRect& r, bool immediate){ // Can't use canvas(), since we might be unrooted. RenderObject* o = this; while ( o->parent() ) o = o->parent(); if (!o->isCanvas()) return; RenderCanvas* c = static_cast<RenderCanvas*>(o); if (c->printingMode()) return; // Don't repaint if we're printing. QRect absRect(r); computeAbsoluteRepaintRect(absRect); c->repaintViewRectangle(absRect, immediate);}bool RenderObject::repaintAfterLayoutIfNeeded(const QRect& oldBounds, const QRect& oldFullBounds){ QRect newBounds, newFullBounds; getAbsoluteRepaintRectIncludingFloats(newBounds, newFullBounds); if (newBounds != oldBounds || selfNeedsLayout()) { RenderCanvas* c = canvas(); if (c->printingMode()) return false; // Don't repaint if we're printing. c->repaintViewRectangle(oldFullBounds); if (newBounds != oldBounds) c->repaintViewRectangle(newFullBounds); return true; } return false;}void RenderObject::repaintDuringLayoutIfMoved(int x, int y){}void RenderObject::repaintFloatingDescendants(){}bool RenderObject::checkForRepaintDuringLayout() const{ return !document()->view()->needsFullRepaint() && !layer();}void RenderObject::repaintObjectsBeforeLayout(){ if (!needsLayout() || isText()) return; bool blockWithInlineChildren = (isRenderBlock() && !isTable() && normalChildNeedsLayout() && childrenInline()); if (selfNeedsLayout()) { repaint(); if (blockWithInlineChildren) return; } for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { if (!current->isPositioned()) // RenderBlock subclass method handles walking the positioned objects. current->repaintObjectsBeforeLayout(); }}QRect RenderObject::getAbsoluteRepaintRectWithOutline(int ow){ QRect r(getAbsoluteRepaintRect()); r.setRect(r.x()-ow, r.y()-ow, r.width()+ow*2, r.height()+ow*2); if (continuation() && !isInline()) r.setRect(r.x(), r.y()-collapsedMarginTop(), r.width(), r.height()+collapsedMarginTop()+collapsedMarginBottom()); if (isInlineFlow()) { for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) { if (!curr->isText()) { QRect childRect = curr->getAbsoluteRepaintRectWithOutline(ow); r = r.unite(childRect); } } } return r;}QRect RenderObject::getAbsoluteRepaintRect(){ if (parent()) return parent()->getAbsoluteRepaintRect(); return QRect();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -