css_renderstyledeclarationimpl.cpp

来自「konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版」· C++ 代码 · 共 762 行 · 第 1/2 页

CPP
762
字号
            return new CSSPrimitiveValueImpl("none", CSSPrimitiveValue::CSS_STRING);        case khtml::FLEFT:            return new CSSPrimitiveValueImpl("left", CSSPrimitiveValue::CSS_STRING);        case khtml::FRIGHT:            return new CSSPrimitiveValueImpl("right", CSSPrimitiveValue::CSS_STRING);        case khtml::FLEFT_ALIGN:            return new CSSPrimitiveValueImpl("-khtml-left", CSSPrimitiveValue::CSS_STRING);        case khtml::FRIGHT_ALIGN:            return new CSSPrimitiveValueImpl("-khtml-right", CSSPrimitiveValue::CSS_STRING);        }    }    case CSS_PROP_FONT_FAMILY:    {        FontDef def = style->htmlFont().getFontDef();        return new CSSPrimitiveValueImpl(def.family, CSSPrimitiveValue::CSS_STRING);    }    case CSS_PROP_FONT_SIZE:    {        FontDef def = style->htmlFont().getFontDef();        return new CSSPrimitiveValueImpl(def.size, CSSPrimitiveValue::CSS_PX);    }    case CSS_PROP_FONT_STYLE:    {        // FIXME: handle oblique        FontDef def = style->htmlFont().getFontDef();        if (def.italic)            return new CSSPrimitiveValueImpl("italic", CSSPrimitiveValue::CSS_STRING);        else            return new CSSPrimitiveValueImpl("normal", CSSPrimitiveValue::CSS_STRING);    }    case CSS_PROP_FONT_VARIANT:    {        FontDef def = style->htmlFont().getFontDef();        if (def.smallCaps)            return new CSSPrimitiveValueImpl("small-caps", CSSPrimitiveValue::CSS_STRING);        else            return new CSSPrimitiveValueImpl("normal", CSSPrimitiveValue::CSS_STRING);    }    case CSS_PROP_FONT_WEIGHT:    {        // FIXME: this does not reflect the full range of weights        // that can be expressed with CSS        FontDef def = style->htmlFont().getFontDef();        if (def.weight == QFont::Bold)            return new CSSPrimitiveValueImpl("bold", CSSPrimitiveValue::CSS_STRING);        else            return new CSSPrimitiveValueImpl("normal", CSSPrimitiveValue::CSS_STRING);    }    case CSS_PROP_HEIGHT:        return new CSSPrimitiveValueImpl(renderer->contentHeight(), CSSPrimitiveValue::CSS_PX);    case CSS_PROP_LEFT:        break;    case CSS_PROP_LETTER_SPACING:        if (style->letterSpacing() == 0)            return new CSSPrimitiveValueImpl("normal", CSSPrimitiveValue::CSS_STRING);        return new CSSPrimitiveValueImpl(style->letterSpacing(), CSSPrimitiveValue::CSS_PX);    case CSS_PROP_LINE_HEIGHT:    {        Length length(style->lineHeight());        if (length.isPercent()) {            //XXX: merge from webcore the computedStyle/specifiedStyle distinction in rendering/font.h            float computedSize = style->htmlFont().getFontDef().size;            return new CSSPrimitiveValueImpl((int)(length._length * computedSize) / 100, CSSPrimitiveValue::CSS_PX);        }        else {            return new CSSPrimitiveValueImpl(length._length, CSSPrimitiveValue::CSS_PX);        }    }    case CSS_PROP_LIST_STYLE_IMAGE:        break;    case CSS_PROP_LIST_STYLE_POSITION:        switch (style->listStylePosition()) {        case OUTSIDE:            return new CSSPrimitiveValueImpl("outside", CSSPrimitiveValue::CSS_STRING);        case INSIDE:            return new CSSPrimitiveValueImpl("inside", CSSPrimitiveValue::CSS_STRING);        }        Q_ASSERT( 0 );        break;    case CSS_PROP_LIST_STYLE_TYPE:        return new CSSPrimitiveValueImpl(stringForListStyleType(style->listStyleType()), CSSPrimitiveValue::CSS_STRING);    case CSS_PROP_MARGIN_TOP:        return valueForLength(style->marginTop(), renderer->contentHeight());    case CSS_PROP_MARGIN_RIGHT:        return valueForLength(style->marginRight(), renderer->contentWidth());    case CSS_PROP_MARGIN_BOTTOM:        return valueForLength(style->marginBottom(), renderer->contentHeight());    case CSS_PROP_MARGIN_LEFT:        return valueForLength(style->marginLeft(), renderer->contentWidth());    case CSS_PROP_MAX_HEIGHT:        return new CSSPrimitiveValueImpl( renderer->availableHeight(),                                          CSSPrimitiveValue::CSS_PX );        break;    case CSS_PROP_MAX_WIDTH:        return new CSSPrimitiveValueImpl( renderer->maxWidth(),                                          CSSPrimitiveValue::CSS_PX );        break;    case CSS_PROP_MIN_HEIGHT:        return new CSSPrimitiveValueImpl( renderer->contentHeight(),                                          CSSPrimitiveValue::CSS_PX );        break;    case CSS_PROP_MIN_WIDTH:        return new CSSPrimitiveValueImpl( renderer->minWidth(),                                          CSSPrimitiveValue::CSS_PX );        break;    case CSS_PROP_OPACITY:        break;    case CSS_PROP_ORPHANS:        break;    case CSS_PROP_OUTLINE_COLOR:        break;    case CSS_PROP_OUTLINE_OFFSET:        break;    case CSS_PROP_OUTLINE_STYLE:        break;    case CSS_PROP_OUTLINE_WIDTH:        break;    case CSS_PROP_OVERFLOW:    {        switch (style->overflow()) {        case khtml::OVISIBLE:            return new CSSPrimitiveValueImpl("visible", CSSPrimitiveValue::CSS_STRING);        case khtml::OHIDDEN:            return new CSSPrimitiveValueImpl("hidden", CSSPrimitiveValue::CSS_STRING);        case khtml::OSCROLL:            return new CSSPrimitiveValueImpl("scroll", CSSPrimitiveValue::CSS_STRING);        case khtml::OAUTO:            return new CSSPrimitiveValueImpl("auto", CSSPrimitiveValue::CSS_STRING);        case khtml::OMARQUEE:            return new CSSPrimitiveValueImpl("marquee", CSSPrimitiveValue::CSS_STRING);        }    }    case CSS_PROP_PADDING_TOP:        return valueForLength(style->paddingTop(), renderer->contentHeight());    case CSS_PROP_PADDING_RIGHT:        return valueForLength(style->paddingRight(), renderer->contentWidth());    case CSS_PROP_PADDING_BOTTOM:        return valueForLength(style->paddingBottom(), renderer->contentHeight());    case CSS_PROP_PADDING_LEFT:        return valueForLength(style->paddingLeft(), renderer->contentWidth());    case CSS_PROP_PAGE_BREAK_AFTER:        break;    case CSS_PROP_PAGE_BREAK_BEFORE:        break;    case CSS_PROP_PAGE_BREAK_INSIDE:        break;    case CSS_PROP_POSITION:        break;    case CSS_PROP_QUOTES:        break;    case CSS_PROP_RIGHT:        break;    case CSS_PROP_SIZE:        break;    case CSS_PROP_TABLE_LAYOUT:        break;    case CSS_PROP_TEXT_ALIGN:        return new CSSPrimitiveValueImpl(stringForTextAlign(style->textAlign()), CSSPrimitiveValue::CSS_STRING);    case CSS_PROP_TEXT_DECORATION:    {        QString string;        if (style->textDecoration() & khtml::UNDERLINE)            string += "underline";        if (style->textDecoration() & khtml::OVERLINE) {            if (string.length() > 0)                string += " ";            string += "overline";        }        if (style->textDecoration() & khtml::LINE_THROUGH) {            if (string.length() > 0)                string += " ";            string += "line-through";        }        if (style->textDecoration() & khtml::BLINK) {            if (string.length() > 0)                string += " ";            string += "blink";        }        if (string.length() == 0)            string = "none";        return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);    }    case CSS_PROP_TEXT_INDENT:        return valueForLength(style->textIndent(), renderer->contentWidth());    case CSS_PROP_TEXT_TRANSFORM:        break;    case CSS_PROP_TOP:        break;    case CSS_PROP_UNICODE_BIDI:        break;    case CSS_PROP_VERTICAL_ALIGN:    {        switch (style->verticalAlign()) {        case khtml::BASELINE:            return new CSSPrimitiveValueImpl("baseline", CSSPrimitiveValue::CSS_STRING);        case khtml::MIDDLE:            return new CSSPrimitiveValueImpl("middle", CSSPrimitiveValue::CSS_STRING);        case khtml::SUB:            return new CSSPrimitiveValueImpl("sub", CSSPrimitiveValue::CSS_STRING);        case khtml::SUPER:            return new CSSPrimitiveValueImpl("super", CSSPrimitiveValue::CSS_STRING);        case khtml::TEXT_TOP:            return new CSSPrimitiveValueImpl("text-top", CSSPrimitiveValue::CSS_STRING);        case khtml::TEXT_BOTTOM:            return new CSSPrimitiveValueImpl("text-bottom", CSSPrimitiveValue::CSS_STRING);        case khtml::TOP:            return new CSSPrimitiveValueImpl("top", CSSPrimitiveValue::CSS_STRING);        case khtml::BOTTOM:            return new CSSPrimitiveValueImpl("bottom", CSSPrimitiveValue::CSS_STRING);        case khtml::BASELINE_MIDDLE:            return new CSSPrimitiveValueImpl("baseline-middle", CSSPrimitiveValue::CSS_STRING);        case khtml::LENGTH:            return valueForLength(style->verticalAlignLength(), renderer->contentWidth());        }    }    case CSS_PROP_VISIBILITY:        switch (style->visibility()) {            case khtml::VISIBLE:                return new CSSPrimitiveValueImpl("visible", CSSPrimitiveValue::CSS_STRING);            case khtml::HIDDEN:                return new CSSPrimitiveValueImpl("hidden", CSSPrimitiveValue::CSS_STRING);            case khtml::COLLAPSE:                return new CSSPrimitiveValueImpl("collapse", CSSPrimitiveValue::CSS_STRING);        }        break;    case CSS_PROP_WHITE_SPACE:    {        switch (style->whiteSpace()) {            case khtml::NORMAL:                return new CSSPrimitiveValueImpl("normal", CSSPrimitiveValue::CSS_STRING);            case khtml::NOWRAP:                return new CSSPrimitiveValueImpl("nowrap", CSSPrimitiveValue::CSS_STRING);            case khtml::PRE:                return new CSSPrimitiveValueImpl("pre", CSSPrimitiveValue::CSS_STRING);            case khtml::PRE_WRAP:                return new CSSPrimitiveValueImpl("pre-wrap", CSSPrimitiveValue::CSS_STRING);            case khtml::PRE_LINE:                return new CSSPrimitiveValueImpl("pre-line", CSSPrimitiveValue::CSS_STRING);            case khtml::KHTML_NOWRAP:                return new CSSPrimitiveValueImpl("-khtml-nowrap", CSSPrimitiveValue::CSS_STRING);        }        break;    }    case CSS_PROP_WIDOWS:        break;    case CSS_PROP_WIDTH:        return new CSSPrimitiveValueImpl( renderer->contentWidth(),                                         CSSPrimitiveValue::CSS_PX );    case CSS_PROP_WORD_SPACING:        return new CSSPrimitiveValueImpl(style->wordSpacing(), CSSPrimitiveValue::CSS_PX);    case CSS_PROP_Z_INDEX:        break;    case CSS_PROP_BACKGROUND:        break;    case CSS_PROP_BORDER:        break;    case CSS_PROP_BORDER_COLOR:        break;    case CSS_PROP_BORDER_STYLE:        break;    case CSS_PROP_BORDER_TOP:        return new CSSPrimitiveValueImpl( renderer->borderTop(),                                         CSSPrimitiveValue::CSS_PX );        break;    case CSS_PROP_BORDER_RIGHT:        return new CSSPrimitiveValueImpl( renderer->borderRight(),                                         CSSPrimitiveValue::CSS_PX );        break;    case CSS_PROP_BORDER_BOTTOM:        return new CSSPrimitiveValueImpl( renderer->borderBottom(),                                         CSSPrimitiveValue::CSS_PX );        break;    case CSS_PROP_BORDER_LEFT:        return new CSSPrimitiveValueImpl( renderer->borderLeft(),                                         CSSPrimitiveValue::CSS_PX );        break;    case CSS_PROP_BORDER_WIDTH:        break;    case CSS_PROP_FONT:        break;    case CSS_PROP_LIST_STYLE:        break;    case CSS_PROP_MARGIN:        break;    case CSS_PROP_OUTLINE:        break;    case CSS_PROP_PADDING:        break;    case CSS_PROP_SCROLLBAR_BASE_COLOR:        break;    case CSS_PROP_SCROLLBAR_FACE_COLOR:        break;    case CSS_PROP_SCROLLBAR_SHADOW_COLOR:        break;    case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:        break;    case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR:        break;    case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:        break;    case CSS_PROP_SCROLLBAR_TRACK_COLOR:        break;    case CSS_PROP_SCROLLBAR_ARROW_COLOR:        break;    case CSS_PROP__KHTML_FLOW_MODE:        break;    case CSS_PROP__KHTML_USER_INPUT:        break;    default:        Q_ASSERT( 0 );        break;    }    return 0;}DOMString RenderStyleDeclarationImpl::getPropertyValue( int propertyID ) const{    CSSValueImpl* value = getPropertyCSSValue(propertyID);    if (value)        return value->cssText();    return "";}bool RenderStyleDeclarationImpl::getPropertyPriority( int ) const{    // This class does not support the notion of priority, since the object    // is a computed value.    return false;}DOM::DOMString RenderStyleDeclarationImpl::removeProperty( int, bool ){    // ### emit error since we're read-only    return DOMString();}bool RenderStyleDeclarationImpl::setProperty ( int, const DOM::DOMString&, bool,                                               bool ){    // ### emit error since we're read-only    return false;}void RenderStyleDeclarationImpl::setProperty ( int, int, bool,                                               bool ){    // ### emit error since we're read-only}void RenderStyleDeclarationImpl::setLengthProperty( int, const DOM::DOMString&, bool,                                                    bool, bool ){    // ### emit error since we're read-only}void RenderStyleDeclarationImpl::setProperty( const DOMString& ){    // ### emit error since we're read-only}DOM::DOMString RenderStyleDeclarationImpl::item( unsigned long ) const{    // ###    return DOMString();}CSSProperty RenderStyleDeclarationImpl::property( int id ) const{    CSSProperty prop;    prop.m_id = id;    prop.m_bImportant = false;    prop.nonCSSHint = false;    CSSValueImpl* v = getPropertyCSSValue( id );    if ( !v )        v = new CSSPrimitiveValueImpl;    prop.setValue( v );    return prop;}

⌨️ 快捷键说明

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