コード例 #1
0
void RenderTableCell::readyWRATHWidgetCollapsedBorder(PaintedWidgetsOfWRATHHandle& handle,
                                                      ContextOfWRATH *wrath_context,
                                                      int tx, int ty, int w, int h)
{
    RenderTableCell_ReadyWRATHWidgetCollapsedBorder *d(RenderTableCell_ReadyWRATHWidgetCollapsedBorder::object(this, handle));

    ContextOfWRATH::AutoPushNode autoPushRoot(wrath_context, d->m_root_node);
    ContextOfWRATH::AutoPushNode autoPushSkip(wrath_context, d->m_skip_node);

    if (!table()->currentBorderStyle()) {
        d->m_skip_node.widget()->visible(false);
        return;
    }

    d->m_skip_node.widget()->visible(true);
    
    CollapsedBorderValue leftVal = collapsedLeftBorder();
    CollapsedBorderValue rightVal = collapsedRightBorder();
    CollapsedBorderValue topVal = collapsedTopBorder();
    CollapsedBorderValue bottomVal = collapsedBottomBorder();
     
    // Adjust our x/y/width/height so that we paint the collapsed borders at the correct location.
    int topWidth = topVal.width();
    int bottomWidth = bottomVal.width();
    int leftWidth = leftVal.width();
    int rightWidth = rightVal.width();
    
    tx -= leftWidth / 2;
    ty -= topWidth / 2;
    w += leftWidth / 2 + (rightWidth + 1) / 2;
    h += topWidth / 2 + (bottomWidth + 1) / 2;
    
    EBorderStyle topStyle = collapsedBorderStyle(topVal.style());
    EBorderStyle bottomStyle = collapsedBorderStyle(bottomVal.style());
    EBorderStyle leftStyle = collapsedBorderStyle(leftVal.style());
    EBorderStyle rightStyle = collapsedBorderStyle(rightVal.style());
    
    bool renderTop = topStyle > BHIDDEN && !topVal.isTransparent();
    bool renderBottom = bottomStyle > BHIDDEN && !bottomVal.isTransparent();
    bool renderLeft = leftStyle > BHIDDEN && !leftVal.isTransparent();
    bool renderRight = rightStyle > BHIDDEN && !rightVal.isTransparent();

    // We never paint diagonals at the joins.  We simply let the border with the highest
    // precedence paint on top of borders with lower precedence.  
    CollapsedBorders borders;
    borders.addBorder(topVal, BSTop, renderTop, tx, ty, tx + w, ty + topWidth, topStyle);
    borders.addBorder(bottomVal, BSBottom, renderBottom, tx, ty + h - bottomWidth, tx + w, ty + h, bottomStyle);
    borders.addBorder(leftVal, BSLeft, renderLeft, tx, ty, tx + leftWidth, ty + h, leftStyle);
    borders.addBorder(rightVal, BSRight, renderRight, tx + w - rightWidth, ty, tx + w, ty + h, rightStyle);

    /*
      [WRATH-DANGER]: These are not used at the moment
      const AffineTransform& currentCTM = graphicsContext->getCTM();
      bool antialias = !currentCTM.isIdentityOrTranslationOrFlipped();
    */
    
    d->m_top.visible(false);
    d->m_bottom.visible(false);
    d->m_left.visible(false);
    d->m_right.visible(false);
    for (CollapsedBorder* border = borders.nextBorder(); border; border = borders.nextBorder()) {
        if (border->borderValue == *table()->currentBorderStyle()) {
            PaintedWidgetsOfWRATHHandle* bh = NULL;
            if (border->borderValue == topVal)
                bh = &d->m_top;
            else if (border->borderValue == bottomVal)
                bh = &d->m_bottom;
            else if (border->borderValue == leftVal)
                bh = &d->m_left;
            else if (border->borderValue == rightVal)
                bh = &d->m_right;
            else
                ASSERT_NOT_REACHED();
            bh->visible(true);
            readyWRATHWidgetDrawLineForBoxSide(*bh, wrath_context, border->x1, border->y1, border->x2, border->y2, border->side, 
					       border->borderValue.color(), border->style, 0, 0, false /*antialias*/);
        }
    }
}
コード例 #2
0
void RenderLineBoxList::readyWRATHWidgets(PaintedWidgetsOfWRATHHandle &handle,
                                          RenderBoxModelObject *renderer,
                                          PaintInfoOfWRATH &paintInfo, int tx, int ty)
{
    RenderLineBoxList_WRATHWidgets *d;
    d=RenderLineBoxList_WRATHWidgets::object(renderer, handle);

    ContextOfWRATH::AutoPushNode autoPushRoot(paintInfo.wrath_context, d->m_root_node);

    /*
      this just.. sucks. WebKit builds a list of 
      RenderInline objects that it will draw outlines.
      It is not clear if and how that list changes,
      so we punt and make all them handle non-visible
      and only those that are found in the list
      are then made visible.
     */
    d->m_handles.hideEachObject();
    d->m_outlineHandles.hideEachObject();

  // 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;

    RenderView* v = renderer->view();
    bool usePrintRect = !v->printRect().isEmpty();
    int outlineSize = renderer->maximalOutlineSize(paintInfo.phase);
    if (!anyLineIntersectsRect(renderer, paintInfo.rect, tx, ty, usePrintRect, outlineSize))
        return;

    PaintInfoOfWRATH info(paintInfo);
    ListHashSet<RenderInline*> outlineObjects;
    info.outlineObjects = &outlineObjects;

    

    for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
        if (usePrintRect) {

            RootInlineBox* root = curr->root();
            int topForPaginationCheck = curr->logicalTopVisualOverflow(root->lineTop());
            int bottomForPaginationCheck = curr->logicalLeftVisualOverflow();
            if (!curr->parent()) {
                // We're a root box.  Use lineTop and lineBottom as well here.
                topForPaginationCheck = min(topForPaginationCheck, root->lineTop());
                bottomForPaginationCheck = max(bottomForPaginationCheck, root->lineBottom());
            }
            if (bottomForPaginationCheck - topForPaginationCheck <= v->printRect().height()) {
                if (ty + bottomForPaginationCheck > v->printRect().maxY()) {
                    if (RootInlineBox* nextRootBox = curr->root()->nextRootBox())
                        bottomForPaginationCheck = min(bottomForPaginationCheck, min(nextRootBox->logicalTopVisualOverflow(), nextRootBox->lineTop()));
                }
                if (ty + bottomForPaginationCheck > v->printRect().maxY()) {
                    if (ty + topForPaginationCheck < v->truncatedAt())
                        v->setBestTruncatedAt(ty + topForPaginationCheck, renderer);
                    // If we were able to truncate, don't paint.
                    if (ty + topForPaginationCheck >= v->truncatedAt())
                        break;
                }
            }
        }

        if (lineIntersectsDirtyRect(renderer, curr, info, tx, ty)) {
            RootInlineBox* root = curr->root();
            PaintedWidgetsOfWRATHHandleT<InlineBox> &currHandle(d->m_handles.getHandle(curr));

            currHandle.visible(true);
            curr->readyWRATHWidgets(currHandle, info, tx, ty, 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;
            PaintedWidgetsOfWRATHHandle &handle(d->m_outlineHandles.getHandle(flow));

            handle.visible(true);
            flow->readyWRATHWidgetOutline(handle, info.wrath_context, tx, ty);
        }
        info.outlineObjects->clear();
    }

    
    d->m_handles.removeNonVisibleHandles();
    d->m_outlineHandles.removeNonVisibleHandles();
}