OP_STATUS Counters::AddCounterValues(OpString& counter_str, HTML_Element* element, short counter_type, const uni_char* counter_value) { if (counter_value) { const uni_char* name = counter_value; unsigned int name_length = 0; // The css parser should have stripped off the leading whitespaces. OP_ASSERT(!css_is_space(*name)); const uni_char* style = name; unsigned int style_length = 0; /* 'delimiter' corresponds to the 'string' argument of the counters function in the CSS 2.1. */ const uni_char* delimiter = NULL; unsigned int delimiter_length = 0; if (counter_type == CSS_FUNCTION_COUNTERS) { delimiter = name; while (*delimiter && !css_is_space(*delimiter) && *delimiter != ',') delimiter++; BOOL comma_found = (*delimiter == ','); name_length = delimiter++ - name; while (css_is_space(*delimiter)) delimiter++; if (!comma_found) { if (*delimiter && *delimiter != ',') return OpStatus::OK; while (css_is_space(*++delimiter)) ; } uni_char quote_char = *delimiter++; if (quote_char != '"' && quote_char != '\'') return OpStatus::OK; style = delimiter; while (*style && (*style != quote_char || *(style-1) == '\\')) style++; if (*style != quote_char) return OpStatus::OK; delimiter_length = style++ - delimiter; } else { while (*style && !css_is_space(*style) && *style != ',') style++; name_length = style - name; } while (*style && (css_is_space(*style) || *style == ',')) style++; const uni_char* end = style; while (*end && !css_is_space(*end) && *end != ',') end++; OP_ASSERT(*end == 0); style_length = end - style; short style_type = CSS_VALUE_decimal; if (*style) { short keyword = CSS_GetKeyword(style, style_length); if (CSS_is_list_style_type_val(keyword) || keyword == CSS_VALUE_none) style_type = keyword; } Counter* counter = GetCounter(name, name_length); if (counter) return counter->AddCounterValues(counter_str, element, delimiter, delimiter_length, style_type, add_only); else { uni_char number_buf[TMPSTRING_SIZE]; /* ARRAY OK 2009-05-11 davve */ MakeListNumberStr(0, style_type, NULL, number_buf, TMPSTRING_SIZE-1); //FIXME rtl?? return counter_str.Append(number_buf); } } return OpStatus::OK; }