Beispiel #1
0
// styles are cached globally, so we only add a style if it doesn't
// exist already
static void CacheStyleFromStruct(TxtNode* def) {
    CrashIf(!def->IsStructWithName("style"));
    TxtNode* nameNode = TxtChildNodeWithKey(def, "name");
    CrashIf(!nameNode); // must have name or else no way to refer to it
    AutoFree tmp(nameNode->ValDup());
    if (StyleByName(tmp))
        return;

    Style* style = new Style();
    for (TxtNode* node = def->firstChild; node != nullptr; node = node->sibling) {
        CrashIf(!node->IsText());
        AddStyleProp(style, node);
    }
    CacheStyle(style, nullptr);
}
Beispiel #2
0
// styles are cached globally, so we only add a style if it doesn't
// exist already
static void CacheStyleFromStruct(TxtNode* def)
{
    CrashIf(!def->IsStructWithName("style"));
    TxtNode *nameNode = TxtChildNodeWithKey(def, "name");
    CrashIf(!nameNode); // must have name or else no way to refer to it
    ScopedMem<char> tmp(nameNode->ValDup());
    if (StyleByName(tmp))
        return;

    Style *style = new Style();
    size_t n = def->children->Count();
    for (size_t i = 0; i < n; i++) {
        TxtNode *node = def->children->At(i);
        CrashIf(!node->IsText());
        AddStyleProp(style, node);
    }
    CacheStyle(style, NULL);
}