Ejemplo n.º 1
0
static OP_STATUS
DOM_SetBoundaryPoint(DOM_EnvironmentImpl *environment, DOM_Document *document, DOM_Range::BoundaryPoint &bp, HTML_Element *elm, unsigned offset, BOOL place_after)
{
	OP_ASSERT(elm);

	DOM_Node *node;
	RETURN_IF_ERROR(environment->ConstructNode(node, elm, document));

	if (!node->IsA(DOM_TYPE_CHARACTERDATA) && !elm->FirstChildActual())
	{
		HTML_Element *parent = elm->ParentActual();
		if (parent)
		{
			RETURN_IF_ERROR(environment->ConstructNode(bp.node, parent, document));

			bp.offset = DOM_Range::CalculateOffset(elm);
			if (place_after)
			{
				bp.offset++;
				bp.unit = NULL;
			}
			else
				bp.unit = node;

			return OpStatus::OK;
		}
	}

	bp.node = node;
	bp.offset = offset;
	bp.unit = NULL;

	return OpStatus::OK;
}