Ejemplo n.º 1
0
/* virtual */ ES_PutState
DOM_HTMLDocument::PutName(OpAtom property_name, ES_Value* value, ES_Runtime* origining_runtime)
{
	ES_GetState state;
	ES_Value value2;

	switch(property_name)
	{
	case OP_ATOM_title:
		if (value->type != VALUE_STRING)
			return PUT_NEEDS_STRING;
		else
			return SetTitle(value, origining_runtime);

	case OP_ATOM_body:
		if (value->type != VALUE_OBJECT || !root)
			return DOM_PUTNAME_DOMEXCEPTION(HIERARCHY_REQUEST_ERR);
		else
			return ((DOM_HTMLElement *) root)->PutChildElement(OP_ATOM_body, value, (DOM_Runtime *) origining_runtime, NULL);

	case OP_ATOM_bgColor:
	case OP_ATOM_fgColor:
	case OP_ATOM_linkColor:
	case OP_ATOM_alinkColor:
	case OP_ATOM_vlinkColor:
		state = GetName(OP_ATOM_body, &value2, origining_runtime);
		if (state == GET_NO_MEMORY)
			return PUT_NO_MEMORY;
		else if (state == GET_SUCCESS && value2.type == VALUE_OBJECT)
		{
			DOM_Node *node = DOM_VALUE2OBJECT(value2, DOM_Node);

			if (property_name == OP_ATOM_fgColor)
				property_name = OP_ATOM_text;
			else if (property_name == OP_ATOM_linkColor)
				property_name = OP_ATOM_link;
			else if (property_name == OP_ATOM_alinkColor)
				property_name = OP_ATOM_aLink;
			else if (property_name == OP_ATOM_vlinkColor)
				property_name = OP_ATOM_vLink;

			if (value->type == VALUE_NULL)
				DOMSetString(value);

			return node->PutName(property_name, value, origining_runtime);
		}
		return PUT_SUCCESS;

	case OP_ATOM_domain:
		if (value->type != VALUE_STRING)
			return PUT_NEEDS_STRING;
		else
		{
			OP_STATUS status = GetRuntime()->SetDomainChecked(value->value.string);
			if (OpStatus::IsMemoryError(status))
				return PUT_NO_MEMORY;
			else if (OpStatus::IsError(status))
				return PUT_SECURITY_VIOLATION;
			else
				return PUT_SUCCESS;
		}

	case OP_ATOM_head:
		return PUT_SUCCESS;

	case OP_ATOM_URL:
	case OP_ATOM_images:
	case OP_ATOM_applets:
	case OP_ATOM_links:
	case OP_ATOM_embeds:
	case OP_ATOM_forms:
	case OP_ATOM_anchors:
	case OP_ATOM_compatMode:
		return PUT_READ_ONLY;
	}

	return DOM_Document::PutName (property_name, value, origining_runtime);
}