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

📄 htmltableelement.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 2 页
字号:
            borders[cLeft] = borders[cRight] = true;        } else if (equalIgnoringCase(attr->value(), "lhs")) {            m_frameAttr = true;            borders[cLeft] = true;        } else if (equalIgnoringCase(attr->value(), "rhs")) {            m_frameAttr = true;            borders[cRight] = true;        } else if (equalIgnoringCase(attr->value(), "box") ||                   equalIgnoringCase(attr->value(), "border")) {            m_frameAttr = true;            borders[cTop] = borders[cBottom] = borders[cLeft] = borders[cRight] = true;        }                // Now map in the border styles of solid and hidden respectively.        if (m_frameAttr) {            addCSSProperty(attr, CSSPropertyBorderTopWidth, CSSValueThin);            addCSSProperty(attr, CSSPropertyBorderBottomWidth, CSSValueThin);            addCSSProperty(attr, CSSPropertyBorderLeftWidth, CSSValueThin);            addCSSProperty(attr, CSSPropertyBorderRightWidth, CSSValueThin);            addCSSProperty(attr, CSSPropertyBorderTopStyle, borders[cTop] ? CSSValueSolid : CSSValueHidden);            addCSSProperty(attr, CSSPropertyBorderBottomStyle, borders[cBottom] ? CSSValueSolid : CSSValueHidden);            addCSSProperty(attr, CSSPropertyBorderLeftStyle, borders[cLeft] ? CSSValueSolid : CSSValueHidden);            addCSSProperty(attr, CSSPropertyBorderRightStyle, borders[cRight] ? CSSValueSolid : CSSValueHidden);        }    } else if (attr->name() == rulesAttr) {        m_rulesAttr = UnsetRules;        if (equalIgnoringCase(attr->value(), "none"))            m_rulesAttr = NoneRules;        else if (equalIgnoringCase(attr->value(), "groups"))            m_rulesAttr = GroupsRules;        else if (equalIgnoringCase(attr->value(), "rows"))            m_rulesAttr = RowsRules;        if (equalIgnoringCase(attr->value(), "cols"))            m_rulesAttr = ColsRules;        if (equalIgnoringCase(attr->value(), "all"))            m_rulesAttr = AllRules;                // The presence of a valid rules attribute causes border collapsing to be enabled.        if (m_rulesAttr != UnsetRules)            addCSSProperty(attr, CSSPropertyBorderCollapse, CSSValueCollapse);    } else if (attr->name() == cellspacingAttr) {        if (!attr->value().isEmpty())            addCSSLength(attr, CSSPropertyBorderSpacing, attr->value());    } else if (attr->name() == cellpaddingAttr) {        if (!attr->value().isEmpty())            m_padding = max(0, attr->value().toInt());        else            m_padding = 1;    } else if (attr->name() == colsAttr) {        // ###    } else if (attr->name() == vspaceAttr) {        addCSSLength(attr, CSSPropertyMarginTop, attr->value());        addCSSLength(attr, CSSPropertyMarginBottom, attr->value());    } else if (attr->name() == hspaceAttr) {        addCSSLength(attr, CSSPropertyMarginLeft, attr->value());        addCSSLength(attr, CSSPropertyMarginRight, attr->value());    } else if (attr->name() == alignAttr) {        if (!attr->value().isEmpty()) {            if (equalIgnoringCase(attr->value(), "center")) {                addCSSProperty(attr, CSSPropertyMarginLeft, CSSValueAuto);                addCSSProperty(attr, CSSPropertyMarginRight, CSSValueAuto);            } else                addCSSProperty(attr, CSSPropertyFloat, attr->value());        }    } else if (attr->name() == valignAttr) {        if (!attr->value().isEmpty())            addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value());    } else        HTMLElement::parseMappedAttribute(attr);    if (bordersBefore != cellBorders() || oldPadding != m_padding) {        if (oldPadding != m_padding)            m_paddingDecl = 0;        bool cellChanged = false;        for (Node* child = firstChild(); child; child = child->nextSibling())            cellChanged |= setTableCellsChanged(child);        if (cellChanged)            setChanged();    }}void HTMLTableElement::additionalAttributeStyleDecls(Vector<CSSMutableStyleDeclaration*>& results){    if ((!m_borderAttr && !m_borderColorAttr) || m_frameAttr)        return;    AtomicString borderValue = m_borderColorAttr ? "solid" : "outset";    CSSMappedAttributeDeclaration* decl = getMappedAttributeDecl(ePersistent, tableborderAttr, borderValue);    if (!decl) {        decl = CSSMappedAttributeDeclaration::create().releaseRef(); // This single ref pins us in the table until the document dies.        decl->setParent(document()->elementSheet());        decl->setNode(this);        decl->setStrictParsing(false); // Mapped attributes are just always quirky.                int v = m_borderColorAttr ? CSSValueSolid : CSSValueOutset;        decl->setProperty(CSSPropertyBorderTopStyle, v, false);        decl->setProperty(CSSPropertyBorderBottomStyle, v, false);        decl->setProperty(CSSPropertyBorderLeftStyle, v, false);        decl->setProperty(CSSPropertyBorderRightStyle, v, false);        setMappedAttributeDecl(ePersistent, tableborderAttr, borderValue, decl);        decl->setParent(0);        decl->setNode(0);        decl->setMappedState(ePersistent, tableborderAttr, borderValue);    }            results.append(decl);}HTMLTableElement::CellBorders HTMLTableElement::cellBorders() const{    switch (m_rulesAttr) {        case NoneRules:        case GroupsRules:            return NoBorders;        case AllRules:            return SolidBorders;        case ColsRules:            return SolidBordersColsOnly;        case RowsRules:            return SolidBordersRowsOnly;        case UnsetRules:            if (!m_borderAttr)                return NoBorders;            if (m_borderColorAttr)                return SolidBorders;            return InsetBorders;    }    ASSERT_NOT_REACHED();    return NoBorders;}void HTMLTableElement::addSharedCellDecls(Vector<CSSMutableStyleDeclaration*>& results){    addSharedCellBordersDecl(results);    addSharedCellPaddingDecl(results);}void HTMLTableElement::addSharedCellBordersDecl(Vector<CSSMutableStyleDeclaration*>& results){    CellBorders borders = cellBorders();    static const AtomicString* cellBorderNames[] = { new AtomicString("none"), new AtomicString("solid"), new AtomicString("inset"), new AtomicString("solid-cols"), new AtomicString("solid-rows") };    const AtomicString& cellborderValue = *cellBorderNames[borders];    CSSMappedAttributeDeclaration* decl = getMappedAttributeDecl(ePersistent, cellborderAttr, cellborderValue);    if (!decl) {        decl = CSSMappedAttributeDeclaration::create().releaseRef(); // This single ref pins us in the table until the document dies.        decl->setParent(document()->elementSheet());        decl->setNode(this);        decl->setStrictParsing(false); // Mapped attributes are just always quirky.                switch (borders) {            case SolidBordersColsOnly:                decl->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin, false);                decl->setProperty(CSSPropertyBorderRightWidth, CSSValueThin, false);                decl->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid, false);                decl->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid, false);                decl->setProperty(CSSPropertyBorderColor, "inherit", false);                break;            case SolidBordersRowsOnly:                decl->setProperty(CSSPropertyBorderTopWidth, CSSValueThin, false);                decl->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin, false);                decl->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid, false);                decl->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid, false);                decl->setProperty(CSSPropertyBorderColor, "inherit", false);                break;            case SolidBorders:                decl->setProperty(CSSPropertyBorderWidth, "1px", false);                decl->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid, false);                decl->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid, false);                decl->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid, false);                decl->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid, false);                decl->setProperty(CSSPropertyBorderColor, "inherit", false);                break;            case InsetBorders:                decl->setProperty(CSSPropertyBorderWidth, "1px", false);                decl->setProperty(CSSPropertyBorderTopStyle, CSSValueInset, false);                decl->setProperty(CSSPropertyBorderBottomStyle, CSSValueInset, false);                decl->setProperty(CSSPropertyBorderLeftStyle, CSSValueInset, false);                decl->setProperty(CSSPropertyBorderRightStyle, CSSValueInset, false);                decl->setProperty(CSSPropertyBorderColor, "inherit", false);                break;            case NoBorders:                decl->setProperty(CSSPropertyBorderWidth, "0", false);                break;        }        setMappedAttributeDecl(ePersistent, cellborderAttr, *cellBorderNames[borders], decl);        decl->setParent(0);        decl->setNode(0);        decl->setMappedState(ePersistent, cellborderAttr, cellborderValue);    }        results.append(decl);}void HTMLTableElement::addSharedCellPaddingDecl(Vector<CSSMutableStyleDeclaration*>& results){    if (m_padding == 0)        return;    if (!m_paddingDecl) {        String paddingValue = String::number(m_padding);        m_paddingDecl = getMappedAttributeDecl(eUniversal, cellpaddingAttr, paddingValue);        if (!m_paddingDecl) {            m_paddingDecl = CSSMappedAttributeDeclaration::create();            m_paddingDecl->setParent(document()->elementSheet());            m_paddingDecl->setNode(this);            m_paddingDecl->setStrictParsing(false); // Mapped attributes are just always quirky.                        m_paddingDecl->setProperty(CSSPropertyPaddingTop, paddingValue, false);            m_paddingDecl->setProperty(CSSPropertyPaddingRight, paddingValue, false);            m_paddingDecl->setProperty(CSSPropertyPaddingBottom, paddingValue, false);            m_paddingDecl->setProperty(CSSPropertyPaddingLeft, paddingValue, false);        }        setMappedAttributeDecl(eUniversal, cellpaddingAttr, paddingValue, m_paddingDecl.get());        m_paddingDecl->setParent(0);        m_paddingDecl->setNode(0);        m_paddingDecl->setMappedState(eUniversal, cellpaddingAttr, paddingValue);    }        results.append(m_paddingDecl.get());}void HTMLTableElement::addSharedGroupDecls(bool rows, Vector<CSSMutableStyleDeclaration*>& results){    if (m_rulesAttr != GroupsRules)        return;    AtomicString rulesValue = rows ? "rowgroups" : "colgroups";    CSSMappedAttributeDeclaration* decl = getMappedAttributeDecl(ePersistent, rulesAttr, rulesValue);    if (!decl) {        decl = CSSMappedAttributeDeclaration::create().releaseRef(); // This single ref pins us in the table until the document dies.        decl->setParent(document()->elementSheet());        decl->setNode(this);        decl->setStrictParsing(false); // Mapped attributes are just always quirky.                if (rows) {            decl->setProperty(CSSPropertyBorderTopWidth, CSSValueThin, false);            decl->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin, false);            decl->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid, false);            decl->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid, false);        } else {            decl->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin, false);            decl->setProperty(CSSPropertyBorderRightWidth, CSSValueThin, false);            decl->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid, false);            decl->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid, false);        }        setMappedAttributeDecl(ePersistent, rulesAttr, rulesValue, decl);        decl->setParent(0);        decl->setNode(0);        decl->setMappedState(ePersistent, rulesAttr, rulesValue);    }    results.append(decl);}void HTMLTableElement::attach(){    ASSERT(!attached());    HTMLElement::attach();}bool HTMLTableElement::isURLAttribute(Attribute *attr) const{    return attr->name() == backgroundAttr;}PassRefPtr<HTMLCollection> HTMLTableElement::rows(){    return HTMLTableRowsCollection::create(this);}PassRefPtr<HTMLCollection> HTMLTableElement::tBodies(){    return HTMLCollection::create(this, HTMLCollection::TableTBodies);}String HTMLTableElement::align() const{    return getAttribute(alignAttr);}void HTMLTableElement::setAlign(const String &value){    setAttribute(alignAttr, value);}String HTMLTableElement::bgColor() const{    return getAttribute(bgcolorAttr);}void HTMLTableElement::setBgColor(const String &value){    setAttribute(bgcolorAttr, value);}String HTMLTableElement::border() const{    return getAttribute(borderAttr);}void HTMLTableElement::setBorder(const String &value){    setAttribute(borderAttr, value);}String HTMLTableElement::cellPadding() const{    return getAttribute(cellpaddingAttr);}void HTMLTableElement::setCellPadding(const String &value){    setAttribute(cellpaddingAttr, value);}String HTMLTableElement::cellSpacing() const{    return getAttribute(cellspacingAttr);}void HTMLTableElement::setCellSpacing(const String &value){    setAttribute(cellspacingAttr, value);}String HTMLTableElement::frame() const{    return getAttribute(frameAttr);}void HTMLTableElement::setFrame(const String &value){    setAttribute(frameAttr, value);}String HTMLTableElement::rules() const{    return getAttribute(rulesAttr);}void HTMLTableElement::setRules(const String &value){    setAttribute(rulesAttr, value);}String HTMLTableElement::summary() const{    return getAttribute(summaryAttr);}void HTMLTableElement::setSummary(const String &value){    setAttribute(summaryAttr, value);}String HTMLTableElement::width() const{    return getAttribute(widthAttr);}void HTMLTableElement::setWidth(const String &value){    setAttribute(widthAttr, value);}void HTMLTableElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const{    HTMLElement::addSubresourceAttributeURLs(urls);    addSubresourceURL(urls, document()->completeURL(getAttribute(backgroundAttr)));}}

⌨️ 快捷键说明

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