Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsHTMLInputElement.cpp File Reference
#include "nsCOMPtr.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMNSHTMLInputElement.h"
#include "nsITextControlElement.h"
#include "nsIFileControlElement.h"
#include "nsIDOMNSEditableElement.h"
#include "nsIRadioControlElement.h"
#include "nsIRadioVisitor.h"
#include "nsIPhonetic.h"
#include "nsIControllers.h"
#include "nsIFocusController.h"
#include "nsPIDOMWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsContentCID.h"
#include "nsIComponentManager.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMEventReceiver.h"
#include "nsGenericHTMLElement.h"
#include "nsHTMLAtoms.h"
#include "nsStyleConsts.h"
#include "nsPresContext.h"
#include "nsMappedAttributes.h"
#include "nsIFormControl.h"
#include "nsIForm.h"
#include "nsIFormSubmission.h"
#include "nsITextControlFrame.h"
#include "nsIRadioControlFrame.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIFormControlFrame.h"
#include "nsIFrame.h"
#include "nsIEventStateManager.h"
#include "nsIServiceManager.h"
#include "nsIScriptSecurityManager.h"
#include "nsDOMError.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIEditor.h"
#include "nsGUIEvent.h"
#include "nsPresState.h"
#include "nsLayoutErrors.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMHTMLCollection.h"
#include "nsICheckboxControlFrame.h"
#include "nsIImageControlFrame.h"
#include "nsLinebreakConverter.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsIDOMMutationEvent.h"
#include "nsMutationEvent.h"
#include "nsRuleData.h"
#include "nsIRadioGroupContainer.h"
#include "nsIMIMEService.h"
#include "nsCExternalHandlerService.h"
#include "nsIFile.h"
#include "nsILocalFile.h"
#include "nsIFileStreams.h"
#include "nsNetUtil.h"
#include "nsImageLoadingContent.h"
#include "nsIDOMWindowInternal.h"

Go to the source code of this file.

Classes

class  nsHTMLInputElement
class  nsRadioVisitor
class  nsRadioSetCheckedChangedVisitor
class  nsRadioGetCheckedChangedVisitor

Defines

#define BF_DISABLED_CHANGED   0
#define BF_HANDLING_CLICK   1
#define BF_VALUE_CHANGED   2
#define BF_CHECKED_CHANGED   3
#define BF_CHECKED   4
#define BF_HANDLING_SELECT_EVENT   5
#define BF_SHOULD_INIT_CHECKED   6
#define BF_PARSER_CREATING   7
#define BF_IN_INTERNAL_ACTIVATE   8
#define BF_CHECKED_IS_TOGGLED   9
#define BF_SETTING_FILE_FOCUS   10
#define GET_BOOLBIT(bitfield, field)
#define SET_BOOLBIT(bitfield, field, b)

Functions

static NS_DEFINE_CID (kXULControllersCID, NS_XULCONTROLLERS_CID)
 NS_HTML_CONTENT_INTERFACE_MAP_BEGIN (nsHTMLInputElement, nsGenericHTMLFormElement) NS_HTML_CONTENT_INTERFACE_MAP_ENDnsresult nsHTMLInputElement
static void MapAttributesIntoRule (const nsMappedAttributes *aAttributes, nsRuleData *aData)
nsresult NS_GetRadioSetCheckedChangedVisitor (PRBool aCheckedChanged, nsIRadioVisitor **aVisitor)
 This visitor sets CheckedChanged on all elements it finds.
nsresult NS_GetRadioGetCheckedChangedVisitor (PRBool *aCheckedChanged, nsIFormControl *aExcludeElement, nsIRadioVisitor **aVisitor)
 This visitor will take the boolean you're pointing at and put aCheckedChanged into it.

Variables

static const char * kWhitespace = "\n\r\t\b"
static const nsAttrValue::EnumTable kInputTypeTable []

Define Documentation

#define BF_CHECKED   4

Definition at line 122 of file nsHTMLInputElement.cpp.

Definition at line 121 of file nsHTMLInputElement.cpp.

Definition at line 127 of file nsHTMLInputElement.cpp.

Definition at line 118 of file nsHTMLInputElement.cpp.

Definition at line 119 of file nsHTMLInputElement.cpp.

Definition at line 123 of file nsHTMLInputElement.cpp.

Definition at line 126 of file nsHTMLInputElement.cpp.

Definition at line 125 of file nsHTMLInputElement.cpp.

Definition at line 128 of file nsHTMLInputElement.cpp.

Definition at line 124 of file nsHTMLInputElement.cpp.

Definition at line 120 of file nsHTMLInputElement.cpp.

#define GET_BOOLBIT (   bitfield,
  field 
)
Value:
(((bitfield) & (0x01 << (field))) \
                                        ? PR_TRUE : PR_FALSE)

Definition at line 130 of file nsHTMLInputElement.cpp.

#define SET_BOOLBIT (   bitfield,
  field,
  b 
)
Value:
((b) \
                                        ? ((bitfield) |=  (0x01 << (field))) \
                                        : ((bitfield) &= ~(0x01 << (field))))

Definition at line 132 of file nsHTMLInputElement.cpp.


Function Documentation

static void MapAttributesIntoRule ( const nsMappedAttributes aAttributes,
nsRuleData aData 
) [static]

Definition at line 2030 of file nsHTMLInputElement.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static NS_DEFINE_CID ( kXULControllersCID  ,
NS_XULCONTROLLERS_CID   
) [static]
nsresult NS_GetRadioGetCheckedChangedVisitor ( PRBool aCheckedChanged,
nsIFormControl aExcludeElement,
nsIRadioVisitor **  aVisitor 
)

This visitor will take the boolean you're pointing at and put aCheckedChanged into it.

If the visitor is never called, aCheckedChanged will of course not change.

Parameters:
aVisitorthe visitor (out param)
aCheckedChangedthe boolean to put CheckedChanged into
aExcludeElementthe element

Definition at line 3113 of file nsHTMLInputElement.cpp.

{
  *aVisitor = new nsRadioGetCheckedChangedVisitor(aCheckedChanged,
                                                  aExcludeElement);
  if (!*aVisitor) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  NS_ADDREF(*aVisitor);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_GetRadioSetCheckedChangedVisitor ( PRBool  aCheckedChanged,
nsIRadioVisitor **  aVisitor 
)

This visitor sets CheckedChanged on all elements it finds.

Parameters:
aVisitorthe visitor (out param)
aCheckedChangedthe value of CheckedChanged to set on all elements

Definition at line 3058 of file nsHTMLInputElement.cpp.

{
  //
  // These are static so that we don't have to keep creating new visitors for
  // such an ordinary process all the time.  There are only two possibilities
  // for this visitor: set to true, and set to false.
  //
  static nsIRadioVisitor* sVisitorTrue = nsnull;
  static nsIRadioVisitor* sVisitorFalse = nsnull;

  //
  // Get the visitor that sets them to true
  //
  if (aCheckedChanged) {
    if (!sVisitorTrue) {
      sVisitorTrue = new nsRadioSetCheckedChangedVisitor(PR_TRUE);
      if (!sVisitorTrue) {
        return NS_ERROR_OUT_OF_MEMORY;
      }
      NS_ADDREF(sVisitorTrue);
      nsresult rv =
        nsContentUtils::ReleasePtrOnShutdown((nsISupports**)&sVisitorTrue);
      if (NS_FAILED(rv)) {
        NS_RELEASE(sVisitorTrue);
        return rv;
      }
    }
    *aVisitor = sVisitorTrue;
  }
  //
  // Get the visitor that sets them to false
  //
  else {
    if (!sVisitorFalse) {
      sVisitorFalse = new nsRadioSetCheckedChangedVisitor(PR_FALSE);
      if (!sVisitorFalse) {
        return NS_ERROR_OUT_OF_MEMORY;
      }
      NS_ADDREF(sVisitorFalse);
      nsresult rv =
        nsContentUtils::ReleasePtrOnShutdown((nsISupports**)&sVisitorFalse);
      if (NS_FAILED(rv)) {
        NS_RELEASE(sVisitorFalse);
        return rv;
      }
    }
    *aVisitor = sVisitorFalse;
  }

  NS_ADDREF(*aVisitor);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 407 of file nsHTMLInputElement.cpp.

{
  *aReturn = nsnull;

  nsHTMLInputElement* it = new nsHTMLInputElement(mNodeInfo, PR_FALSE);
  if (!it) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  nsCOMPtr<nsIDOMNode> kungFuDeathGrip(it);

  CopyInnerTo(it, aDeep);

  switch (mType) {
    case NS_FORM_INPUT_TEXT:
    case NS_FORM_INPUT_PASSWORD:
      if (GET_BOOLBIT(mBitField, BF_VALUE_CHANGED)) {
        // We don't have our default value anymore.  Set our value on
        // the clone.
        nsAutoString value;
        GetValue(value);
        // SetValueInternal handles setting the VALUE_CHANGED bit for us
        it->SetValueInternal(value, nsnull);
      }
      break;
    case NS_FORM_INPUT_FILE:
      if (mFileName) {
        it->mFileName = new nsString(*mFileName);
      }
      break;
    case NS_FORM_INPUT_RADIO:
    case NS_FORM_INPUT_CHECKBOX:
      if (GET_BOOLBIT(mBitField, BF_CHECKED_CHANGED)) {
        // We no longer have our original checked state.  Set our
        // checked state on the clone.
        PRBool checked;
        GetChecked(&checked);
        it->DoSetChecked(checked, PR_FALSE);
      }
      break;
    default:
      break;
  }
          
  kungFuDeathGrip.swap(*aReturn);

  return NS_OK;
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
  { "button", NS_FORM_INPUT_BUTTON },
  { "checkbox", NS_FORM_INPUT_CHECKBOX },
  { "file", NS_FORM_INPUT_FILE },
  { "hidden", NS_FORM_INPUT_HIDDEN },
  { "reset", NS_FORM_INPUT_RESET },
  { "image", NS_FORM_INPUT_IMAGE },
  { "password", NS_FORM_INPUT_PASSWORD },
  { "radio", NS_FORM_INPUT_RADIO },
  { "submit", NS_FORM_INPUT_SUBMIT },
  { "text", NS_FORM_INPUT_TEXT },
  { 0 }
}

Definition at line 1926 of file nsHTMLInputElement.cpp.

const char* kWhitespace = "\n\r\t\b" [static]

Definition at line 136 of file nsHTMLInputElement.cpp.