Changeset 72001 in webkit


Ignore:
Timestamp:
Nov 15, 2010 3:37:21 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2010-11-15 Ilya Sherman <isherman@chromium.org>

Reviewed by Kent Tamura.

Add capability for displaying warnings to autofill popup
Warnings are displayed in dark gray italic.
https://bugs.webkit.org/show_bug.cgi?id=49291
http://code.google.com/p/chromium/issues/detail?id=58509

  • platform/chromium/PopupMenuChromium.cpp: (WebCore::PopupListBox::getRowFont): Use item-specific font, not just the generic menu font. (WebCore::PopupListBox::selectIndex): Updated to clear the selection when hovering over a non-selectable item.
  • platform/chromium/PopupMenuChromium.h: Minor cleanup

2010-11-15 Ilya Sherman <isherman@chromium.org>

Reviewed by Kent Tamura.

Add capability for displaying warnings to autofill popup
Warnings are displayed in dark gray italic.
https://bugs.webkit.org/show_bug.cgi?id=49291
http://code.google.com/p/chromium/issues/detail?id=58509

  • src/AutoFillPopupMenuClient.cpp: (WebKit::AutoFillPopupMenuClient::canRemoveSuggestionAtIndex): Updated logic -- can only remove Autocomplete suggestions, which have unique ID 0. (WebKit::AutoFillPopupMenuClient::itemIsEnabled): False for warnings. (WebKit::AutoFillPopupMenuClient::itemStyle): Dark gray italic for warnings. (WebKit::AutoFillPopupMenuClient::menuStyle): Variable name changed. (WebKit::AutoFillPopupMenuClient::itemIsWarning): True for unique ID < 0. (WebKit::AutoFillPopupMenuClient::initialize): Updated cached styles (see above).
  • src/AutoFillPopupMenuClient.h: Added itemIsEnabled(), variable to cache warning style.
  • src/WebViewImpl.cpp: Minor cleanup. (WebKit::WebViewImpl::applyAutoFillSuggestions):
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r71997 r72001  
     12010-11-15  Ilya Sherman  <isherman@chromium.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        Add capability for displaying warnings to autofill popup
     6        Warnings are displayed in dark gray italic.
     7        https://bugs.webkit.org/show_bug.cgi?id=49291
     8        http://code.google.com/p/chromium/issues/detail?id=58509
     9
     10        * platform/chromium/PopupMenuChromium.cpp:
     11        (WebCore::PopupListBox::getRowFont):
     12          Use item-specific font, not just the generic menu font.
     13        (WebCore::PopupListBox::selectIndex):
     14          Updated to clear the selection when hovering over a non-selectable item.
     15        * platform/chromium/PopupMenuChromium.h: Minor cleanup
     16
    1172010-11-14  David Hyatt  <hyatt@apple.com>
    218
  • trunk/WebCore/platform/chromium/PopupMenuChromium.cpp

    r71963 r72001  
    5050#include "PlatformScreen.h"
    5151#include "PlatformWheelEvent.h"
     52#include "PopupMenuClient.h"
    5253#include "RenderTheme.h"
    5354#include "ScrollbarTheme.h"
     
    992993Font PopupListBox::getRowFont(int rowIndex)
    993994{
    994     Font itemFont = m_popupClient->menuStyle().font();
     995    Font itemFont = m_popupClient->itemStyle(rowIndex).font();
    995996    if (m_popupClient->itemIsLabel(rowIndex)) {
    996997        // Bold-ify labels (ie, an <optgroup> heading).
     
    10701071        return;
    10711072
    1072     if (index != m_selectedIndex && isSelectableItem(index)) {
     1073    bool isSelectable = isSelectableItem(index);
     1074    if (index != m_selectedIndex && isSelectable) {
    10731075        invalidateRow(m_selectedIndex);
    10741076        m_selectedIndex = index;
     
    10771079        scrollToRevealSelection();
    10781080        m_popupClient->selectionChanged(m_selectedIndex);
     1081    } else if (!isSelectable) {
     1082        clearSelection();
    10791083    }
    10801084}
  • trunk/WebCore/platform/chromium/PopupMenuChromium.h

    r71900 r72001  
    3333
    3434#include "config.h"
    35 #include "PopupMenuClient.h"
    3635
    3736#include "FramelessScrollView.h"
    3837#include "IntRect.h"
     38#include "PlatformString.h"
    3939#include "PopupMenu.h"
    4040#include "PopupMenuPrivate.h"
     41#include "PopupMenuStyle.h"
    4142
    4243namespace WebCore {
     
    4546class FrameView;
    4647class PopupListBox;
     48class PopupMenuClient;
    4749
    4850// A container for the data for each menu item (e.g. represented by <option>
  • trunk/WebKit/chromium/ChangeLog

    r71996 r72001  
     12010-11-15  Ilya Sherman  <isherman@chromium.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        Add capability for displaying warnings to autofill popup
     6        Warnings are displayed in dark gray italic.
     7        https://bugs.webkit.org/show_bug.cgi?id=49291
     8        http://code.google.com/p/chromium/issues/detail?id=58509
     9
     10        * src/AutoFillPopupMenuClient.cpp:
     11        (WebKit::AutoFillPopupMenuClient::canRemoveSuggestionAtIndex):
     12          Updated logic -- can only remove Autocomplete suggestions, which have unique ID 0.
     13        (WebKit::AutoFillPopupMenuClient::itemIsEnabled): False for warnings.
     14        (WebKit::AutoFillPopupMenuClient::itemStyle): Dark gray italic for warnings.
     15        (WebKit::AutoFillPopupMenuClient::menuStyle): Variable name changed.
     16        (WebKit::AutoFillPopupMenuClient::itemIsWarning): True for unique ID < 0.
     17        (WebKit::AutoFillPopupMenuClient::initialize): Updated cached styles (see above).
     18        * src/AutoFillPopupMenuClient.h: Added itemIsEnabled(), variable to cache warning style.
     19        * src/WebViewImpl.cpp: Minor cleanup.
     20        (WebKit::WebViewImpl::applyAutoFillSuggestions):
     21
    1222010-11-14  Kent Tamura  <tkent@chromium.org>
    223
  • trunk/WebKit/chromium/public/WebView.h

    r70222 r72001  
    290290    // Notifies the WebView that AutoFill suggestions are available for a node.
    291291    // |uniqueIDs| is a vector of IDs that represent the unique ID of each
    292     // AutoFill profile in the suggestions popup.
     292    // AutoFill profile in the suggestions popup.  If a unique ID is 0, then the
     293    // corresponding suggestion comes from Autocomplete rather than AutoFill.
     294    // If a unique ID is negative, then the corresponding "suggestion" is
     295    // actually a user-facing warning, e.g. explaining why AutoFill is
     296    // unavailable for the current form.
    293297    virtual void applyAutoFillSuggestions(
    294298        const WebNode&,
  • trunk/WebKit/chromium/public/WebViewClient.h

    r71610 r72001  
    310310
    311311    // Informs the browser that the user has accepted an AutoFill suggestion for
    312     // a WebNode.  |name| and |label| form a key into the set of AutoFill
    313     // profiles.  |index| is an index of the selected suggestion in the list of
    314     // suggestions provided by the client
     312    // a WebNode.  |uniqueID| is used as a key into the set of AutoFill profiles,
     313    // and should never be negative.  If it is 0, then the suggestion is an
     314    // Autocomplete suggestion; and |value| stores the suggested text.  |index|
     315    // is an index of the selected suggestion in the list of suggestions provided
     316    // by the client.
    315317    virtual void didAcceptAutoFillSuggestion(const WebNode&,
    316                                              const WebString& name,
     318                                             const WebString& value,
    317319                                             const WebString& label,
    318320                                             int uniqueID,
  • trunk/WebKit/chromium/src/AutoFillPopupMenuClient.cpp

    r71618 r72001  
    116116bool AutoFillPopupMenuClient::canRemoveSuggestionAtIndex(unsigned listIndex)
    117117{
    118     // Only allow deletion of items before the separator and those that don't
    119     // have a label (autocomplete).
    120     int index = convertListIndexToInternalIndex(listIndex);
    121     return m_labels[index].isEmpty() && (m_separatorIndex == -1 || listIndex < static_cast<unsigned>(m_separatorIndex));
     118    // Only allow deletion of items before the separator that have unique id 0
     119    // (i.e. are autocomplete rather than autofill items).
     120    int index = convertListIndexToInternalIndex(listIndex);
     121    return !m_uniqueIDs[index] && (m_separatorIndex == -1 || listIndex < static_cast<unsigned>(m_separatorIndex));
    122122}
    123123
     
    195195}
    196196
     197bool AutoFillPopupMenuClient::itemIsEnabled(unsigned listIndex) const
     198{
     199    return !itemIsWarning(listIndex);
     200}
     201
    197202PopupMenuStyle AutoFillPopupMenuClient::itemStyle(unsigned listIndex) const
    198203{
    199     return *m_style;
     204    return itemIsWarning(listIndex) ? *m_warningStyle : *m_regularStyle;
    200205}
    201206
    202207PopupMenuStyle AutoFillPopupMenuClient::menuStyle() const
    203208{
    204     return *m_style;
     209    return *m_regularStyle;
    205210}
    206211
     
    238243{
    239244    return (m_separatorIndex != -1 && static_cast<unsigned>(m_separatorIndex) == listIndex);
     245}
     246
     247bool AutoFillPopupMenuClient::itemIsWarning(unsigned listIndex) const
     248{
     249    int index = convertListIndexToInternalIndex(listIndex);
     250    if (index == -1)
     251        return false;
     252
     253    ASSERT(index >= 0 && static_cast<size_t>(index) < m_uniqueIDs.size());
     254    return m_uniqueIDs[index] < 0;
    240255}
    241256
     
    283298    setSuggestions(names, labels, icons, uniqueIDs, separatorIndex);
    284299
    285     FontDescription fontDescription;
     300    FontDescription regularFontDescription;
    286301    RenderTheme::defaultTheme()->systemFont(CSSValueWebkitControl,
    287                                             fontDescription);
     302                                            regularFontDescription);
    288303    RenderStyle* style = m_textField->computedStyle();
    289     fontDescription.setComputedSize(style->fontDescription().computedSize());
    290 
    291     Font font(fontDescription, 0, 0);
    292     font.update(textField->document()->styleSelector()->fontSelector());
     304    regularFontDescription.setComputedSize(style->fontDescription().computedSize());
     305
     306    Font regularFont(regularFontDescription, 0, 0);
     307    regularFont.update(textField->document()->styleSelector()->fontSelector());
    293308    // The direction of text in popup menu is set the same as the direction of
    294309    // the input element: textField.
    295     m_style.set(new PopupMenuStyle(Color::black, Color::white, font, true,
    296                                    false, Length(WebCore::Fixed),
    297                                    textField->renderer()->style()->direction()));
     310    m_regularStyle.set(new PopupMenuStyle(Color::black, Color::white, regularFont,
     311                                          true, false, Length(WebCore::Fixed),
     312                                          textField->renderer()->style()->direction()));
     313
     314    FontDescription warningFontDescription = regularFont.fontDescription();
     315    warningFontDescription.setItalic(true);
     316    Font warningFont(warningFontDescription, regularFont.letterSpacing(), regularFont.wordSpacing());
     317    warningFont.update(regularFont.fontSelector());
     318    m_warningStyle.set(new PopupMenuStyle(Color::darkGray,
     319                                          m_regularStyle->backgroundColor(),
     320                                          warningFont,
     321                                          m_regularStyle->isVisible(),
     322                                          m_regularStyle->isDisplayNone(),
     323                                          m_regularStyle->textIndent(),
     324                                          m_regularStyle->textDirection()));
    298325}
    299326
  • trunk/WebKit/chromium/src/AutoFillPopupMenuClient.h

    r65021 r72001  
    7979    virtual WTF::String itemToolTip(unsigned lastIndex) const { return WTF::String(); }
    8080    virtual WTF::String itemAccessibilityText(unsigned lastIndex) const { return WTF::String(); }
    81     virtual bool itemIsEnabled(unsigned listIndex) const { return true; }
     81    virtual bool itemIsEnabled(unsigned listIndex) const;
    8282    virtual WebCore::PopupMenuStyle itemStyle(unsigned listIndex) const;
    8383    virtual WebCore::PopupMenuStyle menuStyle() const;
     
    131131    void setSelectedIndex(int index) { m_selectedIndex = index; }
    132132
     133    bool itemIsWarning(unsigned listIndex) const;
     134
    133135    // The names, labels and icons that make up the contents of the menu items.
    134136    Vector<WTF::String> m_names;
     
    144146
    145147    RefPtr<WebCore::HTMLInputElement> m_textField;
    146     OwnPtr<WebCore::PopupMenuStyle> m_style;
     148    OwnPtr<WebCore::PopupMenuStyle> m_regularStyle;
     149    OwnPtr<WebCore::PopupMenuStyle> m_warningStyle;
    147150
    148151    // DEPRECATED: Will be removed once Autocomplete and AutoFill merge is
  • trunk/WebKit/chromium/src/WebViewImpl.cpp

    r71900 r72001  
    179179    true,  // loopSelectionNavigation
    180180    false, // restrictWidthOfListBox (For security reasons show the entire entry
    181            // so the user doesn't enter information it did not intend to.)
     181           // so the user doesn't enter information he did not intend to.)
    182182    // For suggestions, we use the direction of the input field as the direction
    183183    // of the popup items. The main reason is to keep the display of items in
     
    19441944
    19451945    if (m_autoFillPopupShowing) {
    1946         m_autoFillPopupClient->setSuggestions(
    1947             names, labels, icons, uniqueIDs, separatorIndex);
    19481946        refreshAutoFillPopup();
    19491947    } else {
    1950         m_autoFillPopup->show(focusedNode->getRect(),
    1951                                  focusedNode->ownerDocument()->view(), 0);
     1948        m_autoFillPopup->show(focusedNode->getRect(), focusedNode->ownerDocument()->view(), 0);
    19521949        m_autoFillPopupShowing = true;
    19531950    }
Note: See TracChangeset for help on using the changeset viewer.