From 5f9b0fc0767a50bc5e658aa589aa71ad1f925882 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 7 Oct 2010 13:02:49 -0400 Subject: CSS part for font-variant: small-caps support (some uppercasing is done but not utf8) --- src/cssparser.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/cssparser.cc') diff --git a/src/cssparser.cc b/src/cssparser.cc index 00ba7428..23085352 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -77,6 +77,10 @@ static const char *const Css_font_style_enum_vals[] = { "normal", "italic", "oblique", NULL }; +static const char *const Css_font_variant_enum_vals[] = { + "normal", "small-caps", NULL +}; + static const char *const Css_font_weight_enum_vals[] = { "bold", "bolder", "light", "lighter", "normal", NULL }; @@ -169,7 +173,8 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { {"font-size-adjust", {CSS_TYPE_UNUSED}, NULL}, {"font-stretch", {CSS_TYPE_UNUSED}, NULL}, {"font-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_font_style_enum_vals}, - {"font-variant", {CSS_TYPE_UNUSED}, NULL}, + {"font-variant", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, + Css_font_variant_enum_vals}, {"font-weight", {CSS_TYPE_ENUM, CSS_TYPE_FONT_WEIGHT, CSS_TYPE_UNUSED}, Css_font_weight_enum_vals}, {"height", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL}, -- cgit v1.2.3 From 4bc80c00e134f96f7226f64eaa37d5c1097d00b2 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 21 Oct 2010 11:22:29 -0300 Subject: imported patch border-collapse-parsing --- dw/style.cc | 4 ++++ dw/style.hh | 8 +++++++- src/cssparser.cc | 7 ++++++- src/styleengine.cc | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src/cssparser.cc') diff --git a/dw/style.cc b/dw/style.cc index 30597af2..d315382c 100644 --- a/dw/style.cc +++ b/dw/style.cc @@ -49,6 +49,7 @@ void StyleAttrs::initValues () margin.setVal (0); borderWidth.setVal (0); padding.setVal (0); + borderCollapse = BORDER_MODEL_SEPARATE; setBorderColor (NULL); setBorderStyle (BORDER_NONE); hBorderSpacing = 0; @@ -123,6 +124,7 @@ bool StyleAttrs::equals (object::Object *other) { margin.equals (&otherAttrs->margin) && borderWidth.equals (&otherAttrs->borderWidth) && padding.equals (&otherAttrs->padding) && + borderCollapse == otherAttrs->borderCollapse && borderColor.top == otherAttrs->borderColor.top && borderColor.right == otherAttrs->borderColor.right && borderColor.bottom == otherAttrs->borderColor.bottom && @@ -158,6 +160,7 @@ int StyleAttrs::hashValue () { margin.hashValue () + borderWidth.hashValue () + padding.hashValue () + + borderCollapse + (intptr_t) borderColor.top + (intptr_t) borderColor.right + (intptr_t) borderColor.bottom + @@ -246,6 +249,7 @@ void Style::copyAttrs (StyleAttrs *attrs) margin = attrs->margin; borderWidth = attrs->borderWidth; padding = attrs->padding; + borderCollapse = attrs->borderCollapse; borderColor = attrs->borderColor; borderStyle = attrs->borderStyle; display = attrs->display; diff --git a/dw/style.hh b/dw/style.hh index 33d42c29..0fbd2a84 100644 --- a/dw/style.hh +++ b/dw/style.hh @@ -193,7 +193,7 @@ namespace core { namespace style { enum Cursor { - CURSOR_COSSHAIR, + CURSOR_CROSSHAIR, CURSOR_DEFAULT, CURSOR_POINTER, CURSOR_MOVE, @@ -210,6 +210,11 @@ enum Cursor { CURSOR_HELP }; +enum BorderCollapse { + BORDER_MODEL_SEPARATE, + BORDER_MODEL_COLLAPSE +}; + enum BorderStyle { BORDER_NONE, BORDER_HIDDEN, @@ -435,6 +440,7 @@ public: Length width, height, lineHeight; Box margin, borderWidth, padding; + BorderCollapse borderCollapse; struct { Color *top, *right, *bottom, *left; } borderColor; struct { BorderStyle top, right, bottom, left; } borderStyle; diff --git a/src/cssparser.cc b/src/cssparser.cc index 23085352..e9de3aaf 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -47,6 +47,10 @@ typedef struct { const char *const *enum_symbols; } CssPropertyInfo; +static const char *const Css_border_collapse_enum_vals[] = { + "separate", "collapse", NULL +}; + static const char *const Css_border_style_enum_vals[] = { "none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset", NULL @@ -137,7 +141,8 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { Css_border_style_enum_vals}, {"border-bottom-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, Css_border_width_enum_vals}, - {"border-collapse", {CSS_TYPE_UNUSED}, NULL}, + {"border-collapse", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, + Css_border_collapse_enum_vals}, {"border-left-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL}, {"border-left-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_border_style_enum_vals}, diff --git a/src/styleengine.cc b/src/styleengine.cc index 62ba60d7..a381b1c6 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -434,6 +434,9 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props) { //attrs->backgroundColor = Color::create(layout, 0xdcd1ba); attrs->backgroundColor = Color::create(layout, 0xe0e0a3); break; + case CSS_PROPERTY_BORDER_COLLAPSE: + attrs->borderCollapse = (BorderCollapse) p->value.intVal; + break; case CSS_PROPERTY_BORDER_TOP_COLOR: attrs->borderColor.top = Color::create (layout, p->value.intVal); -- cgit v1.2.3 From 8dde7d0eb570d424043585f644fd69f0721fff87 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 9 Nov 2010 00:18:56 +0000 Subject: css text-indent property thread: http://lists.auriga.wearlab.de/pipermail/dillo-dev/2010-November/007801.html --- dw/style.cc | 4 ++++ dw/style.hh | 2 +- dw/textblock.cc | 10 +++++++++- src/cssparser.cc | 2 +- src/styleengine.cc | 3 +++ 5 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src/cssparser.cc') diff --git a/dw/style.cc b/dw/style.cc index 30597af2..48f98ef8 100644 --- a/dw/style.cc +++ b/dw/style.cc @@ -46,6 +46,7 @@ void StyleAttrs::initValues () valign = VALIGN_BASELINE; backgroundColor = NULL; width = height = lineHeight = LENGTH_AUTO; + textIndent = 0; margin.setVal (0); borderWidth.setVal (0); padding.setVal (0); @@ -120,6 +121,7 @@ bool StyleAttrs::equals (object::Object *other) { width == otherAttrs->width && height == otherAttrs->height && lineHeight == otherAttrs->lineHeight && + textIndent == otherAttrs->textIndent && margin.equals (&otherAttrs->margin) && borderWidth.equals (&otherAttrs->borderWidth) && padding.equals (&otherAttrs->padding) && @@ -155,6 +157,7 @@ int StyleAttrs::hashValue () { width + height + lineHeight + + textIndent + margin.hashValue () + borderWidth.hashValue () + padding.hashValue () + @@ -243,6 +246,7 @@ void Style::copyAttrs (StyleAttrs *attrs) width = attrs->width; height = attrs->height; lineHeight = attrs->lineHeight; + textIndent = attrs->textIndent; margin = attrs->margin; borderWidth = attrs->borderWidth; padding = attrs->padding; diff --git a/dw/style.hh b/dw/style.hh index 33d42c29..9dbdfc46 100644 --- a/dw/style.hh +++ b/dw/style.hh @@ -432,7 +432,7 @@ public: char textAlignChar; /* In future, strings will be supported. */ int hBorderSpacing, vBorderSpacing, wordSpacing; - Length width, height, lineHeight; + Length width, height, lineHeight, textIndent; Box margin, borderWidth, padding; struct { Color *top, *right, *bottom, *left; } borderColor; diff --git a/dw/textblock.cc b/dw/textblock.cc index 81fbcb69..af3d1cb0 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -890,7 +890,15 @@ void Textblock::wordWrap(int wordIndex) line1Offset + word->size.width > availWidth) { line1OffsetEff = 0; } else { - line1OffsetEff = line1Offset; + int indent = 0; + + if (core::style::isPerLength(getStyle()->textIndent)) { + indent = misc::roundInt(this->availWidth * + core::style::perLengthVal (getStyle()->textIndent)); + } else { + indent = core::style::absLengthVal (getStyle()->textIndent); + } + line1OffsetEff = line1Offset + indent; } } diff --git a/src/cssparser.cc b/src/cssparser.cc index 23085352..233d3956 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -213,7 +213,7 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { {"text-align", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_text_align_enum_vals}, {"text-decoration", {CSS_TYPE_MULTI_ENUM, CSS_TYPE_UNUSED}, Css_text_decoration_enum_vals}, - {"text-indent", {CSS_TYPE_UNUSED}, NULL}, + {"text-indent", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL}, {"text-shadow", {CSS_TYPE_UNUSED}, NULL}, {"text-transform", {CSS_TYPE_UNUSED}, NULL}, {"top", {CSS_TYPE_UNUSED}, NULL}, diff --git a/src/styleengine.cc b/src/styleengine.cc index 62ba60d7..bb86ce4d 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -544,6 +544,9 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props) { case CSS_PROPERTY_TEXT_DECORATION: attrs->textDecoration |= p->value.intVal; break; + case CSS_PROPERTY_TEXT_INDENT: + computeLength (&attrs->textIndent, p->value.intVal, attrs->font); + break; case CSS_PROPERTY_VERTICAL_ALIGN: attrs->valign = (VAlignType) p->value.intVal; break; -- cgit v1.2.3 From 8aaf8bbcc18ca3748809fede4773b19b04135f94 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 15 Nov 2010 23:00:10 +0100 Subject: fix bug comment handling of CssParser The skipString() method of CssParser was eating one char too much in case of a match. This caused e.g. empty comments (/**/) to be misinterpreted. Noticed and tracked down by: Jeremy Henty --- src/cssparser.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/cssparser.cc') diff --git a/src/cssparser.cc b/src/cssparser.cc index 66bf8340..7d5e3ae3 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -447,21 +447,21 @@ void CssParser::ungetChar() /* * Skip string str if it is found in the input buffer. + * If string is found leave bufptr pointing to last matched char. * If not wind back. The first char is passed as parameter c * to avoid unnecessary getChar() / ungetChar() calls. */ inline bool CssParser::skipString(int c, const char *str) { - int n = 0; + for (int n = 0; str[n]; n++) { + if (n > 0) + c = getChar(); - while (str[n]) { if (str[n] != c) { while (n--) ungetChar(); return false; } - c = getChar(); - n++; } return true; -- cgit v1.2.3 From 80e2bcf67331dc18a2776f98e7103bbeb70cd667 Mon Sep 17 00:00:00 2001 From: Jeremy Henty Date: Sun, 21 Nov 2010 21:11:37 +0000 Subject: imported patch ignore-unknown-at-rules-0 --- src/cssparser.cc | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'src/cssparser.cc') diff --git a/src/cssparser.cc b/src/cssparser.cc index 7d5e3ae3..ed880d17 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -1416,32 +1416,26 @@ void CssParser::parseImport(DilloHtml *html, DilloUrl *baseUrl) { char *urlStr = NULL; - if (html != NULL && - ttype == CSS_TK_SYMBOL && - dStrcasecmp(tval, "import") == 0) { - nextToken(); - - if (ttype == CSS_TK_SYMBOL && - dStrcasecmp(tval, "url") == 0) - urlStr = parseUrl(); - else if (ttype == CSS_TK_STRING) - urlStr = dStrdup (tval); + if (ttype == CSS_TK_SYMBOL && + dStrcasecmp(tval, "url") == 0) + urlStr = parseUrl(); + else if (ttype == CSS_TK_STRING) + urlStr = dStrdup (tval); - /* Skip all tokens until the expected end. */ - while (!(ttype == CSS_TK_END || + /* Skip all tokens until the expected end. */ + while (!(ttype == CSS_TK_END || (ttype == CSS_TK_CHAR && (tval[0] == ';')))) - nextToken(); - nextToken(); - if (urlStr) { - MSG("CssParser::parseImport(): @import %s\n", urlStr); - DilloUrl *url = a_Html_url_new (html, urlStr, a_Url_str(baseUrl), - baseUrl ? 1 : 0); - a_Html_load_stylesheet(html, url); - a_Url_free(url); - dFree (urlStr); - } + nextToken(); + + if (urlStr) { + MSG("CssParser::parseImport(): @import %s\n", urlStr); + DilloUrl *url = a_Html_url_new (html, urlStr, a_Url_str(baseUrl), + baseUrl ? 1 : 0); + a_Html_load_stylesheet(html, url); + a_Url_free(url); + dFree (urlStr); } } @@ -1458,7 +1452,12 @@ void CssParser::parse(DilloHtml *html, DilloUrl *url, CssContext * context, while (parser.ttype == CSS_TK_CHAR && parser.tval[0] == '@') { parser.nextToken(); - parser.parseImport(html, url); + if (html != NULL && + parser.ttype == CSS_TK_SYMBOL && + dStrcasecmp(parser.tval, "import") == 0) { + parser.nextToken(); + parser.parseImport(html, url); + } } while (parser.ttype != CSS_TK_END) -- cgit v1.2.3 From f74781ad9083b1483f423cc8e87220c9361d7dfa Mon Sep 17 00:00:00 2001 From: Jeremy Henty Date: Sun, 21 Nov 2010 21:11:37 +0000 Subject: imported patch ignore-unknown-at-rules-1 --- src/cssparser.cc | 63 ++++++++++++++++++++++++++++++++++++++++++++++++-------- src/cssparser.hh | 2 ++ 2 files changed, 56 insertions(+), 9 deletions(-) (limited to 'src/cssparser.cc') diff --git a/src/cssparser.cc b/src/cssparser.cc index ed880d17..ec7cb29b 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -1443,25 +1443,70 @@ const char * CssParser::propertyNameString(CssPropertyName name) { return Css_property_info[name].symbol; } + +void CssParser::ignoreBlock() +{ + int depth = 0; + + while (ttype != CSS_TK_END) { + if (ttype == CSS_TK_CHAR) { + if (tval[0] =='{') + depth++; + else if (tval[0] =='}') { + depth--; + if (depth == 0) { + nextToken(); + return; + } + } + } + nextToken(); + } +} + +void CssParser::ignoreStatement() +{ + while (ttype != CSS_TK_END) { + if (ttype == CSS_TK_CHAR) { + if (tval[0] == ';') { + nextToken(); + return; + } + else if (tval[0] =='{') { + ignoreBlock(); + return; + } + } + nextToken(); + } +} void CssParser::parse(DilloHtml *html, DilloUrl *url, CssContext * context, const char *buf, int buflen, CssOrigin origin) { CssParser parser (context, origin, buf, buflen); + bool importsAreAllowed = true; - while (parser.ttype == CSS_TK_CHAR && parser.tval[0] == '@') { - parser.nextToken(); - if (html != NULL && - parser.ttype == CSS_TK_SYMBOL && - dStrcasecmp(parser.tval, "import") == 0) { + while (parser.ttype != CSS_TK_END) { + if (parser.ttype == CSS_TK_CHAR && + parser.tval[0] == '@') { parser.nextToken(); - parser.parseImport(html, url); + if (parser.ttype == CSS_TK_SYMBOL && + dStrcasecmp(parser.tval, "import") == 0 && + html != NULL && + importsAreAllowed) { + parser.nextToken(); + parser.parseImport(html, url); + } + else + parser.ignoreStatement(); + } + else { + importsAreAllowed = false; + parser.parseRuleset(); } } - - while (parser.ttype != CSS_TK_END) - parser.parseRuleset(); } CssPropertyList *CssParser::parseDeclarationBlock(const char *buf, int buflen) diff --git a/src/cssparser.hh b/src/cssparser.hh index 1e471c68..9d3feeaf 100644 --- a/src/cssparser.hh +++ b/src/cssparser.hh @@ -42,6 +42,8 @@ class CssParser { void parseImport(DilloHtml *html, DilloUrl *url); CssSelector *parseSelector(); void parseRuleset(); + void ignoreBlock(); + void ignoreStatement(); public: static CssPropertyList *parseDeclarationBlock(const char *buf, -- cgit v1.2.3 From 8ae5ddd57599119b3337d91d375fb2220ae83e1c Mon Sep 17 00:00:00 2001 From: Jeremy Henty Date: Fri, 26 Nov 2010 11:07:10 +0000 Subject: Support @media rules. --- src/cssparser.cc | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++------ src/cssparser.hh | 1 + 2 files changed, 56 insertions(+), 6 deletions(-) (limited to 'src/cssparser.cc') diff --git a/src/cssparser.cc b/src/cssparser.cc index ec7cb29b..148b52cf 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -1439,6 +1439,48 @@ void CssParser::parseImport(DilloHtml *html, DilloUrl *baseUrl) } } +void CssParser::parseMedia() +{ + bool mediaSyntaxIsOK = false; + bool mediaIsSelected = false; + + /* parse a comma-separated list of media */ + while (ttype == CSS_TK_SYMBOL) { + if (dStrcasecmp(tval, "all") == 0 || + dStrcasecmp(tval, "screen") == 0) + mediaIsSelected = true; + nextToken(); + if (ttype == CSS_TK_CHAR && tval[0] == ',') + nextToken(); + else { + mediaSyntaxIsOK = true; + break; + } + } + + /* check that the syntax is OK so far */ + if (!(mediaSyntaxIsOK && + ttype == CSS_TK_CHAR && + tval[0] == '{')) { + ignoreStatement(); + return; + } + + /* parse/ignore the block as required */ + if (mediaIsSelected) { + nextToken(); + while (ttype != CSS_TK_END) { + parseRuleset(); + if (ttype == CSS_TK_CHAR && tval[0] == '}') { + nextToken(); + break; + } + } + } + else + ignoreBlock(); +} + const char * CssParser::propertyNameString(CssPropertyName name) { return Css_property_info[name].symbol; @@ -1492,12 +1534,19 @@ void CssParser::parse(DilloHtml *html, DilloUrl *url, CssContext * context, if (parser.ttype == CSS_TK_CHAR && parser.tval[0] == '@') { parser.nextToken(); - if (parser.ttype == CSS_TK_SYMBOL && - dStrcasecmp(parser.tval, "import") == 0 && - html != NULL && - importsAreAllowed) { - parser.nextToken(); - parser.parseImport(html, url); + if (parser.ttype == CSS_TK_SYMBOL) { + if (dStrcasecmp(parser.tval, "import") == 0 && + html != NULL && + importsAreAllowed) { + parser.nextToken(); + parser.parseImport(html, url); + } + else if (dStrcasecmp(parser.tval, "media") == 0) { + parser.nextToken(); + parser.parseMedia(); + } + else + parser.ignoreStatement(); } else parser.ignoreStatement(); diff --git a/src/cssparser.hh b/src/cssparser.hh index 9d3feeaf..1542405d 100644 --- a/src/cssparser.hh +++ b/src/cssparser.hh @@ -40,6 +40,7 @@ class CssParser { bool parseSimpleSelector(CssSimpleSelector *selector); char *parseUrl(); void parseImport(DilloHtml *html, DilloUrl *url); + void parseMedia(); CssSelector *parseSelector(); void parseRuleset(); void ignoreBlock(); -- cgit v1.2.3 From 8d45245bc03c7188359110020288a835f131f900 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 26 Nov 2010 10:47:21 -0300 Subject: minor bracket style normalization for "else" clauses --- src/cssparser.cc | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'src/cssparser.cc') diff --git a/src/cssparser.cc b/src/cssparser.cc index 148b52cf..c9cd1327 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -669,9 +669,9 @@ bool CssParser::tokenMatchesProperty(CssPropertyName prop, CssValueType *type) case CSS_TYPE_MULTI_ENUM: if (ttype == CSS_TK_SYMBOL) { - if (dStrcasecmp(tval, "none") == 0) - return true; - else { + if (dStrcasecmp(tval, "none") == 0) { + return true; + } else { for (i = 0; Css_property_info[prop].enum_symbols[i]; i++) { if (dStrcasecmp(tval, Css_property_info[prop].enum_symbols[i]) == 0) @@ -1450,9 +1450,9 @@ void CssParser::parseMedia() dStrcasecmp(tval, "screen") == 0) mediaIsSelected = true; nextToken(); - if (ttype == CSS_TK_CHAR && tval[0] == ',') + if (ttype == CSS_TK_CHAR && tval[0] == ',') { nextToken(); - else { + } else { mediaSyntaxIsOK = true; break; } @@ -1476,8 +1476,7 @@ void CssParser::parseMedia() break; } } - } - else + } else ignoreBlock(); } @@ -1492,9 +1491,9 @@ void CssParser::ignoreBlock() while (ttype != CSS_TK_END) { if (ttype == CSS_TK_CHAR) { - if (tval[0] =='{') + if (tval[0] == '{') { depth++; - else if (tval[0] =='}') { + } else if (tval[0] == '}') { depth--; if (depth == 0) { nextToken(); @@ -1513,8 +1512,7 @@ void CssParser::ignoreStatement() if (tval[0] == ';') { nextToken(); return; - } - else if (tval[0] =='{') { + } else if (tval[0] =='{') { ignoreBlock(); return; } @@ -1540,18 +1538,16 @@ void CssParser::parse(DilloHtml *html, DilloUrl *url, CssContext * context, importsAreAllowed) { parser.nextToken(); parser.parseImport(html, url); - } - else if (dStrcasecmp(parser.tval, "media") == 0) { + } else if (dStrcasecmp(parser.tval, "media") == 0) { parser.nextToken(); parser.parseMedia(); - } - else + } else { parser.ignoreStatement(); - } - else + } + } else { parser.ignoreStatement(); - } - else { + } + } else { importsAreAllowed = false; parser.parseRuleset(); } -- cgit v1.2.3 From a1710b89ec0879331799d56f56521e4579508a69 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 14 Dec 2010 21:29:02 +0000 Subject: border-color: transparent --- src/cssparser.cc | 16 ++++++++++++---- src/styleengine.cc | 30 +++++++++++++++++------------- 2 files changed, 29 insertions(+), 17 deletions(-) (limited to 'src/cssparser.cc') diff --git a/src/cssparser.cc b/src/cssparser.cc index c9cd1327..16efc487 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -51,6 +51,10 @@ static const char *const Css_border_collapse_enum_vals[] = { "separate", "collapse", NULL }; +static const char *const Css_border_color_enum_vals[] = { + "transparent", NULL +}; + static const char *const Css_border_style_enum_vals[] = { "none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset", NULL @@ -136,25 +140,29 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { {"background-image", {CSS_TYPE_UNUSED}, NULL}, {"background-position", {CSS_TYPE_UNUSED}, NULL}, {"background-repeat", {CSS_TYPE_UNUSED}, NULL}, - {"border-bottom-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL}, + {"border-bottom-color", {CSS_TYPE_ENUM, CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, + Css_border_color_enum_vals}, {"border-bottom-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_border_style_enum_vals}, {"border-bottom-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, Css_border_width_enum_vals}, {"border-collapse", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_border_collapse_enum_vals}, - {"border-left-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL}, + {"border-left-color", {CSS_TYPE_ENUM, CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, + Css_border_color_enum_vals}, {"border-left-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_border_style_enum_vals}, {"border-left-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, Css_border_width_enum_vals}, - {"border-right-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL}, + {"border-right-color", {CSS_TYPE_ENUM, CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, + Css_border_color_enum_vals}, {"border-right-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_border_style_enum_vals}, {"border-rigth-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, Css_border_width_enum_vals}, {"border-spacing", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL}, - {"border-top-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL}, + {"border-top-color", {CSS_TYPE_ENUM, CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, + Css_border_color_enum_vals}, {"border-top-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_border_style_enum_vals}, {"border-top-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, diff --git a/src/styleengine.cc b/src/styleengine.cc index 7a297925..9e859aa0 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -234,6 +234,10 @@ void StyleEngine::preprocessAttrs (dw::core::style::StyleAttrs *attrs) { attrs->valign = stack->getRef (stack->size () - 2)->style->valign; } + attrs->borderColor.top = (Color *) -1; + attrs->borderColor.bottom = (Color *) -1; + attrs->borderColor.left = (Color *) -1; + attrs->borderColor.right = (Color *) -1; /* initial value of border-width is 'medium' */ attrs->borderWidth.top = 2; attrs->borderWidth.bottom = 2; @@ -242,14 +246,14 @@ void StyleEngine::preprocessAttrs (dw::core::style::StyleAttrs *attrs) { } void StyleEngine::postprocessAttrs (dw::core::style::StyleAttrs *attrs) { - /* if border-color is not specified use color as computed value */ - if (attrs->borderColor.top == NULL) + /* if border-color is not specified, use color as computed value */ + if (attrs->borderColor.top == (Color *) -1) attrs->borderColor.top = attrs->color; - if (attrs->borderColor.bottom == NULL) + if (attrs->borderColor.bottom == (Color *) -1) attrs->borderColor.bottom = attrs->color; - if (attrs->borderColor.left == NULL) + if (attrs->borderColor.left == (Color *) -1) attrs->borderColor.left = attrs->color; - if (attrs->borderColor.right == NULL) + if (attrs->borderColor.right == (Color *) -1) attrs->borderColor.right = attrs->color; /* computed value of border-width is 0 if border-style is 'none' or 'hidden' */ @@ -438,20 +442,20 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props) { attrs->borderCollapse = (BorderCollapse) p->value.intVal; break; case CSS_PROPERTY_BORDER_TOP_COLOR: - attrs->borderColor.top = - Color::create (layout, p->value.intVal); + attrs->borderColor.top = (p->type == CSS_TYPE_ENUM) ? NULL : + Color::create (layout, p->value.intVal); break; case CSS_PROPERTY_BORDER_BOTTOM_COLOR: - attrs->borderColor.bottom = - Color::create (layout, p->value.intVal); + attrs->borderColor.bottom = (p->type == CSS_TYPE_ENUM) ? NULL : + Color::create (layout, p->value.intVal); break; case CSS_PROPERTY_BORDER_LEFT_COLOR: - attrs->borderColor.left = - Color::create (layout, p->value.intVal); + attrs->borderColor.left = (p->type == CSS_TYPE_ENUM) ? NULL : + Color::create (layout, p->value.intVal); break; case CSS_PROPERTY_BORDER_RIGHT_COLOR: - attrs->borderColor.right = - Color::create (layout, p->value.intVal); + attrs->borderColor.right = (p->type == CSS_TYPE_ENUM) ? NULL : + Color::create (layout, p->value.intVal); break; case CSS_PROPERTY_BORDER_BOTTOM_STYLE: attrs->borderStyle.bottom = (BorderStyle) p->value.intVal; -- cgit v1.2.3 From b0bdd878746015a9c03904cea587e46f27b971c9 Mon Sep 17 00:00:00 2001 From: Jeremy Henty Date: Sat, 18 Dec 2010 17:18:13 +0000 Subject: CssParser::parseImport(): call ignoreStatement(). --- src/cssparser.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/cssparser.cc') diff --git a/src/cssparser.cc b/src/cssparser.cc index 16efc487..5886a1e1 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -1430,12 +1430,7 @@ void CssParser::parseImport(DilloHtml *html, DilloUrl *baseUrl) else if (ttype == CSS_TK_STRING) urlStr = dStrdup (tval); - /* Skip all tokens until the expected end. */ - while (!(ttype == CSS_TK_END || - (ttype == CSS_TK_CHAR && (tval[0] == ';')))) - nextToken(); - - nextToken(); + ignoreStatement(); if (urlStr) { MSG("CssParser::parseImport(): @import %s\n", urlStr); -- cgit v1.2.3 From a45f583b19df9a10c28717214851ae2447ab13b9 Mon Sep 17 00:00:00 2001 From: Jeremy Henty Date: Sat, 18 Dec 2010 17:18:13 +0000 Subject: cssparser.cc: move some calls to nextToken(). --- src/cssparser.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/cssparser.cc') diff --git a/src/cssparser.cc b/src/cssparser.cc index 5886a1e1..16fcdf03 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -1424,6 +1424,8 @@ void CssParser::parseImport(DilloHtml *html, DilloUrl *baseUrl) { char *urlStr = NULL; + nextToken(); + if (ttype == CSS_TK_SYMBOL && dStrcasecmp(tval, "url") == 0) urlStr = parseUrl(); @@ -1447,6 +1449,8 @@ void CssParser::parseMedia() bool mediaSyntaxIsOK = false; bool mediaIsSelected = false; + nextToken(); + /* parse a comma-separated list of media */ while (ttype == CSS_TK_SYMBOL) { if (dStrcasecmp(tval, "all") == 0 || @@ -1539,10 +1543,8 @@ void CssParser::parse(DilloHtml *html, DilloUrl *url, CssContext * context, if (dStrcasecmp(parser.tval, "import") == 0 && html != NULL && importsAreAllowed) { - parser.nextToken(); parser.parseImport(html, url); } else if (dStrcasecmp(parser.tval, "media") == 0) { - parser.nextToken(); parser.parseMedia(); } else { parser.ignoreStatement(); -- cgit v1.2.3 From c35be8734a8fa8e80e247037530b9b7d39cf1a53 Mon Sep 17 00:00:00 2001 From: Jeremy Henty Date: Sat, 18 Dec 2010 17:18:13 +0000 Subject: CssParser::parseImport(): implement media-conditional @import rules. --- src/cssparser.cc | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'src/cssparser.cc') diff --git a/src/cssparser.cc b/src/cssparser.cc index 16fcdf03..aa4cea56 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -1423,6 +1423,9 @@ char * CssParser::parseUrl() void CssParser::parseImport(DilloHtml *html, DilloUrl *baseUrl) { char *urlStr = NULL; + bool importSyntaxIsOK = false; + bool mediaSyntaxIsOK = true; + bool mediaIsSelected = true; nextToken(); @@ -1432,14 +1435,42 @@ void CssParser::parseImport(DilloHtml *html, DilloUrl *baseUrl) else if (ttype == CSS_TK_STRING) urlStr = dStrdup (tval); - ignoreStatement(); + nextToken(); + + /* parse a comma-separated list of media */ + if (ttype == CSS_TK_SYMBOL) { + mediaSyntaxIsOK = false; + mediaIsSelected = false; + while (ttype == CSS_TK_SYMBOL) { + if (dStrcasecmp(tval, "all") == 0 || + dStrcasecmp(tval, "screen") == 0) + mediaIsSelected = true; + nextToken(); + if (ttype == CSS_TK_CHAR && tval[0] == ',') { + nextToken(); + } else { + mediaSyntaxIsOK = true; + break; + } + } + } + + if (mediaSyntaxIsOK && + ttype == CSS_TK_CHAR && + tval[0] == ';') { + importSyntaxIsOK = true; + nextToken(); + } else + ignoreStatement(); if (urlStr) { - MSG("CssParser::parseImport(): @import %s\n", urlStr); - DilloUrl *url = a_Html_url_new (html, urlStr, a_Url_str(baseUrl), - baseUrl ? 1 : 0); - a_Html_load_stylesheet(html, url); - a_Url_free(url); + if (importSyntaxIsOK && mediaIsSelected) { + MSG("CssParser::parseImport(): @import %s\n", urlStr); + DilloUrl *url = a_Html_url_new (html, urlStr, a_Url_str(baseUrl), + baseUrl ? 1 : 0); + a_Html_load_stylesheet(html, url); + a_Url_free(url); + } dFree (urlStr); } } -- cgit v1.2.3