本文整理汇总了C++中HTMLFormControlElementWithState::restoreFormControlState方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLFormControlElementWithState::restoreFormControlState方法的具体用法?C++ HTMLFormControlElementWithState::restoreFormControlState怎么用?C++ HTMLFormControlElementWithState::restoreFormControlState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLFormControlElementWithState
的用法示例。
在下文中一共展示了HTMLFormControlElementWithState::restoreFormControlState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: 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);
}
}
示例4: 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);
}
}