本文整理汇总了C++中FormControlState::valueSize方法的典型用法代码示例。如果您正苦于以下问题:C++ FormControlState::valueSize方法的具体用法?C++ FormControlState::valueSize怎么用?C++ FormControlState::valueSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormControlState
的用法示例。
在下文中一共展示了FormControlState::valueSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: document
TEST_F(HTMLSelectElementTest, SaveRestoreSelectSingleFormControlState) {
document().documentElement()->setInnerHTML(
String("<!DOCTYPE HTML><select id='sel'>"
"<option value='111' id='0'>111</option>"
"<option value='222'>222</option>"
"<option value='111' selected id='2'>!666</option>"
"<option value='999'>999</option></select>"),
ASSERT_NO_EXCEPTION);
document().view()->updateAllLifecyclePhases();
Element* element = document().getElementById("sel");
HTMLFormControlElementWithState* select = toHTMLSelectElement(element);
HTMLOptionElement* opt0 = toHTMLOptionElement(document().getElementById("0"));
HTMLOptionElement* opt2 = toHTMLOptionElement(document().getElementById("2"));
// Save the select element state, and then restore again.
// Test passes if the restored state is not changed.
EXPECT_EQ(2, toHTMLSelectElement(element)->selectedIndex());
EXPECT_FALSE(opt0->selected());
EXPECT_TRUE(opt2->selected());
FormControlState selectState = select->saveFormControlState();
EXPECT_EQ(2U, selectState.valueSize());
// Clear the selected state, to be restored by restoreFormControlState.
toHTMLSelectElement(select)->setSelectedIndex(-1);
ASSERT_FALSE(opt2->selected());
// Restore
select->restoreFormControlState(selectState);
EXPECT_EQ(2, toHTMLSelectElement(element)->selectedIndex());
EXPECT_FALSE(opt0->selected());
EXPECT_TRUE(opt2->selected());
}
示例2: getNumberFromFormControlState
static unsigned getNumberFromFormControlState(const FormControlState& state, size_t index)
{
if (index >= state.valueSize())
return DateTimeFieldsState::emptyValue;
bool parsed;
unsigned const value = state[index].toUInt(&parsed);
return parsed ? value : DateTimeFieldsState::emptyValue;
}
示例3: formElementsCharacterCount
unsigned FormController::formElementsCharacterCount() const
{
unsigned count = 0;
for (auto& element : m_formElementsWithState) {
FormControlState state = element->saveFormControlState();
if (state.valueSize() && element->isTextFormControl())
count += state[0].length();
}
return count;
}
示例4: getAMPMFromFormControlState
static DateTimeFieldsState::AMPMValue getAMPMFromFormControlState(const FormControlState& state, size_t index)
{
if (index >= state.valueSize())
return DateTimeFieldsState::AMPMValueEmpty;
const String value = state[index];
if (value == "A")
return DateTimeFieldsState::AMPMValueAM;
if (value == "P")
return DateTimeFieldsState::AMPMValuePM;
return DateTimeFieldsState::AMPMValueEmpty;
}
示例5: restoreControlStateFor
void FormController::restoreControlStateFor(HTMLFormControlElementWithState& control)
{
// We don't save state of a control with shouldSaveAndRestoreFormControlState()
// == false. But we need to skip restoring process too because a control in
// another form might have the same pair of name and type and saved its state.
if (!control.shouldSaveAndRestoreFormControlState())
return;
if (ownerFormForState(control))
return;
FormControlState state = takeStateForFormElement(control);
if (state.valueSize() > 0)
control.restoreFormControlState(state);
}
示例6: restoreControlStateIn
void FormController::restoreControlStateIn(HTMLFormElement& form)
{
for (auto& element : form.associatedElements()) {
if (!element->isFormControlElementWithState())
continue;
HTMLFormControlElementWithState* control = static_cast<HTMLFormControlElementWithState*>(element);
if (!control->shouldSaveAndRestoreFormControlState())
continue;
if (ownerFormForState(*control) != &form)
continue;
FormControlState state = takeStateForFormElement(*control);
if (state.valueSize() > 0)
control->restoreFormControlState(state);
}
}
示例7: restoreControlStateIn
void FormController::restoreControlStateIn(HTMLFormElement& form)
{
const Vector<FormAssociatedElement*>& elements = form.associatedElements();
for (size_t i = 0; i < elements.size(); ++i) {
if (!elements[i]->isFormControlElementWithState())
continue;
HTMLFormControlElementWithState* control = static_cast<HTMLFormControlElementWithState*>(elements[i]);
if (!control->shouldSaveAndRestoreFormControlState())
continue;
if (ownerFormForState(*control) != &form)
continue;
FormControlState state = takeStateForFormElement(*control);
if (state.valueSize() > 0)
control->restoreFormControlState(state);
}
}