Esempio n. 1
0
String Node::get_textContent()
{
	Node* child = get_firstChild();

	if (child == nullptr) return nullptr;

	if (child->get_nextSibling() == nullptr)
	{
		return child->get_textContent();
	}
	else
	{
		String str;

		while (child != nullptr)
		{
			String str2 = child->get_textContent();
			str += str2;

			child = child->get_nextSibling();
		}

		return str;
	}
}
int HTMLSelectElement::get_selectedIndex()
{
	ASSERT(0);
	return 0;
#if 0
	*pVal = -1;

	int index = 0;

	CComPtr<ILDOMNode> child;
	get_firstChild(&child);
	while (child != NULL)
	{
		LDOMNodeType nodeType;
		child->get_nodeType(&nodeType);

		if (nodeType == LNODE_ELEMENT)
		{
			CComQIPtr<ILDOMElement> element = child;

			CComBSTR tagName;
			element->get_tagName(&tagName);
			if (!wcscmp(tagName, L"option"))
			{
				CComPtr<ILDOMAttr> pAttr;
				element->getAttributeNode(L"selected", &pAttr);
				if (pAttr != NULL)
				{
					*pVal = index;
					break;
				}

				index++;
			}
		}

		CComPtr<ILDOMNode> nextSibling;
		child->get_nextSibling(&nextSibling);
		child = nextSibling;
	}

	return S_OK;
#endif
}
void HTMLSelectElement::set_selectedIndex(int newVal)
{
	int index = 0;
	ASSERT(0);
#if 0
	CComPtr<ILDOMNode> child;
	get_firstChild(&child);
	while (child != NULL)
	{
		LDOMNodeType nodeType;
		child->get_nodeType(&nodeType);

		if (nodeType == LNODE_ELEMENT)
		{
			CComQIPtr<ILDOMElement> element = child;

			CComBSTR tagName;
			element->get_tagName(&tagName);

			if (!wcscmp(tagName, L"option"))
			{
				if (index == newVal)	// Set the selected attribute
				{
					element->setAttribute(L"selected", L"selected");	// ??
				}
				else	// Remove the selected attribute (if any)
				{
					element->removeAttribute(L"selected");
				}

				index++;
			}
		}

		CComPtr<ILDOMNode> nextSibling;
		child->get_nextSibling(&nextSibling);
		child = nextSibling;
	}

	return S_OK;
#endif
}