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

📄 cssparser.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    case CSSPropertyBottom:               // <length> | <percentage> | auto | inherit    case CSSPropertyLeft:                 // <length> | <percentage> | auto | inherit    case CSSPropertyRight:                // <length> | <percentage> | auto | inherit    case CSSPropertyTop:                  // <length> | <percentage> | auto | inherit    case CSSPropertyMarginTop:           //// <margin-width> | inherit    case CSSPropertyMarginRight:         //   Which is defined as    case CSSPropertyMarginBottom:        //   <length> | <percentage> | auto | inherit    case CSSPropertyMarginLeft:          ////    case CSSPropertyWebkitMarginStart:        if (id == CSSValueAuto)            valid_primitive = true;        else            valid_primitive = (!id && validUnit(value, FLength|FPercent, m_strict));        break;    case CSSPropertyZIndex:              // auto | <integer> | inherit        if (id == CSSValueAuto) {            valid_primitive = true;            break;        }        /* nobreak */    case CSSPropertyOrphans:              // <integer> | inherit    case CSSPropertyWidows:               // <integer> | inherit        // ### not supported later on        valid_primitive = (!id && validUnit(value, FInteger, false));        break;    case CSSPropertyLineHeight:          // normal | <number> | <length> | <percentage> | inherit        if (id == CSSValueNormal)            valid_primitive = true;        else            valid_primitive = (!id && validUnit(value, FNumber|FLength|FPercent|FNonNeg, m_strict));        break;    case CSSPropertyCounterIncrement:    // [ <identifier> <integer>? ]+ | none | inherit        if (id != CSSValueNone)            return parseCounter(propId, 1, important);        valid_primitive = true;        break;     case CSSPropertyCounterReset:        // [ <identifier> <integer>? ]+ | none | inherit        if (id != CSSValueNone)            return parseCounter(propId, 0, important);        valid_primitive = true;        break;    case CSSPropertyFontFamily:        // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit    {        parsedValue = parseFontFamily();        break;    }    case CSSPropertyTextDecoration:    case CSSPropertyWebkitTextDecorationsInEffect:        // none | [ underline || overline || line-through || blink ] | inherit        if (id == CSSValueNone) {            valid_primitive = true;        } else {            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();            bool is_valid = true;            while(is_valid && value) {                switch (value->id) {                case CSSValueBlink:                    break;                case CSSValueUnderline:                case CSSValueOverline:                case CSSValueLineThrough:                    list->append(CSSPrimitiveValue::createIdentifier(value->id));                    break;                default:                    is_valid = false;                }                value = m_valueList->next();            }            if (list->length() && is_valid) {                parsedValue = list.release();                m_valueList->next();            }        }        break;    case CSSPropertyZoom:          // normal | reset | document | <number> | <percentage> | inherit        if (id == CSSValueNormal || id == CSSValueReset || id == CSSValueDocument)            valid_primitive = true;        else            valid_primitive = (!id && validUnit(value, FNumber | FPercent | FNonNeg, true));        break;            case CSSPropertyTableLayout:         // auto | fixed | inherit        if (id == CSSValueAuto || id == CSSValueFixed)            valid_primitive = true;        break;    case CSSPropertySrc:  // Only used within @font-face, so cannot use inherit | initial or be !important.  This is a list of urls or local references.        return parseFontFaceSrc();    case CSSPropertyUnicodeRange:        return parseFontFaceUnicodeRange();    /* CSS3 properties */    case CSSPropertyWebkitAppearance:        if ((id >= CSSValueCheckbox && id <= CSSValueTextarea) || id == CSSValueNone)            valid_primitive = true;        break;    case CSSPropertyWebkitBinding:#if ENABLE(XBL)        if (id == CSSValueNone)            valid_primitive = true;        else {            RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();            CSSParserValue* val;            RefPtr<CSSValue> parsedValue;            while ((val = m_valueList->current())) {                if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) {                    String value = parseURL(val->string);                    parsedValue = CSSPrimitiveValue::create(m_styleSheet->completeURL(value), CSSPrimitiveValue::CSS_URI);                }                if (!parsedValue)                    break;                                // FIXME: We can't use release() here since we might hit this path twice                // but that logic seems wrong to me to begin with, we convert all non-uri values                // into the last seen URI value!?                // -webkit-binding: url(foo.xml), 1, 2; (if that were valid) is treated as:                // -webkit-binding: url(foo.xml), url(foo.xml), url(foo.xml); !?                values->append(parsedValue.get());                m_valueList->next();            }            if (!values->length())                return false;                        addProperty(propId, values.release(), important);            m_valueList->next();            return true;        }#endif        break;    case CSSPropertyWebkitBorderImage:    case CSSPropertyWebkitMaskBoxImage:        if (id == CSSValueNone)            valid_primitive = true;        else {            RefPtr<CSSValue> result;            if (parseBorderImage(propId, important, result)) {                addProperty(propId, result, important);                return true;            }        }        break;    case CSSPropertyWebkitBorderTopRightRadius:    case CSSPropertyWebkitBorderTopLeftRadius:    case CSSPropertyWebkitBorderBottomLeftRadius:    case CSSPropertyWebkitBorderBottomRightRadius:    case CSSPropertyWebkitBorderRadius: {        if (num != 1 && num != 2)            return false;        valid_primitive = validUnit(value, FLength, m_strict);        if (!valid_primitive)            return false;        RefPtr<CSSPrimitiveValue> parsedValue1 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);        RefPtr<CSSPrimitiveValue> parsedValue2;        if (num == 2) {            value = m_valueList->next();            valid_primitive = validUnit(value, FLength, m_strict);            if (!valid_primitive)                return false;            parsedValue2 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);        } else            parsedValue2 = parsedValue1;                RefPtr<Pair> pair = Pair::create(parsedValue1.release(), parsedValue2.release());        RefPtr<CSSPrimitiveValue> val = CSSPrimitiveValue::create(pair.release());        if (propId == CSSPropertyWebkitBorderRadius) {            const int properties[4] = { CSSPropertyWebkitBorderTopRightRadius,                                        CSSPropertyWebkitBorderTopLeftRadius,                                        CSSPropertyWebkitBorderBottomLeftRadius,                                        CSSPropertyWebkitBorderBottomRightRadius };            for (int i = 0; i < 4; i++)                addProperty(properties[i], val.get(), important);        } else            addProperty(propId, val.release(), important);        return true;    }    case CSSPropertyOutlineOffset:        valid_primitive = validUnit(value, FLength, m_strict);        break;    case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS3, so treat as CSS3    case CSSPropertyWebkitBoxShadow:        if (id == CSSValueNone)            valid_primitive = true;        else            return parseShadow(propId, important);        break;    case CSSPropertyWebkitBoxReflect:        if (id == CSSValueNone)            valid_primitive = true;        else            return parseReflect(propId, important);        break;    case CSSPropertyOpacity:        valid_primitive = validUnit(value, FNumber, m_strict);        break;    case CSSPropertyWebkitBoxAlign:        if (id == CSSValueStretch || id == CSSValueStart || id == CSSValueEnd ||            id == CSSValueCenter || id == CSSValueBaseline)            valid_primitive = true;        break;    case CSSPropertyWebkitBoxDirection:        if (id == CSSValueNormal || id == CSSValueReverse)            valid_primitive = true;        break;    case CSSPropertyWebkitBoxLines:        if (id == CSSValueSingle || id == CSSValueMultiple)            valid_primitive = true;        break;    case CSSPropertyWebkitBoxOrient:        if (id == CSSValueHorizontal || id == CSSValueVertical ||            id == CSSValueInlineAxis || id == CSSValueBlockAxis)            valid_primitive = true;        break;    case CSSPropertyWebkitBoxPack:        if (id == CSSValueStart || id == CSSValueEnd ||            id == CSSValueCenter || id == CSSValueJustify)            valid_primitive = true;        break;    case CSSPropertyWebkitBoxFlex:        valid_primitive = validUnit(value, FNumber, m_strict);        break;    case CSSPropertyWebkitBoxFlexGroup:    case CSSPropertyWebkitBoxOrdinalGroup:        valid_primitive = validUnit(value, FInteger|FNonNeg, true);        break;    case CSSPropertyWebkitBoxSizing:        valid_primitive = id == CSSValueBorderBox || id == CSSValueContentBox;        break;    case CSSPropertyWebkitMarquee: {        const int properties[5] = { CSSPropertyWebkitMarqueeDirection, CSSPropertyWebkitMarqueeIncrement,                                    CSSPropertyWebkitMarqueeRepetition,                                    CSSPropertyWebkitMarqueeStyle, CSSPropertyWebkitMarqueeSpeed };        return parseShorthand(propId, properties, 5, important);    }    case CSSPropertyWebkitMarqueeDirection:        if (id == CSSValueForwards || id == CSSValueBackwards || id == CSSValueAhead ||            id == CSSValueReverse || id == CSSValueLeft || id == CSSValueRight || id == CSSValueDown ||            id == CSSValueUp || id == CSSValueAuto)            valid_primitive = true;        break;    case CSSPropertyWebkitMarqueeIncrement:        if (id == CSSValueSmall || id == CSSValueLarge || id == CSSValueMedium)            valid_primitive = true;        else            valid_primitive = validUnit(value, FLength|FPercent, m_strict);        break;    case CSSPropertyWebkitMarqueeStyle:        if (id == CSSValueNone || id == CSSValueSlide || id == CSSValueScroll || id == CSSValueAlternate)            valid_primitive = true;        break;    case CSSPropertyWebkitMarqueeRepetition:        if (id == CSSValueInfinite)            valid_primitive = true;        else            valid_primitive = validUnit(value, FInteger|FNonNeg, m_strict);        break;    case CSSPropertyWebkitMarqueeSpeed:        if (id == CSSValueNormal || id == CSSValueSlow || id == CSSValueFast)            valid_primitive = true;        else            valid_primitive = validUnit(value, FTime|FInteger|FNonNeg, m_strict);        break;    case CSSPropertyWebkitUserDrag: // auto | none | element        if (id == CSSValueAuto || id == CSSValueNone || id == CSSValueElement)            valid_primitive = true;        break;    case CSSPropertyWebkitUserModify: // read-only | read-write        if (id == CSSValueReadOnly || id == CSSValueReadWrite || id == CSSValueReadWritePlaintextOnly)            valid_primitive = true;        break;    case CSSPropertyWebkitUserSelect: // auto | none | text        if (id == CSSValueAuto || id == CSSValueNone || id == CSSValueText)            valid_primitive = true;        break;    case CSSPropertyTextOverflow: // clip | ellipsis        if (id == CSSValueClip || id == CSSValueEllipsis)            valid_primitive = true;        break;    case CSSPropertyWebkitTransform:        if (id == CSSValueNone)            valid_primitive = true;        else {            PassRefPtr<CSSValue> val = parseTransform();            if (val) {                addProperty(propId, val, important);                return true;            }            return false;        }        break;    case CSSPropertyWebkitTransformOrigin:    case CSSPropertyWebkitTransformOriginX:    case CSSPropertyWebkitTransformOriginY:    case CSSPropertyWebkitTransformOriginZ: {        RefPtr<CSSValue> val1;        RefPtr<CSSValue> val2;        RefPtr<CSSValue> val3;        int propId1, propId2, propId3;        if (parseTransformOrigin(propId, propId1, propId2, propId3, val1, val2, val3)) {            addProperty(propId1, val1.release(), important);            if (val2)                addProperty(propId2, val2.release(), important);            if (val3)                addProperty(propId3, val3.release(), important);            return true;        }        return false;    }    case CSSPropertyWebkitTransformStyle:        if (value->id == CSSValueFlat || value->id == CSSValuePreserve3d)            valid_primitive = true;        break;    case CSSPropertyWebkitBackfaceVisibility:        if (value->id == CSSValueVisible || value->id == CSSValueHidden)            valid_primitive = true;        break;    case CSSPropertyWebkitPerspective:        if (id == CSSValueNone)            valid_primitive = true;        else {            if (validUnit(value, FNumber|FNonNeg, m_strict)) {                RefPtr<CSSValue> val = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);                if (val) {                    addProperty(propId, val.release(), important);

⌨️ 快捷键说明

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