IntRect RenderInline::clippedOverflowRectForRepaint(RenderBox* repaintContainer)
{
    // Only run-ins are allowed in here during layout.
    ASSERT(!view() || !view()->layoutStateEnabled() || isRunIn());

    if (!firstLineBox() && !continuation())
        return IntRect();

    // Find our leftmost position.
    IntRect boundingBox(linesBoundingBox());
    int left = boundingBox.x();
    int top = boundingBox.y();

    // Now invalidate a rectangle.
    int ow = style() ? style()->outlineSize() : 0;
    
    // We need to add in the relative position offsets of any inlines (including us) up to our
    // containing block.
    RenderBlock* cb = containingBlock();
    for (RenderObject* inlineFlow = this; inlineFlow && inlineFlow->isRenderInline() && inlineFlow != cb; 
         inlineFlow = inlineFlow->parent()) {
         if (inlineFlow->style()->position() == RelativePosition && inlineFlow->hasLayer())
            toRenderBox(inlineFlow)->layer()->relativePositionOffset(left, top);
    }

    IntRect r(-ow + left, -ow + top, boundingBox.width() + ow * 2, boundingBox.height() + ow * 2);
    if (cb->hasColumns())
        cb->adjustRectForColumns(r);

    if (cb->hasOverflowClip()) {
        // cb->height() is inaccurate if we're in the middle of a layout of |cb|, so use the
        // layer's size instead.  Even if the layer's size is wrong, the layer itself will repaint
        // anyway if its size does change.
        int x = r.x();
        int y = r.y();
        IntRect boxRect(0, 0, cb->layer()->width(), cb->layer()->height());
        cb->layer()->subtractScrolledContentOffset(x, y); // For overflow:auto/scroll/hidden.
        IntRect repaintRect(x, y, r.width(), r.height());
        r = intersection(repaintRect, boxRect);
    }
    ASSERT(repaintContainer != this);
    cb->computeRectForRepaint(r, repaintContainer);

    if (ow) {
        for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
            if (!curr->isText()) {
                IntRect childRect = curr->rectWithOutlineForRepaint(repaintContainer, ow);
                r.unite(childRect);
            }
        }

        if (continuation() && !continuation()->isInline()) {
            IntRect contRect = continuation()->rectWithOutlineForRepaint(repaintContainer, ow);
            r.unite(contRect);
        }
    }

    return r;
}
Beispiel #2
0
void DesktopWidget::paintChild(Rect& r)
{
	if (r.width() == 0 && r.height() == 0) return;
	//printf("DesktopWidget::paintChild input x:%d y:%d w:%d h:%d\n", 
	//	r.x(), r.y(), r.width(), r.height());

	WidgetListIt it = d->childList.begin();
	while (it != d->childList.end())
	{
		Widget* widget = *it;

		if (widget && widget->isVisible())
		{
			//printf("DesktopWidget::paintChild child paint name:%s\n", 
			//  widget->name()?widget->name():"NULL");
			//printf("widget x:%d y:%d w:%d h:%d\n", 
			//  widget->x(), widget->y(), 
			//  widget->width(), widget->height());
			if (widget->geometry().intersect(r))
			{
				//printf("DesktopWidget::paintChild paint name:%s\n",
				//	widget->name());

				int w = r.width() > widget->width() ? widget->width() : r.width();
				int h = r.height() > widget->height() ? widget->height() : r.height();

				SDL_Rect srcRect;
				srcRect.x = r.x() - widget->x();
				if (srcRect.x < 0)
				{
					srcRect.x = 0;
				}
				srcRect.y = r.y() - widget->y();
				if (srcRect.y < 0)
				{
					srcRect.y = 0;
				}
				srcRect.w = w;
				srcRect.h = h;


				Rect repaintRect(srcRect.x, srcRect.y, srcRect.w, srcRect.h);
				widget->paint(repaintRect);

				SDL_Rect dstRect;
				dstRect.x = r.x();
				dstRect.y = r.y();
				dstRect.w = w;
				dstRect.h = h;

				//printf("DesktopWidget::paintChild src(x:%d y:%d w:%d h:%d)\n",
				//		srcRect.x, srcRect.y, srcRect.w, srcRect.h);
				//printf("DesktopWidget::paintChild dst(x:%d y:%d w:%d h:%d)\n",
				//		dstRect.x, dstRect.y, dstRect.w, dstRect.h);

				Painter::blitSurface(widget, widget->surface(), &srcRect,
					d->surface, &dstRect);
			}
		}
		it++;
	}

	SDL_UpdateRect(d->surface, r.x(), r.y(), r.width(), r.height());
	//printf("DesktopWidget::paintChild update x:%d y:%d w:%d h:%d\n\n\n\n",
	//	r.x(), r.y(), r.width(), r.height());
}