Exemplo n.º 1
0
void HtmlFormatter::HandleTagStyle(HtmlToken* t) {
    if (!t->IsStartTag())
        return;
    AttrInfo* attr = t->GetAttrByName("type");
    if (attr && !attr->ValIs("text/css"))
        return;

    const char* start = t->s + t->sLen + 1;
    while (t && !t->IsError() && (!t->IsEndTag() || t->tag != Tag_Style)) {
        t = htmlParser->Next();
    }
    if (!t || !t->IsEndTag() || Tag_Style != t->tag)
        return;
    const char* end = t->s - 2;
    CrashIf(start > end);
    ParseStyleSheet(start, end - start);
    UpdateTagNesting(t);
}
Exemplo n.º 2
0
void HtmlFileFormatter::HandleTagLink(HtmlToken *t)
{
    CrashIf(!htmlDoc);
    if (t->IsEndTag())
        return;
    AttrInfo *attr = t->GetAttrByName("rel");
    if (!attr || !attr->ValIs("stylesheet"))
        return;
    attr = t->GetAttrByName("type");
    if (attr && !attr->ValIs("text/css"))
        return;
    attr = t->GetAttrByName("href");
    if (!attr)
        return;

    size_t len;
    ScopedMem<char> src(str::DupN(attr->val, attr->valLen));
    url::DecodeInPlace(src);
    ScopedMem<char> data(htmlDoc->GetFileData(src, &len));
    if (data)
        ParseStyleSheet(data, len);
}