Пример #1
0
/**
 * Traverses the horizontal inline boxes and appends the point coordinates to
 * the given array.
 * @param box inline box
 * @param pointArray array collecting coordinates
 * @param bottom \c true, collect bottom coordinates, \c false, collect top
 * 	coordinates.
 * @param limit lower limit that an y-coordinate must at least reach. Note
 *	that limit designates the highest y-coordinate for \c bottom, and
 *	the lowest for !\c bottom.
 */
static void collectHorizontalBoxCoordinates(InlineBox *box, QValueVector< QPoint > &pointArray, bool bottom, int offset, int limit = -500000)
{
    //   kdDebug(6000) << "collectHorizontalBoxCoordinates: " << endl;
    offset = bottom ? offset : -offset;
    int y = box->yPos() + bottom * box->height() + offset;
    if(limit != -500000 && (bottom ? y < limit : y > limit))
        y = limit;
    int x = box->xPos() + bottom * box->width() + offset;
    QPoint newPnt(x, y);
    // Add intersection point if point-array not empty.
    if(!pointArray.isEmpty())
    {
        QPoint lastPnt = pointArray.back();
        QPoint insPnt(newPnt.x(), lastPnt.y());
        if(offset && ((bottom && lastPnt.y() > y) || (!bottom && lastPnt.y() < y)))
        {
            insPnt.rx() = lastPnt.x();
            insPnt.ry() = y;
        }
        //         kdDebug(6040) << "left: " << lastPnt << " == " << insPnt << ": " << (insPnt == lastPnt) << endl;
        appendPoint(pointArray, insPnt);
    }
    // Insert starting point of box
    appendPoint(pointArray, newPnt);

    newPnt.rx() += (bottom ? -box->width() : box->width()) - 2 * offset;

    if(box->isInlineFlowBox())
    {
        InlineFlowBox *flowBox = static_cast< InlineFlowBox * >(box);
        for(InlineBox *b = bottom ? flowBox->lastChild() : flowBox->firstChild(); b; b = bottom ? b->prevOnLine() : b->nextOnLine())
        {
            // Don't let boxes smaller than this flow box' height influence
            // the vertical position of the outline if they have a different
            // x-coordinate
            int l2;
            if(b->xPos() != box->xPos() && b->xPos() + b->width() != box->xPos() + box->width())
                l2 = y;
            else
                l2 = limit;
            collectHorizontalBoxCoordinates(b, pointArray, bottom, kAbs(offset), l2);
        }

        // Add intersection point if flow box contained any children
        if(flowBox->firstChild())
        {
            QPoint lastPnt = pointArray.back();
            QPoint insPnt(lastPnt.x(), newPnt.y());
            //             kdDebug(6040) << "right: " << lastPnt << " == " << insPnt << ": " << (insPnt == lastPnt) << endl;
            appendPoint(pointArray, insPnt);
        }
    }

    // Insert ending point of box
    appendPoint(pointArray, newPnt);

    //     kdDebug(6000) << "collectHorizontalBoxCoordinates: " << "ende" << endl;
}