cssparser.cpp
来自「将konqueror浏览器移植到ARM9 2410中」· C++ 代码 · 共 2,040 行 · 第 1/5 页
CPP
2,040 行
} break; } case CSS_PROP_PADDING_TOP: //// <padding-width> | inherit case CSS_PROP_PADDING_RIGHT: // Which is defined as case CSS_PROP_PADDING_BOTTOM: // <length> | <percentage> case CSS_PROP_PADDING_LEFT: //// { parsedValue = parseUnit(curP, endP, LENGTH | PERCENT|NONNEGATIVE); break; } case CSS_PROP_TEXT_INDENT: // <length> | <percentage> | inherit case CSS_PROP_MIN_HEIGHT: // <length> | <percentage> | inherit case CSS_PROP_MIN_WIDTH: // <length> | <percentage> | inherit { parsedValue = parseUnit(curP, endP, LENGTH | PERCENT); break; } case CSS_PROP_FONT_SIZE: // <absolute-size> | <relative-size> | <length> | <percentage> | inherit { if (cssval) { int id = cssval->id; if (id >= CSS_VAL_XX_SMALL && id <= CSS_VAL_LARGER) { parsedValue = new CSSPrimitiveValueImpl(id); break; } } else { parsedValue = parseUnit(curP, endP, LENGTH | PERCENT | NONNEGATIVE); } break; } case CSS_PROP_FONT_STYLE: // normal | italic | oblique | inherit { if (cssval) { int id = cssval->id; if ( id == CSS_VAL_NORMAL || id == CSS_VAL_ITALIC || id == CSS_VAL_OBLIQUE) { parsedValue = new CSSPrimitiveValueImpl(id); } } break; } case CSS_PROP_FONT_VARIANT: // normal | small-caps | inherit { if (cssval) { int id = cssval->id; if ( id == CSS_VAL_NORMAL || id == CSS_VAL_SMALL_CAPS) { parsedValue = new CSSPrimitiveValueImpl(id); } } break; } case CSS_PROP_VERTICAL_ALIGN: // baseline | sub | super | top | text-top | middle | bottom | text-bottom | // <percentage> | <length> | inherit { if (cssval) { int id = cssval->id; if ( id >= CSS_VAL_BASELINE && id <= CSS_VAL__KONQ_BASELINE_MIDDLE ) { parsedValue = new CSSPrimitiveValueImpl(id); } } else { parsedValue = parseUnit(curP, endP, LENGTH | PERCENT ); } break; } case CSS_PROP_MAX_HEIGHT: // <length> | <percentage> | none | inherit case CSS_PROP_MAX_WIDTH: // <length> | <percentage> | none | inherit { if (cssval && cssval->id == CSS_VAL_NONE) { parsedValue = new CSSPrimitiveValueImpl(cssval->id); } else { parsedValue = parseUnit(curP, endP, LENGTH | PERCENT ); } break; } case CSS_PROP_HEIGHT: // <length> | <percentage> | auto | inherit case CSS_PROP_WIDTH: // <length> | <percentage> | auto | inherit { if (cssval && cssval->id == CSS_VAL_AUTO) { parsedValue = new CSSPrimitiveValueImpl(cssval->id); } else { parsedValue = parseUnit(curP, endP, LENGTH | PERCENT | NONNEGATIVE ); } 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: //// { if (cssval && cssval->id == CSS_VAL_AUTO) { parsedValue = new CSSPrimitiveValueImpl(cssval->id); } else { parsedValue = parseUnit(curP, endP, LENGTH | PERCENT ); } break; } case CSS_PROP_FONT_SIZE_ADJUST: // <number> | none | inherit // ### not supported later on { if (cssval && cssval->id == CSS_VAL_NONE) { parsedValue = new CSSPrimitiveValueImpl(cssval->id); } else { parsedValue = parseUnit(curP, endP, NUMBER); } break; } case CSS_PROP_Z_INDEX: // auto | <integer> | inherit { if (cssval && cssval->id == CSS_VAL_AUTO) { parsedValue = new CSSPrimitiveValueImpl(cssval->id); break; } // break explicitly missing, looking for <number> } case CSS_PROP_ORPHANS: // <integer> | inherit case CSS_PROP_WIDOWS: // <integer> | inherit // ### not supported later on { parsedValue = parseUnit(curP, endP, INTEGER); break; } case CSS_PROP_LINE_HEIGHT: // normal | <number> | <length> | <percentage> | inherit { if (cssval && cssval->id == CSS_VAL_NORMAL) { parsedValue = new CSSPrimitiveValueImpl(cssval->id); } else { parsedValue = parseUnit(curP, endP, NUMBER | LENGTH | PERCENT | NONNEGATIVE); } break; } case CSS_PROP_COUNTER_INCREMENT: // [ <identifier> <integer>? ]+ | none | inherit case CSS_PROP_COUNTER_RESET: // [ <identifier> <integer>? ]+ | none | inherit { if (cssval && cssval->id == CSS_VAL_NONE) { parsedValue = new CSSPrimitiveValueImpl(cssval->id); } else { CSSValueListImpl *list = new CSSValueListImpl; int pos=0, pos2; while( 1 ) { pos2 = value.find(',', pos); QString face = value.mid(pos, pos2-pos); face = face.stripWhiteSpace(); if(face.length() == 0) break; // ### single quoted is missing... if(face[0] == '\"') face.remove(0, 1); if(face[face.length()-1] == '\"') face = face.left(face.length()-1); //kdDebug( 6080 ) << "found face '" << face << "'" << endl; list->append(new CSSPrimitiveValueImpl(DOMString(face), CSSPrimitiveValue::CSS_STRING)); pos = pos2 + 1; if(pos2 == -1) break; } //kdDebug( 6080 ) << "got " << list->length() << " faces" << endl; if(list->length()) parsedValue = list; else delete list; break; } } case CSS_PROP_FONT_FAMILY: // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit { CSSValueListImpl *list = new CSSValueListImpl; // css2 compatible parsing... FontParser fp; fp.startTokenizer( value, strictParsing ); QStringList families; if ( !fp.matchFontFamily( &families ) ) return false; for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) { if( *it != QString::null ) { list->append(new CSSPrimitiveValueImpl(DOMString(*it), CSSPrimitiveValue::CSS_STRING)); //kdDebug() << "StyleBaseImpl::parsefont: family='" << *it << "'" << endl; } } //kdDebug( 6080 ) << "got " << list->length() << " faces" << endl; if(list->length()) parsedValue = list; else delete list; break; } case CSS_PROP_TEXT_DECORATION: // none | [ underline || overline || line-through || blink ] | inherit { if (cssval) { if (cssval->id == CSS_VAL_NONE) { parsedValue = new CSSPrimitiveValueImpl(cssval->id); } else { CSSValueListImpl *list = new CSSValueListImpl; value.simplifyWhiteSpace(); //kdDebug( 6080 ) << "text-decoration: '" << str << "'" << endl; int pos=0, pos2; while( 1 ) { pos2 = value.find(' ', pos); QString decoration = value.mid(pos, pos2-pos); decoration = decoration.stripWhiteSpace(); //kdDebug( 6080 ) << "found decoration '" << decoration << "'" << endl; const struct css_value *cssval = findValue(decoration.lower().ascii(), decoration.length()); if (cssval) { list->append(new CSSPrimitiveValueImpl(cssval->id)); } pos = pos2 + 1; if(pos2 == -1) break; } //kdDebug( 6080 ) << "got " << list->length() << "d decorations" << endl; if(list->length()) { parsedValue = list; } else { delete list; } } } break; } case CSS_PROP__KONQ_FLOW_MODE: { if (cssval->id==CSS_VAL__KONQ_NORMAL || cssval->id==CSS_VAL__KONQ_AROUND_FLOATS) parsedValue = new CSSPrimitiveValueImpl(cssval->id); break; } /* shorthand properties */ case CSS_PROP_BACKGROUND: // ['background-color' || 'background-image' ||'background-repeat' || // 'background-attachment' || 'background-position'] | inherit {#ifdef CSS_DEBUG_BCKGR kdDebug(6080) << "CSS_PROP_BACKGROUND" << endl;#endif const int properties[5] = { CSS_PROP_BACKGROUND_COLOR, CSS_PROP_BACKGROUND_IMAGE, CSS_PROP_BACKGROUND_REPEAT, CSS_PROP_BACKGROUND_ATTACHMENT, CSS_PROP_BACKGROUND_POSITION}; return parseShortHand(curP, endP, properties, 5); //return parseBackground(curP, endP); } 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(curP, endP, properties, 3); } 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(curP, endP, properties, 3); } 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(curP, endP, properties, 3); } 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(curP, endP, properties, 3); } 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(curP, endP, properties, 3); } case CSS_PROP_OUTLINE: // [ 'outline-color' || 'outline-style' || 'outline-width' ] | inherit { const int properties[3] = { CSS_PROP_OUTLINE_COLOR, CSS_PROP_OUTLINE_STYLE, CSS_PROP_OUTLINE_WIDTH }; return parseShortHand(curP, endP, properties, 3); } case CSS_PROP_BORDER_COLOR: // <color>{1,4} | transparent | inherit { const struct css_value *cssval = findValue(val, len); if (cssval && cssval->id == CSS_VAL_TRANSPARENT) { // set border colors to invalid parsedValue = new CSSPrimitiveValueImpl(CSS_VAL_TRANSPARENT); break; } 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(curP, endP, properties); } 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(curP, endP, properties); } 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(curP, endP, properties); } 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(curP, endP, properties); } 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(curP, endP, properties); } 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 { return parseFont(curP, endP); } case CSS_PROP_LIST_STYLE: { const int properties[3] = { CSS_PROP_LIST_STYLE_TYPE, CSS_PROP_LIST_STYLE_POSITION, CSS_PROP_LIST_STYLE_IMAGE }; return parseShortHand(curP, endP, properties, 3); } default: {#ifdef CSS_DEBUG kdDebug( 6080 ) << "illegal or CSS2 Aural property: " << val << endl;#endif } } } if ( parsedValue ) { setParsedValue(propId, parsedValue); return true; } else {#ifndef CSS_AURAL return false;#endif#ifdef CSS_AURAL return parseAuralValue(curP, endP, propId);#endif }}#ifdef CSS_AURAL/* parseAuralValue */bool StyleBaseImpl::parseAuralValue( const QChar *curP, const QChar *endP, int propId ){ QString value(curP, endP - curP); value = value.lower(); const char *val = value.ascii(); CSSValueImpl *parsedValue = 0; kdDebug( 6080 ) << "parseAuralValue: " << value << " val: " << val << endl; /* AURAL Properies */ switch(propId) { case CSS_PROP_AZIMUTH: // <angle> | [[ left-side | far-left | left | center-left | center | // center-right | right | far-right | right-side ] || behind ] | // leftwards | rightwards | inherit case CSS_PROP_PAUSE_AFTER: // <time> | <percentage> | inherit case CSS_PROP_PAUSE_BEFORE: // <time> | <percentage> | inherit case CSS_PROP_PAUSE: // [ [<time> | <percentage>]{1,2} ] | inherit case CSS_PROP_PLAY_DURING: // <uri> mix? repeat? | auto | none | inherit case CSS_PROP_VOICE_FAMILY: // [[<specific-voice> | <generic-voice> ],]* // [<specific-voice> | <generic-voice> ] | inherit { // ### TO BE DONE break; } case CSS_PROP_CUE: // [ 'cue-before' || 'cue-after' ] | inherit { const int properties[2] = { CSS_PROP_CUE_BEFORE, CSS_PROP_CUE_AFTER}; return parse2Values(curP, endP, properties); } case CSS_PROP_CUE_AFTER: // <uri> | none | inherit case CSS_PROP_CUE_BEFORE: // <uri> | none | inherit { const struct css_value *cssval = findValue(val, endP - curP); if (cssval) { if (cssval->id == CSS_VAL_NONE) { parsedValue = new CSSPrimitiveValueImpl(cssval->id); } } else { DOMString v
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?