Changeset 73635 in webkit


Ignore:
Timestamp:
Dec 9, 2010 11:54:19 AM (13 years ago)
Author:
robert@webkit.org
Message:

2010-12-09 Robert Hogan <robert@webkit.org>

Reviewed by Andreas Kling.

[Qt] Search input field doesn't have cancel button
Add a cancel button to the search field and make it customizable
by the client. For now, use the close dialog button associated
with the application's style as the default.

Unskip a bunch of search field related tests that pass now:

fast/forms/search-cancel-button-mouseup.html
fast/forms/search-rtl.html
fast/forms/search-abs-pos-cancel-button.html
fast/forms/search-styled.html
fast/forms/search-transformed.html
fast/forms/search-zoomed.html
fast/forms/search-cancel-button-style-sharing.html
fast/forms/search-display-none-cancel-button.html
fast/forms/search-placeholder-value-changed.html
fast/repaint/search-field-cancel.html
fast/forms/search-cancel-button-events.html

https://bugs.webkit.org/show_bug.cgi?id=42887

  • platform/qt/Skipped:

2010-12-09 Robert Hogan <robert@webkit.org>

Reviewed by Andreas Kling.

[Qt] Search input field doesn't have cancel button

Add a cancel button to the search field and make it customizable
by the client. For now, use the close dialog button associated
with the application's style as the default.

https://bugs.webkit.org/show_bug.cgi?id=42887

  • platform/graphics/qt/ImageQt.cpp: (loadResourcePixmap):
  • platform/qt/RenderThemeQt.cpp: (WebCore::RenderThemeQt::computeSizeBasedOnStyle): (WebCore::RenderThemeQt::paintSearchField): (WebCore::RenderThemeQt::adjustSearchFieldStyle): (WebCore::RenderThemeQt::adjustSearchFieldCancelButtonStyle): (WebCore::RenderThemeQt::convertToPaintingRect): (WebCore::RenderThemeQt::paintSearchFieldCancelButton):
  • platform/qt/RenderThemeQt.h:

2010-12-09 Robert Hogan <robert@webkit.org>

Reviewed by Andreas Kling.

[Qt] Search input field doesn't have cancel button

Add a cancel button to the search field and make it customizable
by the client. For now, use the close dialog button associated
with the application's style as the default.

https://bugs.webkit.org/show_bug.cgi?id=42887

  • Api/qwebsettings.cpp: (graphics):
  • Api/qwebsettings.h:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r73634 r73635  
     12010-12-09  Robert Hogan  <robert@webkit.org>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] Search input field doesn't have cancel button
     6        Add a cancel button to the search field and make it customizable
     7        by the client. For now, use the close dialog button associated
     8        with the application's style as the default.
     9
     10        Unskip a bunch of search field related tests that pass now:
     11
     12        fast/forms/search-cancel-button-mouseup.html
     13        fast/forms/search-rtl.html
     14        fast/forms/search-abs-pos-cancel-button.html
     15        fast/forms/search-styled.html
     16        fast/forms/search-transformed.html
     17        fast/forms/search-zoomed.html
     18        fast/forms/search-cancel-button-style-sharing.html
     19        fast/forms/search-display-none-cancel-button.html
     20        fast/forms/search-placeholder-value-changed.html
     21        fast/repaint/search-field-cancel.html
     22        fast/forms/search-cancel-button-events.html
     23
     24        https://bugs.webkit.org/show_bug.cgi?id=42887
     25
     26        * platform/qt/Skipped:
     27
    1282010-12-09  Yael Aharon  <yael.aharon@nokia.com>
    229
  • trunk/LayoutTests/platform/qt/Skipped

    r73503 r73635  
    510510fast/forms/001.html
    511511fast/forms/focus2.html
    512 fast/forms/search-cancel-button-mouseup.html
    513512fast/frames/001.html
    514513fast/text/monospace-width-cache.html
     
    23412340fast/forms/listbox-selection.html
    23422341fast/forms/onselect-textarea.html
    2343 fast/forms/search-rtl.html
    23442342fast/forms/select-writing-direction-natural.html
    23452343fast/forms/tabbing-input-iframe.html
     
    24012399fast/events/crash-on-mutate-during-drop.html
    24022400fast/forms/option-mouseevents.html
    2403 fast/forms/search-abs-pos-cancel-button.html
    24042401fast/forms/text-control-intrinsic-widths.html
    24052402fast/forms/textarea-metrics.html
     
    24592456fast/forms/negativeLineHeight.html
    24602457fast/forms/placeholder-pseudo-style.html
    2461 fast/forms/search-styled.html
    2462 fast/forms/search-transformed.html
    2463 fast/forms/search-zoomed.html
    24642458fast/forms/textarea-align.html
    24652459fast/forms/textarea-setinnerhtml.html
     
    32353229fast/forms/radio_checked_dynamic.html
    32363230fast/forms/range-thumb-height-percentage.html
    3237 fast/forms/search-cancel-button-style-sharing.html
    3238 fast/forms/search-display-none-cancel-button.html
    3239 fast/forms/search-placeholder-value-changed.html
    32403231fast/forms/searchfield-heights.html
    32413232fast/forms/select-accesskey.html
     
    35753566fast/repaint/renderer-destruction-by-invalidateSelection-crash.html
    35763567fast/repaint/repaint-resized-overflow.html
    3577 fast/repaint/search-field-cancel.html
    35783568fast/repaint/selected-replaced.html
    35793569fast/repaint/selection-clear.html
     
    52375227animations/stop-animation-on-suspend.html
    52385228
    5239 # [Qt] Search input field doesn't have cancel button
    5240 # https://bugs.webkit.org/show_bug.cgi?id=42887
    5241 fast/forms/search-cancel-button-events.html
    5242 
    52435229# [Qt] DRT sideeffect revealed by r63657
    52445230# https://bugs.webkit.org/show_bug.cgi?id=42578
  • trunk/WebCore/ChangeLog

    r73634 r73635  
     12010-12-09  Robert Hogan  <robert@webkit.org>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] Search input field doesn't have cancel button
     6
     7        Add a cancel button to the search field and make it customizable
     8        by the client. For now, use the close dialog button associated
     9        with the application's style as the default.
     10
     11        https://bugs.webkit.org/show_bug.cgi?id=42887
     12
     13        * platform/graphics/qt/ImageQt.cpp:
     14        (loadResourcePixmap):
     15        * platform/qt/RenderThemeQt.cpp:
     16        (WebCore::RenderThemeQt::computeSizeBasedOnStyle):
     17        (WebCore::RenderThemeQt::paintSearchField):
     18        (WebCore::RenderThemeQt::adjustSearchFieldStyle):
     19        (WebCore::RenderThemeQt::adjustSearchFieldCancelButtonStyle):
     20        (WebCore::RenderThemeQt::convertToPaintingRect):
     21        (WebCore::RenderThemeQt::paintSearchFieldCancelButton):
     22        * platform/qt/RenderThemeQt.h:
     23
    1242010-12-09  Yael Aharon  <yael.aharon@nokia.com>
    225
  • trunk/WebCore/platform/graphics/qt/ImageQt.cpp

    r72588 r73635  
    6969    else if (!qstrcmp(name, "inputSpeech"))
    7070        pixmap = QWebSettings::webGraphic(QWebSettings::InputSpeechButtonGraphic);
     71    else if (!qstrcmp(name, "searchCancelButton"))
     72        pixmap = QWebSettings::webGraphic(QWebSettings::SearchCancelButtonGraphic);
     73    else if (!qstrcmp(name, "searchCancelButtonPressed"))
     74        pixmap = QWebSettings::webGraphic(QWebSettings::SearchCancelButtonPressedGraphic);
    7175
    7276    return pixmap;
  • trunk/WebCore/platform/qt/RenderThemeQt.cpp

    r72004 r73635  
    5050#include "QWebPageClient.h"
    5151#include "QtStyleOptionWebComboBox.h"
     52#include "qwebsettings.h"
    5253#include "RenderBox.h"
    5354#if ENABLE(PROGRESS_TAG)
     
    7576#include <QStyleOptionSlider>
    7677#include <QWidget>
     78
     79// These values all match Safari/Win/Chromium
     80static const float defaultControlFontPixelSize = 13;
     81static const float defaultCancelButtonSize = 9;
     82static const float minCancelButtonSize = 5;
     83static const float maxCancelButtonSize = 21;
     84static const float defaultSearchFieldResultsDecorationSize = 13;
     85static const float minSearchFieldResultsDecorationSize = 9;
     86static const float maxSearchFieldResultsDecorationSize = 30;
     87static const float defaultSearchFieldResultsButtonWidth = 18;
    7788
    7889
     
    395406    switch (renderStyle->appearance()) {
    396407    case TextAreaPart:
     408    case SearchFieldPart:
    397409    case TextFieldPart: {
    398410        int padding = findFrameLineWidth(style);
     
    868880                                     const IntRect& r)
    869881{
    870     return true;
     882    return paintTextField(o, pi, r);
    871883}
    872884
     
    874886                                           Element* e) const
    875887{
    876     notImplemented();
    877     RenderTheme::adjustSearchFieldStyle(selector, style, e);
     888    style->setBackgroundColor(Color::transparent);
     889    style->resetBorder();
     890    style->resetPadding();
     891    computeSizeBasedOnStyle(style);
    878892}
    879893
     
    881895                                                       Element* e) const
    882896{
    883     notImplemented();
    884     RenderTheme::adjustSearchFieldCancelButtonStyle(selector, style, e);
     897    // Taken from RenderThemeChromium.cpp
     898
     899    // Scale the button size based on the font size
     900    float fontScale = style->fontSize() / defaultControlFontPixelSize;
     901    int cancelButtonSize = lroundf(qMin(qMax(minCancelButtonSize, defaultCancelButtonSize * fontScale), maxCancelButtonSize));
     902    style->setWidth(Length(cancelButtonSize, Fixed));
     903    style->setHeight(Length(cancelButtonSize, Fixed));
     904}
     905
     906// Taken from RenderThemeChromium.cpp
     907IntRect RenderThemeQt::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const
     908{
     909    // Compute an offset between the part renderer and the input renderer.
     910    IntSize offsetFromInputRenderer = -(partRenderer->offsetFromAncestorContainer(inputRenderer));
     911    // Move the rect into partRenderer's coords.
     912    partRect.move(offsetFromInputRenderer);
     913    // Account for the local drawing offset.
     914    partRect.move(localOffset.x(), localOffset.y());
     915
     916    return partRect;
    885917}
    886918
     
    888920                                                 const IntRect& r)
    889921{
    890     notImplemented();
    891     return RenderTheme::paintSearchFieldCancelButton(o, pi, r);
     922    // Adapted from RenderThemeChromium.cpp
     923
     924    // Get the renderer of <input> element.
     925    Node* input = o->node()->shadowAncestorNode();
     926    if (!input->renderer()->isBox())
     927        return false;
     928    RenderBox* inputRenderBox = toRenderBox(input->renderer());
     929    IntRect inputContentBox = inputRenderBox->contentBoxRect();
     930
     931    // Make sure the scaled button stays square and will fit in its parent's box.
     932    int cancelButtonSize = qMin(inputContentBox.width(), qMin(inputContentBox.height(), r.height()));
     933    // Calculate cancel button's coordinates relative to the input element.
     934    // Center the button vertically.  Round up though, so if it has to be one pixel off-center, it will
     935    // be one pixel closer to the bottom of the field.  This tends to look better with the text.
     936    IntRect cancelButtonRect(o->offsetFromAncestorContainer(inputRenderBox).width(),
     937                             inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2,
     938                             cancelButtonSize, cancelButtonSize);
     939    IntRect paintingRect = convertToPaintingRect(inputRenderBox, o, cancelButtonRect, r);
     940    static Image* cancelImage = Image::loadPlatformResource("searchCancelButton").releaseRef();
     941    static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelButtonPressed").releaseRef();
     942    pi.context->drawImage(isPressed(o) ? cancelPressedImage : cancelImage,
     943                                 o->style()->colorSpace(), paintingRect);
     944    return false;
    892945}
    893946
  • trunk/WebCore/platform/qt/RenderThemeQt.h

    r62104 r73635  
    178178    QStyle* fallbackStyle() const;
    179179
     180    IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const;
     181
    180182    Page* m_page;
    181183
  • trunk/WebKit/qt/Api/qwebsettings.cpp

    r71499 r73635  
    4949#include <QUrl>
    5050#include <QFileInfo>
     51#include <QStyle>
    5152
    5253#include "NetworkStateNotifier.h"
     
    102103        hash->insert(QWebSettings::DeleteButtonGraphic, QPixmap(QLatin1String(":webkit/resources/deleteButton.png")));
    103104        hash->insert(QWebSettings::InputSpeechButtonGraphic, QPixmap(QLatin1String(":webkit/resources/inputSpeech.png")));
     105        hash->insert(QWebSettings::SearchCancelButtonGraphic, QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
     106        hash->insert(QWebSettings::SearchCancelButtonPressedGraphic, QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
    104107    }
    105108
     
    373376    \value TextAreaSizeGripCornerGraphic The graphic shown for the size grip of text areas.
    374377    \value DeleteButtonGraphic The graphic shown for the WebKit-Editing-Delete-Button in Deletion UI.
     378    \value InputSpeechButtonGraphic The graphic shown in input fields that support speech recognition.
     379    \value SearchCancelButtonGraphic The graphic shown for clearing the text in a search field.
     380    \value SearchCancelButtonPressedGraphic The graphic shown when SearchCancelButtonGraphic is pressed.
    375381*/
    376382
  • trunk/WebKit/qt/Api/qwebsettings.h

    r72604 r73635  
    8686        TextAreaSizeGripCornerGraphic,
    8787        DeleteButtonGraphic,
    88         InputSpeechButtonGraphic
     88        InputSpeechButtonGraphic,
     89        SearchCancelButtonGraphic,
     90        SearchCancelButtonPressedGraphic
    8991    };
    9092    enum FontSize {
  • trunk/WebKit/qt/ChangeLog

    r73602 r73635  
     12010-12-09  Robert Hogan  <robert@webkit.org>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] Search input field doesn't have cancel button
     6
     7        Add a cancel button to the search field and make it customizable
     8        by the client. For now, use the close dialog button associated
     9        with the application's style as the default.
     10
     11        https://bugs.webkit.org/show_bug.cgi?id=42887
     12
     13        * Api/qwebsettings.cpp:
     14        (graphics):
     15        * Api/qwebsettings.h:
     16
    1172010-12-09  Siddharth Mathur  <siddharth.mathur@nokia.com>
    218
Note: See TracChangeset for help on using the changeset viewer.