コード例 #1
0
bool HtmlElement::NameIs(const char *name) const
{
    if (!this->name) {
        CrashIf(Tag_NotFound == this->tag);
        HtmlTag tag = FindHtmlTag(name, str::Len(name));
        return tag == this->tag;
    }
    return str::EqI(this->name, name);
}
コード例 #2
0
ファイル: HtmlPullParser.cpp プロジェクト: Nargesf/Sumatrapdf
void HtmlToken::SetTag(TokenType new_type, const char *new_s, const char *end)
{
    type = new_type;
    s = new_s;
    sLen = end - s;
    SkipName(new_s, s + sLen);
    nLen = new_s - s;
    tag = FindHtmlTag(s, nLen);
    nextAttr = NULL;
}
コード例 #3
0
ファイル: CssParser.cpp プロジェクト: DBNinja/sumatrapdf
const CssSelector *CssPullParser::NextSelector()
{
    if (!currSel)
        return nullptr;
    SkipWsAndComments(currSel, selEnd);
    if (currSel == selEnd)
        return nullptr;

    sel.s = currSel;
    // skip single selector
    const char *sEnd = currSel;
    while (currSel < selEnd && *currSel != ',') {
        if (*currSel == '"' || *currSel == '\'') {
            bool ok = SkipQuotedString(currSel, selEnd);
            CrashIf(!ok);
            sEnd = currSel;
        }
        else if (*currSel == '\\' && currSel < selEnd - 1) {
            currSel += 2;
            sEnd = currSel;
        }
        else if (!SkipWsAndComments(currSel, selEnd)) {
            sEnd = ++currSel;
        }
    }
    if (currSel < selEnd)
        currSel++;

    sel.sLen = sEnd - sel.s;
    sel.tag = Tag_NotFound;
    sel.clazz = nullptr;
    sel.clazzLen = 0;

    // parse "*", "el", ".class" and "el.class"
    const char *c = sEnd;
    for (; c > sel.s && (isalnum((unsigned char)*(c - 1)) || *(c - 1) == '-'); c--);
    if (c > sel.s && *(c - 1) == '.') {
        sel.clazz = c;
        sel.clazzLen = sEnd - c;
        c--;
    }
    for (; c > sel.s && (isalnum((unsigned char)*(c - 1)) || *(c - 1) == '-'); c--);
    if (sel.clazz - 1 == sel.s) {
        sel.tag = Tag_Any;
    }
    else if (c == (sel.clazz ? sel.clazz - 1 : sEnd) && c == sel.s + 1 && *sel.s == '*') {
        sel.tag = Tag_Any;
    }
    else if (c == sel.s) {
        sel.tag = FindHtmlTag(sel.s, sel.clazz ? sel.clazz - sel.s - 1 : sel.sLen);
    }

    return &sel;
}