cssparser.cpp
来自「konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版」· C++ 代码 · 共 1,746 行 · 第 1/5 页
CPP
1,746 行
CSSValueImpl *val1 = 0, *val2 = 0; int propId1, propId2; if (parseBackgroundProperty(propId, propId1, propId2, val1, val2)) { addProperty(propId1, val1, important); if (val2) addProperty(propId2, val2, important); return true; } return false; } case CSS_PROP_LIST_STYLE_IMAGE: // <uri> | none | inherit if (id == CSS_VAL_NONE) { parsedValue = new CSSImageValueImpl(); valueList->next(); } else if (value->unit == CSSPrimitiveValue::CSS_URI ) { // ### allow string in non strict mode? DOMString uri = khtml::parseURL( domString( value->string ) ); if (!uri.isEmpty()) { parsedValue = new CSSImageValueImpl( DOMString(KURL( styleElement->baseURL(), uri.string()).url()), styleElement ); valueList->next(); } } break; case CSS_PROP_OUTLINE_WIDTH: // <border-width> | inherit case CSS_PROP_BORDER_TOP_WIDTH: //// <border-width> | inherit case CSS_PROP_BORDER_RIGHT_WIDTH: // Which is defined as case CSS_PROP_BORDER_BOTTOM_WIDTH: // thin | medium | thick | <length> case CSS_PROP_BORDER_LEFT_WIDTH: //// if (id == CSS_VAL_THIN || id == CSS_VAL_MEDIUM || id == CSS_VAL_THICK) valid_primitive = true; else valid_primitive = ( validUnit( value, FLength, strict&(!nonCSSHint) ) ); break; case CSS_PROP_LETTER_SPACING: // normal | <length> | inherit case CSS_PROP_WORD_SPACING: // normal | <length> | inherit if ( id == CSS_VAL_NORMAL ) valid_primitive = true; else valid_primitive = validUnit( value, FLength, strict&(!nonCSSHint) ); break; case CSS_PROP_TEXT_INDENT: // <length> | <percentage> | inherit valid_primitive = ( !id && validUnit( value, FLength|FPercent, strict&(!nonCSSHint) ) ); break; case CSS_PROP_PADDING_TOP: // <length> | <percentage> | inherit case CSS_PROP_PADDING_RIGHT: // <padding-width> | inherit case CSS_PROP_PADDING_BOTTOM: // Which is defined as case CSS_PROP_PADDING_LEFT: // <length> | <percentage> case CSS_PROP__KHTML_PADDING_START: valid_primitive = ( !id && validUnit( value, FLength|FPercent|FNonNeg, strict&(!nonCSSHint) ) ); break; case CSS_PROP_MAX_HEIGHT: // <length> | <percentage> | none | inherit case CSS_PROP_MAX_WIDTH: // <length> | <percentage> | none | inherit if ( id == CSS_VAL_NONE ) { valid_primitive = true; break; } /* nobreak */ case CSS_PROP_MIN_HEIGHT: // <length> | <percentage> | inherit case CSS_PROP_MIN_WIDTH: // <length> | <percentage> | inherit valid_primitive = ( !id && validUnit( value, FLength|FPercent|FNonNeg, strict&(!nonCSSHint) ) ); break; case CSS_PROP_FONT_SIZE: // <absolute-size> | <relative-size> | <length> | <percentage> | inherit if (id >= CSS_VAL_XX_SMALL && id <= CSS_VAL_LARGER) valid_primitive = true; else valid_primitive = ( validUnit( value, FLength|FPercent, strict&(!nonCSSHint) ) ); break; case CSS_PROP_FONT_STYLE: // normal | italic | oblique | inherit if ( id == CSS_VAL_NORMAL || id == CSS_VAL_ITALIC || id == CSS_VAL_OBLIQUE) valid_primitive = true; break; case CSS_PROP_FONT_VARIANT: // normal | small-caps | inherit if ( id == CSS_VAL_NORMAL || id == CSS_VAL_SMALL_CAPS) valid_primitive = true; break; case CSS_PROP_VERTICAL_ALIGN: // baseline | sub | super | top | text-top | middle | bottom | text-bottom | // <percentage> | <length> | inherit if ( id >= CSS_VAL_BASELINE && id <= CSS_VAL__KHTML_BASELINE_MIDDLE ) valid_primitive = true; else valid_primitive = ( !id && validUnit( value, FLength|FPercent, strict&(!nonCSSHint) ) ); break; case CSS_PROP_HEIGHT: // <length> | <percentage> | auto | inherit case CSS_PROP_WIDTH: // <length> | <percentage> | auto | inherit if ( id == CSS_VAL_AUTO ) valid_primitive = true; else // ### handle multilength case where we allow relative units valid_primitive = ( !id && validUnit( value, FLength|FPercent|FNonNeg, strict&(!nonCSSHint) ) ); break; case CSS_PROP_BOTTOM: // <length> | <percentage> | auto | inherit case CSS_PROP_LEFT: // <length> | <percentage> | auto | inherit case CSS_PROP_RIGHT: // <length> | <percentage> | auto | inherit case CSS_PROP_TOP: // <length> | <percentage> | auto | inherit case CSS_PROP_MARGIN_TOP: //// <margin-width> | inherit case CSS_PROP_MARGIN_RIGHT: // Which is defined as case CSS_PROP_MARGIN_BOTTOM: // <length> | <percentage> | auto | inherit case CSS_PROP_MARGIN_LEFT: //// case CSS_PROP__KHTML_MARGIN_START: if ( id == CSS_VAL_AUTO ) valid_primitive = true; else valid_primitive = ( !id && validUnit( value, FLength|FPercent, strict&(!nonCSSHint) ) ); break; case CSS_PROP_Z_INDEX: // auto | <integer> | inherit // qDebug("parsing z-index: id=%d, fValue=%f", id, value->fValue ); if ( id == CSS_VAL_AUTO ) { valid_primitive = true; break; } /* nobreak */ case CSS_PROP_ORPHANS: // <integer> | inherit case CSS_PROP_WIDOWS: // <integer> | inherit // ### not supported later on valid_primitive = ( !id && validUnit( value, FInteger, false ) ); break; case CSS_PROP_LINE_HEIGHT: // normal | <number> | <length> | <percentage> | inherit if ( id == CSS_VAL_NORMAL ) valid_primitive = true; else valid_primitive = ( !id && validUnit( value, FNumber|FLength|FPercent, strict&(!nonCSSHint) ) ); break; case CSS_PROP_COUNTER_INCREMENT: // [ <identifier> <integer>? ]+ | none | inherit if ( id == CSS_VAL_NONE ) valid_primitive = true; else return parseCounter(propId, true, important); break; case CSS_PROP_COUNTER_RESET: // [ <identifier> <integer>? ]+ | none | inherit if ( id == CSS_VAL_NONE ) valid_primitive = true; else return parseCounter(propId, false, important); break; case CSS_PROP_FONT_FAMILY: // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit { parsedValue = parseFontFamily(); break; } case CSS_PROP_TEXT_DECORATION: // none | [ underline || overline || line-through || blink ] | inherit if (id == CSS_VAL_NONE) { valid_primitive = true; } else { CSSValueListImpl *list = new CSSValueListImpl; bool is_valid = true; while( is_valid && value ) { switch ( value->id ) { case CSS_VAL_BLINK: break; case CSS_VAL_UNDERLINE: case CSS_VAL_OVERLINE: case CSS_VAL_LINE_THROUGH: list->append( new CSSPrimitiveValueImpl( value->id ) ); break; default: is_valid = false; } value = valueList->next(); } //kdDebug( 6080 ) << "got " << list->length() << "d decorations" << endl; if(list->length() && is_valid) { parsedValue = list; valueList->next(); } else { delete list; } } break; case CSS_PROP_TABLE_LAYOUT: // auto | fixed | inherit if ( id == CSS_VAL_AUTO || id == CSS_VAL_FIXED ) valid_primitive = true; break; case CSS_PROP__KHTML_FLOW_MODE: if ( id == CSS_VAL__KHTML_NORMAL || id == CSS_VAL__KHTML_AROUND_FLOATS ) valid_primitive = true; break; /* CSS3 properties */ case CSS_PROP_BOX_SIZING: // border-box | content-box | inherit if ( id == CSS_VAL_BORDER_BOX || id == CSS_VAL_CONTENT_BOX ) valid_primitive = true; break; case CSS_PROP_OUTLINE_OFFSET: valid_primitive = validUnit(value, FLength, strict); break; case CSS_PROP_TEXT_SHADOW: // CSS2 property, dropped in CSS2.1, back in CSS3, so treat as CSS3 if (id == CSS_VAL_NONE) valid_primitive = true; else return parseShadow(propId, important); break; case CSS_PROP_OPACITY: valid_primitive = validUnit(value, FNumber, strict); break; case CSS_PROP__KHTML_USER_INPUT: // none | enabled | disabled | inherit if ( id == CSS_VAL_NONE || id == CSS_VAL_ENABLED || id == CSS_VAL_DISABLED ) valid_primitive = true;// kdDebug(6080) << "CSS_PROP__KHTML_USER_INPUT: " << valid_primitive << endl; break; case CSS_PROP__KHTML_MARQUEE: { const int properties[5] = { CSS_PROP__KHTML_MARQUEE_DIRECTION, CSS_PROP__KHTML_MARQUEE_INCREMENT, CSS_PROP__KHTML_MARQUEE_REPETITION, CSS_PROP__KHTML_MARQUEE_STYLE, CSS_PROP__KHTML_MARQUEE_SPEED }; return parseShortHand(properties, 5, important); } case CSS_PROP__KHTML_MARQUEE_DIRECTION: if (id == CSS_VAL_FORWARDS || id == CSS_VAL_BACKWARDS || id == CSS_VAL_AHEAD || id == CSS_VAL_REVERSE || id == CSS_VAL_LEFT || id == CSS_VAL_RIGHT || id == CSS_VAL_DOWN || id == CSS_VAL_UP || id == CSS_VAL_AUTO) valid_primitive = true; break; case CSS_PROP__KHTML_MARQUEE_INCREMENT: if (id == CSS_VAL_SMALL || id == CSS_VAL_LARGE || id == CSS_VAL_MEDIUM) valid_primitive = true; else valid_primitive = validUnit(value, FLength|FPercent, strict&(!nonCSSHint)); break; case CSS_PROP__KHTML_MARQUEE_STYLE: if (id == CSS_VAL_NONE || id == CSS_VAL_SLIDE || id == CSS_VAL_SCROLL || id == CSS_VAL_ALTERNATE || id == CSS_VAL_UNFURL) valid_primitive = true; break; case CSS_PROP__KHTML_MARQUEE_REPETITION: if (id == CSS_VAL_INFINITE) valid_primitive = true; else valid_primitive = validUnit(value, FInteger|FNonNeg, strict&(!nonCSSHint)); break; case CSS_PROP__KHTML_MARQUEE_SPEED: if (id == CSS_VAL_NORMAL || id == CSS_VAL_SLOW || id == CSS_VAL_FAST) valid_primitive = true; else valid_primitive = validUnit(value, FTime|FInteger|FNonNeg, strict&(!nonCSSHint)); break; // End of CSS3 properties /* shorthand properties */ case CSS_PROP_BACKGROUND: // ['background-color' || 'background-image' ||'background-repeat' || // 'background-attachment' || 'background-position'] | inherit return parseBackgroundShorthand(important); case CSS_PROP_BORDER: // [ 'border-width' || 'border-style' || <color> ] | inherit { const int properties[3] = { CSS_PROP_BORDER_WIDTH, CSS_PROP_BORDER_STYLE, CSS_PROP_BORDER_COLOR }; return parseShortHand(properties, 3, important); } case CSS_PROP_BORDER_TOP: // [ 'border-top-width' || 'border-style' || <color> ] | inherit { const int properties[3] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_TOP_STYLE, CSS_PROP_BORDER_TOP_COLOR}; return parseShortHand(properties, 3, important); } case CSS_PROP_BORDER_RIGHT: // [ 'border-right-width' || 'border-style' || <color> ] | inherit { const int properties[3] = { CSS_PROP_BORDER_RIGHT_WIDTH, CSS_PROP_BORDER_RIGHT_STYLE, CSS_PROP_BORDER_RIGHT_COLOR }; return parseShortHand(properties, 3, important); } case CSS_PROP_BORDER_BOTTOM: // [ 'border-bottom-width' || 'border-style' || <color> ] | inherit { const int properties[3] = { CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_PROP_BORDER_BOTTOM_COLOR }; return parseShortHand(properties, 3, important); } case CSS_PROP_BORDER_LEFT: // [ 'border-left-width' || 'border-style' || <color> ] | inherit { const int properties[3] = { CSS_PROP_BORDER_LEFT_WIDTH, CSS_PROP_BORDER_LEFT_STYLE, CSS_PROP_BORDER_LEFT_COLOR }; return parseShortHand(properties, 3, important); } case CSS_PROP_OUTLINE: // [ 'outline-color' || 'outline-style' || 'outline-width' ] | inherit { const int properties[3] = { CSS_PROP_OUTLINE_WIDTH, CSS_PROP_OUTLINE_STYLE, CSS_PROP_OUTLINE_COLOR }; return parseShortHand(properties, 3, important); } case CSS_PROP_BORDER_COLOR: // <color>{1,4} | inherit { const int properties[4] = { CSS_PROP_BORDER_TOP_COLOR, CSS_PROP_BORDER_RIGHT_COLOR, CSS_PROP_BORDER_BOTTOM_COLOR, CSS_PROP_BORDER_LEFT_COLOR }; return parse4Values(properties, important); } case CSS_PROP_BORDER_WIDTH: // <border-width>{1,4} | inherit { const int properties[4] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_RIGHT_WIDTH, CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_LEFT_WIDTH }; return parse4Values(properties, important); } case CSS_PROP_BORDER_STYLE: // <border-style>{1,4} | inherit { const int properties[4] = { CSS_PROP_BORDER_TOP_STYLE, CSS_PROP_BORDER_RIGHT_STYLE, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_PROP_BORDER_LEFT_STYLE }; return parse4Values(properties, important); } case CSS_PROP_MARGIN: // <margin-width>{1,4} | inherit { const int properties[4] = { CSS_PROP_MARGIN_TOP, CSS_PROP_MARGIN_RIGHT, CSS_PROP_MARGIN_BOTTOM, CSS_PROP_MARGIN_LEFT }; return parse4Values(properties, important); } case CSS_PROP_PADDING: // <padding-width>{1,4} | inherit { const int properties[4] = { CSS_PROP_PADDING_TOP, CSS_PROP_PADDING_RIGHT, CSS_PROP_PADDING_BOTTOM, CSS_PROP_PADDING_LEFT }; return parse4Values(properties, important); } case CSS_PROP_FONT: // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit if ( id >= CSS_VAL_CAPTION && id <= CSS_VAL_STATUS_BAR ) valid_primitive = true; else return parseFont(important);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?