void AutocompletePopupMenuClient::initialize( HTMLInputElement* textField, const WebVector<WebString>& suggestions, int defaultSuggestionIndex) { ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size())); // The suggestions must be set before initializing the // SuggestionsPopupMenuClient. setSuggestions(suggestions); SuggestionsPopupMenuClient::initialize(textField, defaultSuggestionIndex); }
void AutoFillPopupMenuClient::initialize( HTMLInputElement* textField, const WebVector<WebString>& names, const WebVector<WebString>& labels, int defaultSuggestionIndex) { ASSERT(names.size() == labels.size()); ASSERT(defaultSuggestionIndex < static_cast<int>(names.size())); // The suggestions must be set before initializing the // SuggestionsPopupMenuClient. setSuggestions(names, labels); SuggestionsPopupMenuClient::initialize(textField, defaultSuggestionIndex); }
void AutofillPopupMenuClient::initialize( HTMLInputElement* textField, const WebVector<WebString>& names, const WebVector<WebString>& labels, const WebVector<WebString>& icons, const WebVector<int>& uniqueIDs, int separatorIndex) { ASSERT(names.size() == labels.size()); ASSERT(names.size() == icons.size()); ASSERT(names.size() == uniqueIDs.size()); ASSERT(separatorIndex < static_cast<int>(names.size())); m_selectedIndex = -1; m_textField = textField; // The suggestions must be set before initializing the // AutofillPopupMenuClient. setSuggestions(names, labels, icons, uniqueIDs, separatorIndex); FontDescription regularFontDescription; RenderTheme::defaultTheme()->systemFont(CSSValueWebkitControl, regularFontDescription); RenderStyle* style = m_textField->computedStyle(); regularFontDescription.setComputedSize(style->fontDescription().computedSize()); Font regularFont(regularFontDescription, 0, 0); regularFont.update(textField->document()->styleSelector()->fontSelector()); // The direction of text in popup menu is set the same as the direction of // the input element: textField. m_regularStyle = adoptPtr(new PopupMenuStyle(Color::black, Color::white, regularFont, true, false, Length(WebCore::Fixed), textField->renderer()->style()->direction(), textField->renderer()->style()->unicodeBidi() == Override, PopupMenuStyle::AutofillPopup)); FontDescription warningFontDescription = regularFont.fontDescription(); warningFontDescription.setItalic(true); Font warningFont(warningFontDescription, regularFont.letterSpacing(), regularFont.wordSpacing()); warningFont.update(regularFont.fontSelector()); m_warningStyle = adoptPtr(new PopupMenuStyle(Color::darkGray, m_regularStyle->backgroundColor(), warningFont, m_regularStyle->isVisible(), m_regularStyle->isDisplayNone(), m_regularStyle->textIndent(), m_regularStyle->textDirection(), m_regularStyle->hasTextDirectionOverride(), PopupMenuStyle::AutofillPopup)); }
void AutofillPopupMenuClient::initialize( HTMLInputElement* textField, const WebVector<WebString>& names, const WebVector<WebString>& labels, const WebVector<WebString>& icons, const WebVector<int>& itemIDs, int separatorIndex) { ASSERT(names.size() == labels.size()); ASSERT(names.size() == icons.size()); ASSERT(names.size() == itemIDs.size()); m_selectedIndex = -1; m_textField = textField; if (separatorIndex == -1) { // The suggestions must be set before initializing the // AutofillPopupMenuClient. setSuggestions(names, labels, icons, itemIDs); } else { m_useLegacyBehavior = true; WebVector<WebString> namesWithSeparator(names.size() + 1); WebVector<WebString> labelsWithSeparator(labels.size() + 1); WebVector<WebString> iconsWithSeparator(icons.size() + 1); WebVector<int> itemIDsWithSeparator(itemIDs.size() + 1); for (size_t i = 0; i < names.size(); ++i) { size_t j = i < static_cast<size_t>(separatorIndex) ? i : i + 1; namesWithSeparator[j] = names[i]; labelsWithSeparator[j] = labels[i]; iconsWithSeparator[j] = icons[i]; itemIDsWithSeparator[j] = itemIDs[i]; } itemIDsWithSeparator[separatorIndex] = WebAutofillClient::MenuItemIDSeparator; setSuggestions(namesWithSeparator, labelsWithSeparator, iconsWithSeparator, itemIDsWithSeparator); } FontDescription regularFontDescription; RenderTheme::theme().systemFont(CSSValueWebkitControl, regularFontDescription); RenderStyle* style = m_textField->computedStyle(); regularFontDescription.setComputedSize(style->fontDescription().computedSize()); Font regularFont(regularFontDescription, 0, 0); regularFont.update(textField->document().styleResolver()->fontSelector()); // The direction of text in popup menu is set the same as the direction of // the input element: textField. m_regularStyle = adoptPtr(new PopupMenuStyle(Color::black, Color::white, regularFont, true, false, Length(WebCore::Fixed), textField->renderer()->style()->direction(), textField->renderer()->style()->unicodeBidi() == Override, PopupMenuStyle::CustomBackgroundColor, PopupMenuStyle::AutofillPopup)); FontDescription warningFontDescription = regularFont.fontDescription(); warningFontDescription.setItalic(true); Font warningFont(warningFontDescription, regularFont.letterSpacing(), regularFont.wordSpacing()); warningFont.update(regularFont.fontSelector()); m_warningStyle = adoptPtr(new PopupMenuStyle(Color::darkGray, m_regularStyle->backgroundColor(), warningFont, m_regularStyle->isVisible(), m_regularStyle->isDisplayNone(), m_regularStyle->textIndent(), m_regularStyle->textDirection(), m_regularStyle->hasTextDirectionOverride(), PopupMenuStyle::CustomBackgroundColor, PopupMenuStyle::AutofillPopup)); }