本文整理汇总了C++中HTMLInputElement::GetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLInputElement::GetValue方法的具体用法?C++ HTMLInputElement::GetValue怎么用?C++ HTMLInputElement::GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLInputElement
的用法示例。
在下文中一共展示了HTMLInputElement::GetValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetValue
nsresult
nsColorControlFrame::UpdateColor()
{
// Get the color from the "value" property of our content; it will return the
// default color (through the sanitization algorithm) if the value is empty.
nsAutoString color;
HTMLInputElement* elt = HTMLInputElement::FromContent(mContent);
elt->GetValue(color, CallerType::System);
if (color.IsEmpty()) {
// OK, there is one case the color string might be empty -- if our content
// is still being created, i.e. if it has mDoneCreating==false. In that
// case, we simply do nothing, because we'll be called again with a complete
// content node before we ever reflow or paint. Specifically: we can expect
// that HTMLInputElement::DoneCreatingElement() will set mDoneCreating to
// true (which enables sanitization) and then it'll call SetValueInternal(),
// which produces a nonempty color (via sanitization), and then it'll call
// this function here, and we'll get the nonempty default color.
MOZ_ASSERT(HasAnyStateBits(NS_FRAME_FIRST_REFLOW),
"Content node's GetValue() should return a valid color string "
"by the time we've been reflowed (the default color, in case "
"no valid color is set)");
return NS_OK;
}
// Set the background-color CSS property of the swatch element to this color.
return mColorContent->SetAttr(kNameSpaceID_None, nsGkAtoms::style,
NS_LITERAL_STRING("background-color:") + color,
/* aNotify */ true);
}
示例2: textArea
void
HTMLTextFieldAccessible::Value(nsString& aValue)
{
aValue.Truncate();
if (NativeState() & states::PROTECTED) // Don't return password text!
return;
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mContent));
if (textArea) {
textArea->GetValue(aValue);
return;
}
HTMLInputElement* input = HTMLInputElement::FromContent(mContent);
if (input)
input->GetValue(aValue);
}
示例3: Value
void HTMLTextFieldAccessible::Value(nsString& aValue) const {
aValue.Truncate();
if (NativeState() & states::PROTECTED) // Don't return password text!
return;
HTMLTextAreaElement* textArea = HTMLTextAreaElement::FromNode(mContent);
if (textArea) {
textArea->GetValue(aValue);
return;
}
HTMLInputElement* input = HTMLInputElement::FromNode(mContent);
if (input) {
// Pass NonSystem as the caller type, to be safe. We don't expect to have a
// file input here.
input->GetValue(aValue, CallerType::NonSystem);
}
}
示例4: MakeAnonymousElement
nsresult
nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
nsresult rv;
// We create an anonymous tree for our input element that is structured as
// follows:
//
// input
// div - outer wrapper with "display:flex" by default
// input - text input field
// div - spin box wrapping up/down arrow buttons
// div - spin up (up arrow button)
// div - spin down (down arrow button)
//
// If you change this, be careful to change the destruction order in
// nsNumberControlFrame::DestroyFrom.
// Create the anonymous outer wrapper:
rv = MakeAnonymousElement(getter_AddRefs(mOuterWrapper),
aElements,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberWrapper,
mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
ContentInfo& outerWrapperCI = aElements.LastElement();
// Create the ::-moz-number-text pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mTextField),
outerWrapperCI.mChildren,
nsGkAtoms::input,
nsCSSPseudoElements::ePseudo_mozNumberText,
outerWrapperCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
NS_LITERAL_STRING("text"), PR_FALSE);
HTMLInputElement* content = HTMLInputElement::FromContent(mContent);
HTMLInputElement* textField = HTMLInputElement::FromContent(mTextField);
// Initialize the text field value:
nsAutoString value;
content->GetValue(value);
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::value, value, false);
// If we're readonly, make sure our anonymous text control is too:
nsAutoString readonly;
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::readonly, readonly)) {
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::readonly, readonly, false);
}
// Propogate our tabindex:
int32_t tabIndex;
content->GetTabIndex(&tabIndex);
textField->SetTabIndex(tabIndex);
// Initialize the text field's placeholder, if ours is set:
nsAutoString placeholder;
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholder)) {
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholder, false);
}
if (mContent->AsElement()->State().HasState(NS_EVENT_STATE_FOCUS)) {
// We don't want to focus the frame but the text field.
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mTextField);
NS_ASSERTION(element, "Really, this should be a nsIDOMElement!");
fm->SetFocus(element, 0);
}
// Create the ::-moz-number-spin-box pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinBox),
outerWrapperCI.mChildren,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberSpinBox,
outerWrapperCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
ContentInfo& spinBoxCI = outerWrapperCI.mChildren.LastElement();
// Create the ::-moz-number-spin-up pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinUp),
spinBoxCI.mChildren,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberSpinUp,
spinBoxCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
// Create the ::-moz-number-spin-down pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinDown),
spinBoxCI.mChildren,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberSpinDown,
spinBoxCI.mStyleContext);
return rv;
}
示例5: MakeAnonymousElement
nsresult
nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
nsresult rv;
// We create an anonymous tree for our input element that is structured as
// follows:
//
// input
// div - outer wrapper with "display:flex" by default
// input - text input field
// div - spin box wrapping up/down arrow buttons
// div - spin up (up arrow button)
// div - spin down (down arrow button)
//
// If you change this, be careful to change the destruction order in
// nsNumberControlFrame::DestroyFrom.
// Create the anonymous outer wrapper:
rv = MakeAnonymousElement(getter_AddRefs(mOuterWrapper),
aElements,
nsGkAtoms::div,
CSSPseudoElementType::mozNumberWrapper,
mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
ContentInfo& outerWrapperCI = aElements.LastElement();
// Create the ::-moz-number-text pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mTextField),
outerWrapperCI.mChildren,
nsGkAtoms::input,
CSSPseudoElementType::mozNumberText,
outerWrapperCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
NS_LITERAL_STRING("text"), PR_FALSE);
HTMLInputElement* content = HTMLInputElement::FromContent(mContent);
HTMLInputElement* textField = HTMLInputElement::FromContent(mTextField);
// Initialize the text field value:
nsAutoString value;
content->GetValue(value);
SetValueOfAnonTextControl(value);
// If we're readonly, make sure our anonymous text control is too:
nsAutoString readonly;
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::readonly, readonly)) {
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::readonly, readonly, false);
}
// Propogate our tabindex:
int32_t tabIndex;
content->GetTabIndex(&tabIndex);
textField->SetTabIndex(tabIndex);
// Initialize the text field's placeholder, if ours is set:
nsAutoString placeholder;
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholder)) {
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholder, false);
}
if (mContent->AsElement()->State().HasState(NS_EVENT_STATE_FOCUS)) {
// We don't want to focus the frame but the text field.
RefPtr<FocusTextField> focusJob = new FocusTextField(mContent, mTextField);
nsContentUtils::AddScriptRunner(focusJob);
}
if (StyleDisplay()->mAppearance == NS_THEME_TEXTFIELD) {
// The author has elected to hide the spinner by setting this
// -moz-appearance. We will reframe if it changes.
return rv;
}
// Create the ::-moz-number-spin-box pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinBox),
outerWrapperCI.mChildren,
nsGkAtoms::div,
CSSPseudoElementType::mozNumberSpinBox,
outerWrapperCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
ContentInfo& spinBoxCI = outerWrapperCI.mChildren.LastElement();
// Create the ::-moz-number-spin-up pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinUp),
spinBoxCI.mChildren,
nsGkAtoms::div,
CSSPseudoElementType::mozNumberSpinUp,
spinBoxCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
// Create the ::-moz-number-spin-down pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinDown),
spinBoxCI.mChildren,
nsGkAtoms::div,
CSSPseudoElementType::mozNumberSpinDown,
//.........这里部分代码省略.........