本文整理汇总了C++中HTMLFormElement::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLFormElement::getAttribute方法的具体用法?C++ HTMLFormElement::getAttribute怎么用?C++ HTMLFormElement::getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLFormElement
的用法示例。
在下文中一共展示了HTMLFormElement::getAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: action
WebSearchableFormData::WebSearchableFormData(const WebFormElement& form, const WebInputElement& selectedInputElement)
{
HTMLFormElement* formElement = static_cast<HTMLFormElement*>(form);
HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(selectedInputElement);
// Only consider forms that GET data.
// Allow HTTPS only when an input element is provided.
if (equalIgnoringCase(formElement->getAttribute(methodAttr), "post")
|| (!isHTTPFormSubmit(*formElement) && !inputElement))
return;
WTF::TextEncoding encoding;
getFormEncoding(*formElement, &encoding);
if (!encoding.isValid()) {
// Need a valid encoding to encode the form elements.
// If the encoding isn't found webkit ends up replacing the params with
// empty strings. So, we don't try to do anything here.
return;
}
// Look for a suitable search text field in the form when a
// selectedInputElement is not provided.
if (!inputElement) {
inputElement = findSuitableSearchInputElement(*formElement);
// Return if no suitable text element has been found.
if (!inputElement)
return;
}
HTMLFormControlElement* firstSubmitButton = buttonToActivate(*formElement);
if (firstSubmitButton) {
// The form does not have an active submit button, make the first button
// active. We need to do this, otherwise the URL will not contain the
// name of the submit button.
firstSubmitButton->setActivatedSubmit(true);
}
Vector<char> encodedString;
bool isValidSearchString = buildSearchString(*formElement, &encodedString, encoding, inputElement);
if (firstSubmitButton)
firstSubmitButton->setActivatedSubmit(false);
// Return if the search string is not valid.
if (!isValidSearchString)
return;
String action(formElement->action());
KURL url(formElement->document().completeURL(action.isNull() ? "" : action));
RefPtr<EncodedFormData> formData = EncodedFormData::create(encodedString);
url.setQuery(formData->flattenToString());
m_url = url;
m_encoding = String(encoding.name());
}