NS_IMETHODIMP
nsHTMLLegendElement::GetForm(nsIDOMHTMLFormElement** aForm)
{
  Element* form = GetFormElement();

  return form ? CallQueryInterface(form, aForm) : NS_OK;
}
예제 #2
0
//	Function to create and/or retrieve a CFormElement from
//		a layout form struct.
CFormElement *CFormElement::GetFormElement(CAbstractCX *pCX, LO_FormElementStruct *pFormElement)
{
	CFormElement *pRetval = NULL;

	//	Ensure we have enough information with which to continue.
	if(pCX == NULL)	{
		return(pRetval);
	}
	else if(pFormElement == NULL)	{
		return(pRetval);
	}

	pRetval = GetFormElement(pCX, pFormElement->element_data);

	//	Look at the form element structure to see if one already exists.
	if(pRetval == NULL && pFormElement->element_data != NULL)	{
		//	We need to create a new form class.
		TRY	{
			switch(pFormElement->element_data->type)	{
				case FORM_TYPE_TEXT:
				case FORM_TYPE_PASSWORD:
					pRetval = (CFormElement *)new CFormText();
					break;
				case FORM_TYPE_CHECKBOX:
				case FORM_TYPE_RADIO:
					pRetval = (CFormElement *)new CFormRadio();
					break;
				case FORM_TYPE_BUTTON:
				case FORM_TYPE_RESET:
				case FORM_TYPE_SUBMIT:
					pRetval = (CFormElement *)new CFormButton();
					break;
				case FORM_TYPE_SELECT_ONE:
					pRetval = (CFormElement *)new CFormSelectOne();
					break;
				case FORM_TYPE_SELECT_MULT:
					pRetval = (CFormElement *)new CFormSelectMult();
					break;
				case FORM_TYPE_TEXTAREA:
					pRetval = (CFormElement *)new CFormTextarea();
					break;
				case FORM_TYPE_FILE:
					pRetval = (CFormElement *)new CFormFile();
					break;
				case FORM_TYPE_READONLY:
					pRetval = (CFormElement *)new CFormReadOnly();
					break;
				default:
					//	What exactly are we doing here?
					TRACE("Unimplemented form type (%d) requested.\n", (int)pFormElement->element_data->type);
					pRetval = NULL;
					break;
			}
		}
		CATCH(CException, e)	{
			pRetval = NULL;
		}
		END_CATCH
	}
already_AddRefed<nsHTMLFormElement>
HTMLLegendElement::GetForm()
{
  Element* form = GetFormElement();
  MOZ_ASSERT_IF(form, form->IsHTML(nsGkAtoms::form));
  nsRefPtr<nsHTMLFormElement> ret = static_cast<nsHTMLFormElement*>(form);
  return ret.forget();
}