/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef nsGenericHTMLElement_h___ #define nsGenericHTMLElement_h___
class nsDOMTokenList; class nsIFrame; class nsILayoutHistoryState; class nsIURI; struct nsSize;
enum nsCSSPropertyID : int32_t;
namespace mozilla { class EditorBase; class ErrorResult; class EventChainPostVisitor; class EventChainPreVisitor; class EventChainVisitor; class EventListenerManager; class PresState; namespace dom { class ElementInternals; class HTMLFormElement; enumclass FetchPriority : uint8_t;
} // namespace dom
} // namespace mozilla
using nsGenericHTMLElementBase = nsStyledElement;
/** * A common superclass for HTML elements
*/ class nsGenericHTMLElement : public nsGenericHTMLElementBase { public: using ContentEditableState = mozilla::ContentEditableState; using Element::Focus; using Element::SetTabIndex; using InvokeAction = mozilla::dom::InvokeAction;
/** * Returns ContentEditableState::True if the element has a contentEditable * attribute and its value is "true" or an empty string. Returns * ContentEditableState::False if the *element has a contentEditable attribute * and its value is "false". Returns ContentEditableState::PlainTextOnly if * the element has a contentEditable attribute and its value is * "plaintext-only". Otherwise returns ContentEditableState::Inherit.
*/
[[nodiscard]] inline ContentEditableState GetContentEditableState() const { if (!MayHaveContentEditableAttr()) { return ContentEditableState::Inherit;
} static constexpr AttrValuesArray kValidValuesExceptInherit[] = {
nsGkAtoms::_empty, nsGkAtoms::_true, nsGkAtoms::plaintextOnly,
nsGkAtoms::_false, nullptr}; switch (mAttrs.FindAttrValueIn(kNameSpaceID_None,
nsGkAtoms::contenteditable,
kValidValuesExceptInherit, eIgnoreCase)) { case 0: case 1: return ContentEditableState::True; case 2: return mozilla::StaticPrefs::
dom_element_contenteditable_plaintext_only_enabled()
? ContentEditableState::PlainTextOnly
: ContentEditableState::Inherit; case 3: return ContentEditableState::False; default: return ContentEditableState::Inherit;
}
}
/** Returns whether a form control should be default-focusable. */ bool IsFormControlDefaultFocusable(mozilla::IsFocusableFlags) const;
/** * Returns the count of descendants (inclusive of this node) in * the uncomposed document that are explicitly set as editable.
*/
uint32_t EditableInclusiveDescendantCount();
/** * Determine whether an attribute is an event (onclick, etc.) * @param aName the attribute * @return whether the name is an event handler name
*/ bool IsEventAttributeNameInternal(nsAtom* aName) override;
#define EVENT(name_, id_, type_, struct_) /* nothing; handled by nsINode */ // The using nsINode::Get/SetOn* are to avoid warnings about shadowing the XPCOM // getter and setter on nsINode. #define FORWARDED_EVENT(name_, id_, type_, struct_) \ using nsINode::GetOn##name_; \ using nsINode::SetOn##name_; \
mozilla::dom::EventHandlerNonNull* GetOn##name_(); \ void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler); #define ERROR_EVENT(name_, id_, type_, struct_) \ using nsINode::GetOn##name_; \ using nsINode::SetOn##name_; \
already_AddRefed<mozilla::dom::EventHandlerNonNull> GetOn##name_(); \ void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler); #include"mozilla/EventNameList.h"// IWYU pragma: keep #undef ERROR_EVENT #undef FORWARDED_EVENT #undef EVENT
mozilla::dom::Element* GetOffsetParent() {
mozilla::CSSIntRect rcFrame; return GetOffsetRect(rcFrame);
}
int32_t OffsetTop() {
mozilla::CSSIntRect rcFrame;
GetOffsetRect(rcFrame);
// These methods are already implemented in nsIContent but we want something // faster for HTMLElements ignoring the namespace checking. // This is safe because we already know that we are in the HTML namespace. inlinebool IsHTMLElement() const { returntrue; }
// Returns true if the event should not be handled from GetEventTargetParent. virtualbool IsDisabledForEvents(mozilla::WidgetEvent* aEvent) { returnfalse;
}
Focusable IsFocusableWithoutStyle(mozilla::IsFocusableFlags aFlags =
mozilla::IsFocusableFlags(0)) override {
Focusable result;
IsHTMLFocusable(aFlags, &result.mFocusable, &result.mTabIndex); return result;
} /** * Returns true if a subclass is not allowed to override the value returned * in aIsFocusable.
*/ virtualbool IsHTMLFocusable(mozilla::IsFocusableFlags, bool* aIsFocusable,
int32_t* aTabIndex);
MOZ_CAN_RUN_SCRIPT
mozilla::Result<bool, nsresult> PerformAccesskey( bool aKeyCausesActivation, bool aIsTrustedEvent) override;
/** * Check if an event for an anchor can be handled * @return true if the event can be handled, false otherwise
*/ bool CheckHandleEventForAnchorsPreconditions(
mozilla::EventChainVisitor& aVisitor); void GetEventTargetParentForAnchors(mozilla::EventChainPreVisitor& aVisitor);
MOZ_CAN_RUN_SCRIPT
nsresult PostHandleEventForAnchors(mozilla::EventChainPostVisitor& aVisitor); bool IsHTMLLink(nsIURI** aURI) const;
// HTML element methods void Compact() { mAttrs.Compact(); }
/** * Get the base target for any links within this piece * of content. Generally, this is the document's base target, * but certain content carries a local base for backward * compatibility. * * @param aBaseTarget the base target [OUT]
*/ void GetBaseTarget(nsAString& aBaseTarget) const;
/** * Parse an alignment attribute (top/middle/bottom/baseline) * * @param aString the string to parse * @param aResult the resulting HTMLValue * @return whether the value was parsed
*/ staticbool ParseAlignValue(const nsAString& aString, nsAttrValue& aResult);
/** * Parse a div align string to value (left/right/center/middle/justify) * * @param aString the string to parse * @param aResult the resulting HTMLValue * @return whether the value was parsed
*/ staticbool ParseDivAlignValue(const nsAString& aString,
nsAttrValue& aResult);
/** * Convert a table halign string to value (left/right/center/char/justify) * * @param aString the string to parse * @param aResult the resulting HTMLValue * @return whether the value was parsed
*/ staticbool ParseTableHAlignValue(const nsAString& aString,
nsAttrValue& aResult);
/** * Convert a table cell halign string to value * * @param aString the string to parse * @param aResult the resulting HTMLValue * @return whether the value was parsed
*/ staticbool ParseTableCellHAlignValue(const nsAString& aString,
nsAttrValue& aResult);
/** * Convert a table valign string to value (left/right/center/char/justify/ * abscenter/absmiddle/middle) * * @param aString the string to parse * @param aResult the resulting HTMLValue * @return whether the value was parsed
*/ staticbool ParseTableVAlignValue(const nsAString& aString,
nsAttrValue& aResult);
/** * Convert an image attribute to value (width, height, hspace, vspace, border) * * @param aAttribute the attribute to parse * @param aString the string to parse * @param aResult the resulting HTMLValue * @return whether the value was parsed
*/ staticbool ParseImageAttribute(nsAtom* aAttribute, const nsAString& aString,
nsAttrValue& aResult);
/** * Convert a frameborder string to value (yes/no/1/0) * * @param aString the string to parse * @param aResult the resulting HTMLValue * @return whether the value was parsed
*/ staticbool ParseFrameborderValue(const nsAString& aString,
nsAttrValue& aResult);
/** * Convert a scrolling string to value (yes/no/on/off/scroll/noscroll/auto) * * @param aString the string to parse * @param aResult the resulting HTMLValue * @return whether the value was parsed
*/ staticbool ParseScrollingValue(const nsAString& aString,
nsAttrValue& aResult);
/* * Attribute Mapping Helpers
*/
/** * A style attribute mapping function for the most common attributes, to be * called by subclasses' attribute mapping functions. Currently handles * dir, lang and hidden, could handle others. * * @param aAttributes the list of attributes to map * @param aData the returned rule data [INOUT] * @see GetAttributeMappingFunction
*/ staticvoid MapCommonAttributesInto(mozilla::MappedDeclarationsBuilder&); /** * Same as MapCommonAttributesInto except that it does not handle hidden. * @see GetAttributeMappingFunction
*/ staticvoid MapCommonAttributesIntoExceptHidden(
mozilla::MappedDeclarationsBuilder&);
/** * Helper to map the align attribute. * @see GetAttributeMappingFunction
*/ staticvoid MapImageAlignAttributeInto(mozilla::MappedDeclarationsBuilder&);
/** * Helper to map the align attribute for things like <div>, <h1>, etc. * @see GetAttributeMappingFunction
*/ staticvoid MapDivAlignAttributeInto(mozilla::MappedDeclarationsBuilder&);
/** * Helper to map the valign attribute for things like <col>, <tr>, <section>. * @see GetAttributeMappingFunction
*/ staticvoid MapVAlignAttributeInto(mozilla::MappedDeclarationsBuilder&);
/** * Helper to map the image border attribute. * @see GetAttributeMappingFunction
*/ staticvoid MapImageBorderAttributeInto(mozilla::MappedDeclarationsBuilder&); /** * Helper to map the image margin attribute into a style struct. * * @param aAttributes the list of attributes to map * @param aData the returned rule data [INOUT] * @see GetAttributeMappingFunction
*/ staticvoid MapImageMarginAttributeInto(mozilla::MappedDeclarationsBuilder&);
/** * Helper to map a given dimension (width/height) into the declaration * block, handling percentages and numbers.
*/ staticvoid MapDimensionAttributeInto(mozilla::MappedDeclarationsBuilder&,
nsCSSPropertyID, const nsAttrValue&);
/** * Maps the aspect ratio given width and height attributes.
*/ staticvoid DoMapAspectRatio(const nsAttrValue& aWidth, const nsAttrValue& aHeight,
mozilla::MappedDeclarationsBuilder&);
// Whether to map the width and height attributes to aspect-ratio. enumclass MapAspectRatio { No, Yes };
/** * Helper to map the image position attribute into a style struct.
*/ staticvoid MapImageSizeAttributesInto(mozilla::MappedDeclarationsBuilder&,
MapAspectRatio = MapAspectRatio::No);
/** * Helper to map the width and height attributes into the aspect-ratio * property. * * If you also map the width/height attributes to width/height (as you should * for any HTML element that isn't <canvas>) then you should use * MapImageSizeAttributesInto instead, passing MapAspectRatio::Yes instead, as * that'd be faster.
*/ staticvoid MapAspectRatioInto(mozilla::MappedDeclarationsBuilder&);
/** * Helper to map `width` attribute into a style struct. * * @param aAttributes the list of attributes to map * @param aData the returned rule data [INOUT] * @see GetAttributeMappingFunction
*/ staticvoid MapWidthAttributeInto(mozilla::MappedDeclarationsBuilder&);
/** * Helper to map `height` attribute. * @see GetAttributeMappingFunction
*/ staticvoid MapHeightAttributeInto(mozilla::MappedDeclarationsBuilder&); /** * Helper to map the background attribute * @see GetAttributeMappingFunction
*/ staticvoid MapBackgroundInto(mozilla::MappedDeclarationsBuilder&); /** * Helper to map the bgcolor attribute * @see GetAttributeMappingFunction
*/ staticvoid MapBGColorInto(mozilla::MappedDeclarationsBuilder&); /** * Helper to map the background attributes (currently background and bgcolor) * @see GetAttributeMappingFunction
*/ staticvoid MapBackgroundAttributesInto(mozilla::MappedDeclarationsBuilder&); /** * Helper to map the scrolling attribute on FRAME and IFRAME. * @see GetAttributeMappingFunction
*/ staticvoid MapScrollingAttributeInto(mozilla::MappedDeclarationsBuilder&);
// Form Helper Routines /** * Find an ancestor of this content node which is a form (could be null) * @param aCurrentForm the current form for this node. If this is * non-null, and no ancestor form is found, and the current form is in * a connected subtree with the node, the current form will be * returned. This is needed to handle cases when HTML elements have a * current form that they're not descendants of. * @note This method should not be called if the element has a form attribute.
*/
mozilla::dom::HTMLFormElement* FindAncestorForm(
mozilla::dom::HTMLFormElement* aCurrentForm = nullptr);
/** * See if the document being tested has nav-quirks mode enabled. * @param doc the document
*/ staticbool InNavQuirksMode(Document*);
/** * Gets the absolute URI value of an attribute, by resolving any relative * URIs in the attribute against the baseuri of the element. If the attribute * isn't a relative URI the value of the attribute is returned as is. Only * works for attributes in null namespace. * * @param aAttr name of attribute. * @param aBaseAttr name of base attribute. * @param aResult result value [out]
*/ void GetURIAttr(nsAtom* aAttr, nsAtom* aBaseAttr, nsAString& aResult) const; void GetURIAttr(nsAtom* aAttr, nsAtom* aBaseAttr, nsACString& aResult) const;
/** * Gets the absolute URI values of an attribute, by resolving any relative * URIs in the attribute against the baseuri of the element. If a substring * isn't a relative URI, the substring is returned as is. Only works for * attributes in null namespace.
*/ const nsAttrValue* GetURIAttr(nsAtom* aAttr, nsAtom* aBaseAttr,
nsIURI** aURI) const;
// Per spec, <img> is exposed by id only if it also has a nonempty // name (which doesn't have to match the id or anything). // HasName() is true precisely when name is nonempty. return aElement->IsHTMLElement(nsGkAtoms::img) && aElement->HasName();
}
private: /** * Add/remove this element to the documents name cache
*/ void AddToNameTable(nsAtom* aName); void RemoveFromNameTable();
/** * Register or unregister an access key to this element based on the * accesskey attribute.
*/ void RegUnRegAccessKey(bool aDoReg) override { if (!HasFlag(NODE_HAS_ACCESSKEY)) { return;
}
nsStyledElement::RegUnRegAccessKey(aDoReg);
}
protected: void BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, bool aNotify) override; // TODO: Convert AfterSetAttr to MOZ_CAN_RUN_SCRIPT and get rid of // kungFuDeathGrip in it.
MOZ_CAN_RUN_SCRIPT_BOUNDARY void AfterSetAttr(
int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) override;
/** * Handles dispatching a simulated click on `this` on space or enter. * TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230)
*/
MOZ_CAN_RUN_SCRIPT_BOUNDARY void HandleKeyboardActivation(
mozilla::EventChainPostVisitor&);
/** Dispatch a simulated mouse click by keyboard to the given element. */
MOZ_CAN_RUN_SCRIPT static nsresult DispatchSimulatedClick(
nsGenericHTMLElement* aElement, bool aIsTrusted,
nsPresContext* aPresContext);
/** * Create a URI for the given aURISpec string. * Returns INVALID_STATE_ERR and nulls *aURI if aURISpec is empty * and the document's URI matches the element's base URI.
*/
nsresult NewURIFromString(const nsAString& aURISpec, nsIURI** aURI);
/** * Gets the integer-value of an attribute, returns specified default value * if the attribute isn't set or isn't set to an integer. Only works for * attributes in null namespace. * * @param aAttr name of attribute. * @param aDefault default-value to return if attribute isn't set.
*/
int32_t GetIntAttr(nsAtom* aAttr, int32_t aDefault) const;
/** * Sets value of attribute to specified integer. Only works for attributes * in null namespace. * * @param aAttr name of attribute. * @param aValue Integer value of attribute.
*/
nsresult SetIntAttr(nsAtom* aAttr, int32_t aValue);
/** * Gets the unsigned integer-value of an attribute, returns specified default * value if the attribute isn't set or isn't set to an integer. Only works for * attributes in null namespace. * * @param aAttr name of attribute. * @param aDefault default-value to return if attribute isn't set.
*/
uint32_t GetUnsignedIntAttr(nsAtom* aAttr, uint32_t aDefault) const;
/** * Sets value of attribute to specified unsigned integer. Only works for * attributes in null namespace. * * @param aAttr name of attribute. * @param aValue Integer value of attribute. * @param aDefault Default value (in case value is out of range). If the spec * doesn't provide one, should be 1 if the value is limited to * nonzero values, and 0 otherwise.
*/ void SetUnsignedIntAttr(nsAtom* aName, uint32_t aValue, uint32_t aDefault,
mozilla::ErrorResult& aError) {
nsAutoString value; if (aValue > INT32_MAX) {
value.AppendInt(aDefault);
} else {
value.AppendInt(aValue);
}
SetHTMLAttr(aName, value, aError);
}
/** * Gets the unsigned integer-value of an attribute that is stored as a * dimension (i.e. could be an integer or a percentage), returns specified * default value if the attribute isn't set or isn't set to a dimension. Only * works for attributes in null namespace. * * @param aAttr name of attribute. * @param aDefault default-value to return if attribute isn't set.
*/
uint32_t GetDimensionAttrAsUnsignedInt(nsAtom* aAttr,
uint32_t aDefault) const;
/** * Sets value of attribute to specified double. Only works for attributes * in null namespace. * * Implements * https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes:idl-double * * @param aAttr name of attribute. * @param aValue Double value of attribute.
*/ template <Reflection Limited = Reflection::Unlimited> void SetDoubleAttr(nsAtom* aAttr, double aValue, mozilla::ErrorResult& aRv) { // 1. If the reflected IDL attribute is limited to only positive numbers and // the given value is not greater than 0, then return. if (Limited == Reflection::OnlyPositive && aValue <= 0) { return;
}
// 2. Run this's set the content attribute with the given value, converted // to the best representation of the number as a floating-point number.
nsAutoString value;
value.AppendFloat(aValue);
SetHTMLAttr(aAttr, value, aRv);
}
/** * Locates the EditorBase associated with this node. In general this is * equivalent to GetEditorInternal(), but for designmode or contenteditable, * this may need to get an editor that's not actually on this element's * associated TextControlFrame. This is used by the spellchecking routines * to get the editor affected by changing the spellcheck attribute on this * node.
*/ virtual already_AddRefed<mozilla::EditorBase> GetAssociatedEditor();
/** * Get the frame's offset information for offsetTop/Left/Width/Height. * Returns the parent the offset is relative to. * @note This method flushes pending notifications (FlushType::Layout). * @param aRect the offset information [OUT]
*/
mozilla::dom::Element* GetOffsetRect(mozilla::CSSIntRect& aRect);
/** * Ensures all editors associated with a subtree are synced, for purposes of * spellchecking.
*/ staticvoid SyncEditorsOnSubtree(nsIContent* content);
// HTMLElement specific bits enum { // Used to handle keyboard activation.
HTML_ELEMENT_ACTIVE_FOR_KEYBOARD = HTML_ELEMENT_FLAG_BIT(0), // Similar to HTMLInputElement's mInhibitRestoration, used to prevent // form-associated custom elements not created by a network parser from // being restored.
HTML_ELEMENT_INHIBIT_RESTORATION = HTML_ELEMENT_FLAG_BIT(1),
// Remaining bits are type specific.
HTML_ELEMENT_TYPE_SPECIFIC_BITS_OFFSET =
ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 2,
};
// Form element specific bits enum { // If this flag is set on an nsGenericHTMLFormElement or an HTMLImageElement, // that means that we have added ourselves to our mForm. It's possible to // have a non-null mForm, but not have this flag set. That happens when the // form is set via the content sink.
ADDED_TO_FORM = FORM_ELEMENT_FLAG_BIT(0),
// If this flag is set on an nsGenericHTMLFormElement or an HTMLImageElement, // that means that its form is in the process of being unbound from the tree, // and this form element hasn't re-found its form in // nsGenericHTMLFormElement::UnbindFromTree yet.
MAYBE_ORPHAN_FORM_ELEMENT = FORM_ELEMENT_FLAG_BIT(1),
// If this flag is set on an nsGenericHTMLElement or an HTMLImageElement, then // the element might be in the past names map of its form.
MAY_BE_IN_PAST_NAMES_MAP = FORM_ELEMENT_FLAG_BIT(2)
};
// NOTE: I don't think it's possible to have both ADDED_TO_FORM and // MAYBE_ORPHAN_FORM_ELEMENT set at the same time, so if it becomes an issue we // can probably merge them into the same bit. --bz
/** * A helper class for form elements that can contain children
*/ class nsGenericHTMLFormElement : public nsGenericHTMLElement { public:
nsGenericHTMLFormElement(
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
/** * This callback is called by a fieldest on all its elements whenever its * disabled attribute is changed so the element knows its disabled state * might have changed. * * @note Classes redefining this method should not do any content * state updates themselves but should just make sure to call into * nsGenericHTMLFormElement::FieldSetDisabledChanged.
*/ virtualvoid FieldSetDisabledChanged(bool aNotify);
/** * This callback is called by a fieldset on all it's elements when it's being * destroyed. When called, the elements should check that aFieldset is there * first parent fieldset and null mFieldset in that case only. * * @param aFieldSet The fieldset being removed.
*/ void ForgetFieldSet(nsIContent* aFieldset);
/** * Get the layout history object for a particular piece of content. * * @param aRead if true, won't return a layout history state if the * layout history state is empty. * @return the history state object
*/
already_AddRefed<nsILayoutHistoryState> GetLayoutHistory(bool aRead);
/** * Check our disabled content attribute and fieldset's (if it exists) disabled * state to decide whether our disabled flag should be toggled.
*/ virtualvoid UpdateDisabledState(bool aNotify); bool IsReadOnlyInternal() const final;
/** * This method will update the form owner, using @form or looking to a parent. * * @param aBindToTree Whether the element is being attached to the tree. * @param aFormIdElement The element associated with the id in @form. If * aBindToTree is false, aFormIdElement *must* contain the element associated * with the id in @form. Otherwise, it *must* be null. * * @note Callers of UpdateFormOwner have to be sure the element is in a * document (GetUncomposedDoc() != nullptr).
*/ virtualvoid UpdateFormOwner(bool aBindToTree, Element* aFormIdElement);
/** * This method will update mFieldset and set it to the first fieldset parent.
*/ void UpdateFieldSet(bool aNotify);
/** * Add a form id observer which will observe when the element with the id in * @form will change. * * @return The element associated with the current id in @form (may be null).
*/
Element* AddFormIdObserver();
/** * Remove the form id observer.
*/ void RemoveFormIdObserver();
/** * This method is a a callback for IDTargetObserver (from Document). * It will be called each time the element associated with the id in @form * changes.
*/ staticbool FormIdUpdated(Element* aOldElement, Element* aNewElement, void* aData);
// Returns true if the event should not be handled from GetEventTargetParent bool IsElementDisabledForEvents(mozilla::WidgetEvent* aEvent,
nsIFrame* aFrame);
/** * Returns if the control can be disabled.
*/ virtualbool CanBeDisabled() const { returnfalse; }
/** * Returns true if :read-write pseudo class may match the element even if the * element isn't part of designMode or contenteditable.
*/ virtualbool DoesReadWriteApply() const { returnfalse; }
/** * Save to presentation state. The form element will determine whether it * has anything to save and if so, create an entry in the layout history for * its pres context.
*/ virtualvoid SaveState() {}
};
class nsGenericHTMLFormControlElement : public nsGenericHTMLFormElement, public nsIFormControl { public:
nsGenericHTMLFormControlElement(
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, FormControlType);
/** * Get the presentation state for a piece of content, or create it if it does * not exist. Generally used by SaveState().
*/
mozilla::PresState* GetPrimaryPresState();
/** * Called when we have been cloned and adopted, and the information of the * node has been changed.
*/ void NodeInfoChanged(Document* aOldDoc) override;
void GetFormAction(nsString& aValue);
protected: /** * Restore from presentation state. You pass in the presentation state for * this form control (generated with GenerateStateKey() + "-C") and the form * control will grab its state from there. * * @param aState the pres state to use to restore the control * @return true if the form control was a checkbox and its * checked state was restored, false otherwise.
*/ virtualbool RestoreState(mozilla::PresState* aState) { returnfalse; }
/** * Restore the state for a form control in response to the element being * inserted into the document by the parser. Ends up calling RestoreState(). * * GenerateStateKey() must already have been called. * * @return false if RestoreState() was not called, the return * value of RestoreState() otherwise.
*/ bool RestoreFormControlState();
/* Generates the state key for saving the form state in the session if not
computed already. The result is stored in mStateKey. */ void GenerateStateKey();
/* Used to store the key to that element in the session. Is void until
GenerateStateKey has been used */
nsCString mStateKey;
// A number for this form control that is unique within its owner document. // This is only set to a number for elements inserted into the document by // the parser from the network. Otherwise, it is -1.
int32_t mControlNumber;
};
// Here, we expand 'NS_DECLARE_NS_NEW_HTML_ELEMENT()' by hand. // (Calling the macro directly (with no args) produces compiler warnings.)
nsGenericHTMLElement* NS_NewHTMLElement(
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
// Distinct from the above in order to have function pointer that compared // unequal to a function pointer to the above.
nsGenericHTMLElement* NS_NewCustomElement(
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.