📄 render_inline.cpp
字号:
paintFocusRing(paintInfo.p, _tx, _ty); else#endif paintOutlines(paintInfo.p, _tx, _ty); }}void RenderInline::absoluteRects(QValueList<QRect>& rects, int _tx, int _ty){ for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) rects.append(QRect(_tx + curr->xPos(), _ty + curr->yPos(), curr->width(), curr->height())); for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) if (!curr->isText()) curr->absoluteRects(rects, _tx + curr->xPos(), _ty + curr->yPos()); if (continuation()) continuation()->absoluteRects(rects, _tx - containingBlock()->xPos() + continuation()->xPos(), _ty - containingBlock()->yPos() + continuation()->yPos());}#if APPLE_CHANGESvoid RenderInline::addFocusRingRects(QPainter *p, int _tx, int _ty){ for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { p->addFocusRingRect(_tx + curr->xPos(), _ty + curr->yPos(), curr->width(), curr->height()); } for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) { if (!curr->isText()) curr->addFocusRingRects(p, _tx + curr->xPos(), _ty + curr->yPos()); } if (continuation()) continuation()->addFocusRingRects(p, _tx - containingBlock()->xPos() + continuation()->xPos(), _ty - containingBlock()->yPos() + continuation()->yPos());}void RenderInline::paintFocusRing(QPainter *p, int tx, int ty){ int ow = style()->outlineWidth(); if (ow == 0 || m_isContinuation) // Continuations get painted by the original inline. return; QColor oc = style()->outlineColor(); if (!oc.isValid()) oc = style()->color(); p->initFocusRing(ow, style()->outlineOffset(), oc); addFocusRingRects(p, tx, ty); p->drawFocusRing(); p->clearFocusRing();}#endifvoid RenderInline::paintOutlines(QPainter *p, int _tx, int _ty){ if (style()->outlineWidth() == 0 || style()->outlineStyle() <= BHIDDEN) return; QPtrList <QRect> rects; rects.setAutoDelete(true); rects.append(new QRect(0,0,0,0)); for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { rects.append(new QRect(curr->xPos(), curr->yPos(), curr->width(), curr->height())); } rects.append(new QRect(0,0,0,0)); for (unsigned int i = 1; i < rects.count() - 1; i++) paintOutline(p, _tx, _ty, *rects.at(i-1), *rects.at(i), *rects.at(i+1));}void RenderInline::paintOutline(QPainter *p, int tx, int ty, const QRect &lastline, const QRect &thisline, const QRect &nextline){ int ow = style()->outlineWidth(); if (ow == 0 || m_isContinuation) // Continuations get painted by the original inline. return; EBorderStyle os = style()->outlineStyle(); QColor oc = style()->outlineColor(); if (!oc.isValid()) oc = style()->color(); int offset = style()->outlineOffset(); int t = ty + thisline.top() - offset; int l = tx + thisline.left() - offset; int b = ty + thisline.bottom() + offset + 1; int r = tx + thisline.right() + offset + 1; // left edge drawBorder(p, l - ow, t - (lastline.isEmpty() || thisline.left() < lastline.left() || lastline.right() <= thisline.left() ? ow : 0), l, b + (nextline.isEmpty() || thisline.left() <= nextline.left() || nextline.right() <= thisline.left() ? ow : 0), BSLeft, oc, style()->color(), os, (lastline.isEmpty() || thisline.left() < lastline.left() || lastline.right() <= thisline.left() ? ow : -ow), (nextline.isEmpty() || thisline.left() <= nextline.left() || nextline.right() <= thisline.left() ? ow : -ow), true); // right edge drawBorder(p, r, t - (lastline.isEmpty() || lastline.right() < thisline.right() || thisline.right() <= lastline.left() ? ow : 0), r + ow, b + (nextline.isEmpty() || nextline.right() <= thisline.right() || thisline.right() <= nextline.left() ? ow : 0), BSRight, oc, style()->color(), os, (lastline.isEmpty() || lastline.right() < thisline.right() || thisline.right() <= lastline.left() ? ow : -ow), (nextline.isEmpty() || nextline.right() <= thisline.right() || thisline.right() <= nextline.left() ? ow : -ow), true); // upper edge if ( thisline.left() < lastline.left()) drawBorder(p, l - ow, t - ow, QMIN(r+ow, (lastline.isValid()? tx+lastline.left() : 1000000)), t , BSTop, oc, style()->color(), os, ow, (lastline.isValid() && tx+lastline.left()+1<r+ow ? -ow : ow), true); if (lastline.right() < thisline.right()) drawBorder(p, QMAX(lastline.isValid()?tx + lastline.right() + 1:-1000000, l - ow), t - ow, r + ow, t , BSTop, oc, style()->color(), os, (lastline.isValid() && l-ow < tx+lastline.right()+1 ? -ow : ow), ow, true); // lower edge if ( thisline.left() < nextline.left()) drawBorder(p, l - ow, b, QMIN(r+ow, nextline.isValid()? tx+nextline.left()+1 : 1000000), b + ow, BSBottom, oc, style()->color(), os, ow, (nextline.isValid() && tx+nextline.left()+1<r+ow? -ow : ow), true); if (nextline.right() < thisline.right()) drawBorder(p, QMAX(nextline.isValid()?tx+nextline.right()+1:-1000000 , l-ow), b, r + ow, b + ow, BSBottom, oc, style()->color(), os, (nextline.isValid() && l-ow < tx+nextline.right()+1? -ow : ow), ow, true);}void RenderInline::calcMinMaxWidth(){ KHTMLAssert( !minMaxKnown() );#ifdef DEBUG_LAYOUT kdDebug( 6040 ) << renderName() << "(RenderInline)::calcMinMaxWidth() this=" << this << endl;#endif // Irrelevant, since some enclosing block will actually measure us and our children. m_minWidth = 0; m_maxWidth = 0; setMinMaxKnown();}bool RenderInline::requiresLayer() { return isRoot() || isRelPositioned() || style()->opacity() < 1.0f;}int RenderInline::width() const{ // Return the width of the minimal left side and the maximal right side. int leftSide = 0; int rightSide = 0; for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { if (curr == firstLineBox() || curr->xPos() < leftSide) leftSide = curr->xPos(); if (curr == firstLineBox() || curr->xPos() + curr->width() > rightSide) rightSide = curr->xPos() + curr->width(); } return rightSide - leftSide;}int RenderInline::height() const{ int h = 0; if (firstLineBox()) h = lastLineBox()->yPos() + lastLineBox()->height() - firstLineBox()->yPos(); return h;}int RenderInline::offsetLeft() const{ int x = RenderFlow::offsetLeft(); if (firstLineBox()) x += firstLineBox()->xPos(); return x;}int RenderInline::offsetTop() const{ int y = RenderFlow::offsetTop(); if (firstLineBox()) y += firstLineBox()->yPos(); return y;}const char *RenderInline::renderName() const{ if (isRelPositioned()) return "RenderInline (relative positioned)"; if (isAnonymous()) return "RenderInline (generated)"; return "RenderInline";}bool RenderInline::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction, bool inside){ // Check our kids if our HitTestAction says to. if (hitTestAction != HitTestSelfOnly) { for (RenderObject* child = lastChild(); child; child = child->previousSibling()) if (!child->layer() && !child->isFloating() && child->nodeAtPoint(info, _x, _y, _tx, _ty)) inside = true; } // Check our line boxes if we're still not inside. if (hitTestAction != HitTestChildrenOnly && !inside && style()->visibility() != HIDDEN) { // See if we're inside one of our line boxes. for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { if((_y >=_ty + curr->m_y) && (_y < _ty + curr->m_y + curr->m_height) && (_x >= _tx + curr->m_x) && (_x <_tx + curr->m_x + curr->m_width) ) { inside = true; break; } } } if (inside && element()) { if (info.innerNode() && info.innerNode()->renderer() && !info.innerNode()->renderer()->isInline()) { // Within the same layer, inlines are ALWAYS fully above blocks. Change inner node. info.setInnerNode(element()); // Clear everything else. info.setInnerNonSharedNode(0); info.setURLElement(0); } if (!info.innerNode()) info.setInnerNode(element()); if(!info.innerNonSharedNode()) info.setInnerNonSharedNode(element()); } return inside;}Position RenderInline::positionForCoordinates(int x, int y){ for (RenderObject *c = continuation(); c; c = c->continuation()) { if (c->isInline() || c->firstChild()) return c->positionForCoordinates(x, y); } return RenderFlow::positionForCoordinates(x, y);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -