⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rendertable.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    return RenderBlock::borderLeft();}    int RenderTable::calcBorderRight() const{    if (collapseBorders()) {        // Determined by the last cell of the first row. See the CSS 2.1 spec, section 17.6.2.        if (!numEffCols())            return 0;        unsigned borderWidth = 0;        const BorderValue& tb = style()->borderRight();        if (tb.style() == BHIDDEN)            return 0;        if (tb.style() > BHIDDEN)            borderWidth = tb.width;        int rightmostColumn = style()->direction() == RTL ? 0 : numEffCols() - 1;        RenderTableCol* colGroup = colElement(rightmostColumn);        if (colGroup) {            const BorderValue& gb = style()->borderRight();            if (gb.style() == BHIDDEN)                return 0;            if (gb.style() > BHIDDEN)                borderWidth = max(borderWidth, static_cast<unsigned>(gb.width));        }                RenderTableSection* firstNonEmptySection = m_head ? m_head : (m_firstBody ? m_firstBody : m_foot);        if (firstNonEmptySection && !firstNonEmptySection->numRows())            firstNonEmptySection = sectionBelow(firstNonEmptySection, true);                if (firstNonEmptySection) {            const BorderValue& sb = firstNonEmptySection->style()->borderRight();            if (sb.style() == BHIDDEN)                return 0;            if (sb.style() > BHIDDEN)                borderWidth = max(borderWidth, static_cast<unsigned>(sb.width));            const RenderTableSection::CellStruct& cs = firstNonEmptySection->cellAt(0, rightmostColumn);                        if (cs.cell) {                const BorderValue& cb = cs.cell->style()->borderRight();                if (cb.style() == BHIDDEN)                    return 0;                const BorderValue& rb = cs.cell->parent()->style()->borderRight();                if (rb.style() == BHIDDEN)                    return 0;                if (cb.style() > BHIDDEN)                    borderWidth = max(borderWidth, static_cast<unsigned>(cb.width));                if (rb.style() > BHIDDEN)                    borderWidth = max(borderWidth, static_cast<unsigned>(rb.width));            }        }        return (borderWidth + 1) / 2;    }    return RenderBlock::borderRight();}void RenderTable::recalcHorizontalBorders(){    m_borderLeft = calcBorderLeft();    m_borderRight = calcBorderRight();}int RenderTable::borderTop() const{    if (collapseBorders())        return outerBorderTop();    return RenderBlock::borderTop();}int RenderTable::borderBottom() const{    if (collapseBorders())        return outerBorderBottom();    return RenderBlock::borderBottom();}int RenderTable::outerBorderTop() const{    if (!collapseBorders())        return 0;    int borderWidth = 0;    RenderTableSection* topSection;    if (m_head)        topSection = m_head;    else if (m_firstBody)        topSection = m_firstBody;    else if (m_foot)        topSection = m_foot;    else        topSection = 0;    if (topSection) {        borderWidth = topSection->outerBorderTop();        if (borderWidth == -1)            return 0;   // Overridden by hidden    }    const BorderValue& tb = style()->borderTop();    if (tb.style() == BHIDDEN)        return 0;    if (tb.style() > BHIDDEN)        borderWidth = max(borderWidth, static_cast<int>(tb.width / 2));    return borderWidth;}int RenderTable::outerBorderBottom() const{    if (!collapseBorders())        return 0;    int borderWidth = 0;    RenderTableSection* bottomSection;    if (m_foot)        bottomSection = m_foot;    else {        RenderObject* child;        for (child = lastChild(); child && !child->isTableSection(); child = child->previousSibling())            ;        bottomSection = child ? static_cast<RenderTableSection*>(child) : 0;    }    if (bottomSection) {        borderWidth = bottomSection->outerBorderBottom();        if (borderWidth == -1)            return 0;   // Overridden by hidden    }    const BorderValue& tb = style()->borderBottom();    if (tb.style() == BHIDDEN)        return 0;    if (tb.style() > BHIDDEN)        borderWidth = max(borderWidth, static_cast<int>((tb.width + 1) / 2));    return borderWidth;}int RenderTable::outerBorderLeft() const{    if (!collapseBorders())        return 0;    int borderWidth = 0;    const BorderValue& tb = style()->borderLeft();    if (tb.style() == BHIDDEN)        return 0;    if (tb.style() > BHIDDEN)        borderWidth = tb.width / 2;    bool allHidden = true;    for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {        if (!child->isTableSection())            continue;        int sw = static_cast<RenderTableSection*>(child)->outerBorderLeft();        if (sw == -1)            continue;        else            allHidden = false;        borderWidth = max(borderWidth, sw);    }    if (allHidden)        return 0;    return borderWidth;}int RenderTable::outerBorderRight() const{    if (!collapseBorders())        return 0;    int borderWidth = 0;    const BorderValue& tb = style()->borderRight();    if (tb.style() == BHIDDEN)        return 0;    if (tb.style() > BHIDDEN)        borderWidth = (tb.width + 1) / 2;    bool allHidden = true;    for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {        if (!child->isTableSection())            continue;        int sw = static_cast<RenderTableSection*>(child)->outerBorderRight();        if (sw == -1)            continue;        else            allHidden = false;        borderWidth = max(borderWidth, sw);    }    if (allHidden)        return 0;    return borderWidth;}RenderTableSection* RenderTable::sectionAbove(const RenderTableSection* section, bool skipEmptySections) const{    recalcSectionsIfNeeded();    if (section == m_head)        return 0;    RenderObject* prevSection = section == m_foot ? lastChild() : section->previousSibling();    while (prevSection) {        if (prevSection->isTableSection() && prevSection != m_head && prevSection != m_foot && (!skipEmptySections || static_cast<RenderTableSection*>(prevSection)->numRows()))            break;        prevSection = prevSection->previousSibling();    }    if (!prevSection && m_head && (!skipEmptySections || m_head->numRows()))        prevSection = m_head;    return static_cast<RenderTableSection*>(prevSection);}RenderTableSection* RenderTable::sectionBelow(const RenderTableSection* section, bool skipEmptySections) const{    recalcSectionsIfNeeded();    if (section == m_foot)        return 0;    RenderObject* nextSection = section == m_head ? firstChild() : section->nextSibling();    while (nextSection) {        if (nextSection->isTableSection() && nextSection != m_head && nextSection != m_foot && (!skipEmptySections || static_cast<RenderTableSection*>(nextSection)->numRows()))            break;        nextSection = nextSection->nextSibling();    }    if (!nextSection && m_foot && (!skipEmptySections || m_foot->numRows()))        nextSection = m_foot;    return static_cast<RenderTableSection*>(nextSection);}RenderTableCell* RenderTable::cellAbove(const RenderTableCell* cell) const{    recalcSectionsIfNeeded();    // Find the section and row to look in    int r = cell->row();    RenderTableSection* section = 0;    int rAbove = 0;    if (r > 0) {        // cell is not in the first row, so use the above row in its own section        section = cell->section();        rAbove = r - 1;    } else {        section = sectionAbove(cell->section(), true);        if (section)            rAbove = section->numRows() - 1;    }    // Look up the cell in the section's grid, which requires effective col index    if (section) {        int effCol = colToEffCol(cell->col());        RenderTableSection::CellStruct aboveCell;        // If we hit a span back up to a real cell.        do {            aboveCell = section->cellAt(rAbove, effCol);            effCol--;        } while (!aboveCell.cell && aboveCell.inColSpan && effCol >= 0);        return aboveCell.cell;    } else        return 0;}RenderTableCell* RenderTable::cellBelow(const RenderTableCell* cell) const{    recalcSectionsIfNeeded();    // Find the section and row to look in    int r = cell->row() + cell->rowSpan() - 1;    RenderTableSection* section = 0;    int rBelow = 0;    if (r < cell->section()->numRows() - 1) {        // The cell is not in the last row, so use the next row in the section.        section = cell->section();        rBelow = r + 1;    } else {        section = sectionBelow(cell->section(), true);        if (section)            rBelow = 0;    }    // Look up the cell in the section's grid, which requires effective col index    if (section) {        int effCol = colToEffCol(cell->col());        RenderTableSection::CellStruct belowCell;        // If we hit a colspan back up to a real cell.        do {            belowCell = section->cellAt(rBelow, effCol);            effCol--;        } while (!belowCell.cell && belowCell.inColSpan && effCol >= 0);        return belowCell.cell;    } else        return 0;}RenderTableCell* RenderTable::cellBefore(const RenderTableCell* cell) const{    recalcSectionsIfNeeded();    RenderTableSection* section = cell->section();    int effCol = colToEffCol(cell->col());    if (!effCol)        return 0;        // If we hit a colspan back up to a real cell.    RenderTableSection::CellStruct prevCell;    do {        prevCell = section->cellAt(cell->row(), effCol - 1);        effCol--;    } while (!prevCell.cell && prevCell.inColSpan && effCol >= 0);    return prevCell.cell;}RenderTableCell* RenderTable::cellAfter(const RenderTableCell* cell) const{    recalcSectionsIfNeeded();    int effCol = colToEffCol(cell->col() + cell->colSpan());    if (effCol >= numEffCols())        return 0;    return cell->section()->cellAt(cell->row(), effCol).cell;}RenderBlock* RenderTable::firstLineBlock() const{    return 0;}void RenderTable::updateFirstLetter(){}int RenderTable::firstLineBoxBaseline() const{    RenderTableSection* firstNonEmptySection = m_head ? m_head : (m_firstBody ? m_firstBody : m_foot);    if (firstNonEmptySection && !firstNonEmptySection->numRows())        firstNonEmptySection = sectionBelow(firstNonEmptySection, true);    if (!firstNonEmptySection)        return -1;    return firstNonEmptySection->y() + firstNonEmptySection->firstLineBoxBaseline();}IntRect RenderTable::overflowClipRect(int tx, int ty){    IntRect rect = RenderBlock::overflowClipRect(tx, ty);        // If we have a caption, expand the clip to include the caption.    // FIXME: Technically this is wrong, but it's virtually impossible to fix this    // for real until captions have been re-written.    // FIXME: This code assumes (like all our other caption code) that only top/bottom are    // supported.  When we actually support left/right and stop mapping them to top/bottom,    // we might have to hack this code first (depending on what order we do these bug fixes in).    if (m_caption) {        rect.setHeight(height());        rect.setY(ty);    }    return rect;}bool RenderTable::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int xPos, int yPos, int tx, int ty, HitTestAction action){    tx += x();    ty += y();    // Check kids first.    if (!hasOverflowClip() || overflowClipRect(tx, ty).contains(xPos, yPos)) {        for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {            if (child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer() && (child->isTableSection() || child == m_caption) &&                child->nodeAtPoint(request, result, xPos, yPos, tx, ty, action)) {                updateHitTestResult(result, IntPoint(xPos - tx, yPos - ty));                return true;            }        }    }    // Check our bounds next.    if (visibleToHitTesting() && (action == HitTestBlockBackground || action == HitTestChildBlockBackground) && IntRect(tx, ty, width(), height()).contains(xPos, yPos)) {        updateHitTestResult(result, IntPoint(xPos - tx, yPos - ty));        return true;    }    return false;}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -