Ejemplo n.º 1
0
void SkViewInflate::rInflate(const SkDOM& dom, const SkDOM::Node* node, SkView* parent)
{
	const char* str = dom.findAttr(node, "id");
	if (str)
		fIDs.set(str, parent);

	const SkDOM::Node* child = dom.getFirstChild(node);
	while (child)
	{
		SkView* view = this->createView(dom, child);
		if (view)
		{
			this->rInflate(dom, child, view);
			parent->attachChildToFront(view)->unref();
		}
		else
		{
			const char* name = dom.getName(child);
			const char* target;

			if (!strcmp(name, "listenTo") && (target = dom.findAttr(child, "target")) != NULL)
				this->addIDStr(&fListenTo, parent, target);

			if (!strcmp(name, "broadcastTo") && (target = dom.findAttr(child, "target")) != NULL)
				this->addIDStr(&fBroadcastTo, parent, target);
		}
		child = dom.getNextSibling(child);
	}

	parent->setVisibleP(true);
	this->inflateView(parent, dom, node);
}
Ejemplo n.º 2
0
static void write_dom(const SkDOM& dom, const SkDOM::Node* node, SkXMLWriter* w, bool skipRoot) {
    if (!skipRoot) {
        const char* elem = dom.getName(node);
        if (dom.getType(node) == SkDOM::kText_Type) {
            SkASSERT(dom.countChildren(node) == 0);
            w->addText(elem, strlen(elem));
            return;
        }

        w->startElement(elem);

        SkDOM::AttrIter iter(dom, node);
        const char* name;
        const char* value;
        while ((name = iter.next(&value)) != nullptr) {
            w->addAttribute(name, value);
        }
    }

    node = dom.getFirstChild(node, nullptr);
    while (node) {
        write_dom(dom, node, w, false);
        node = dom.getNextSibling(node, nullptr);
    }

    if (!skipRoot) {
        w->endElement();
    }
}
Ejemplo n.º 3
0
bool SkXMLParser::parse(const SkDOM& dom, const SkDOMNode* node)
{
    const char* elemName = dom.getName(node);

    if (this->startElement(elemName))
        return false;

    SkDOM::AttrIter iter(dom, node);
    const char*     name, *value;

    while ((name = iter.next(&value)) != nullptr)
        if (this->addAttribute(name, value))
            return false;

    if ((node = dom.getFirstChild(node)) != nullptr)
        do {
            if (!this->parse(dom, node))
                return false;
        } while ((node = dom.getNextSibling(node)) != nullptr);

    return !this->endElement(elemName);
}
Ejemplo n.º 4
0
static void write_dom(const SkDOM& dom, const SkDOM::Node* node, SkXMLWriter* w, bool skipRoot)
{
    if (!skipRoot)
    {
        w->startElement(dom.getName(node));

        SkDOM::AttrIter iter(dom, node);
        const char* name;
        const char* value;
        while ((name = iter.next(&value)) != NULL)
            w->addAttribute(name, value);
    }

    node = dom.getFirstChild(node, NULL);
    while (node)
    {
        write_dom(dom, node, w, false);
        node = dom.getNextSibling(node, NULL);
    }

    if (!skipRoot)
        w->endElement();
}