[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

robert at webkit.org robert at webkit.org
Sun Feb 20 22:52:25 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 4603e3f9c68a765e47cf5f56f0d33d4a0b4d7eee
Author: robert at webkit.org <robert at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 12 20:27:43 2011 +0000

    2011-01-12  Robert Hogan  <robert at webkit.org>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [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:
    2011-01-12  Robert Hogan  <robert at webkit.org>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [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/graphics/qt/ImageQt.cpp:
            (loadResourcePixmap):
            * platform/qt/RenderThemeQt.cpp:
            (WebCore::RenderThemeQt::isControlStyled):
            (WebCore::RenderThemeQt::computeSizeBasedOnStyle):
            (WebCore::RenderThemeQt::paintSearchField):
            (WebCore::RenderThemeQt::adjustSearchFieldStyle):
            (WebCore::RenderThemeQt::adjustSearchFieldCancelButtonStyle):
            (WebCore::RenderThemeQt::convertToPaintingRect):
            (WebCore::RenderThemeQt::paintSearchFieldCancelButton):
            * platform/qt/RenderThemeQt.h:
    2011-01-12  Robert Hogan  <robert at webkit.org>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [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:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75632 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 4da0076..2daee47 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,31 @@
+2011-01-12  Robert Hogan  <robert at webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [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:
+
 2011-01-12  Nico Weber  <thakis at chromium.org>
 
         Unreviewed, test expectations.
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index ebe839e..b2bbdcf 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -487,7 +487,6 @@ fast/dom/open-and-close-by-DOM.html
 fast/dom/Window/new-window-opener.html
 fast/forms/001.html
 fast/forms/focus2.html
-fast/forms/search-cancel-button-mouseup.html
 fast/frames/001.html
 fast/text/monospace-width-cache.html
 
@@ -2322,7 +2321,6 @@ fast/forms/listbox-onchange.html
 fast/forms/listbox-selection-2.html
 fast/forms/listbox-selection.html
 fast/forms/onselect-textarea.html
-fast/forms/search-rtl.html
 fast/forms/select-writing-direction-natural.html
 fast/forms/tabbing-input-iframe.html
 fast/forms/textAreaLineHeight.html
@@ -2382,7 +2380,6 @@ fast/encoding/hebrew/8859-8-i.html
 fast/encoding/hebrew/logical.html
 fast/events/crash-on-mutate-during-drop.html
 fast/forms/option-mouseevents.html
-fast/forms/search-abs-pos-cancel-button.html
 fast/forms/text-control-intrinsic-widths.html
 fast/forms/textarea-metrics.html
 fast/history/window-open.html
@@ -2440,9 +2437,6 @@ fast/forms/listbox-deselect-scroll.html
 fast/forms/listbox-hit-test-zoomed.html
 fast/forms/negativeLineHeight.html
 fast/forms/placeholder-pseudo-style.html
-fast/forms/search-styled.html
-fast/forms/search-transformed.html
-fast/forms/search-zoomed.html
 fast/forms/textarea-align.html
 fast/forms/textarea-setinnerhtml.html
 fast/forms/textarea-width.html
@@ -3216,9 +3210,6 @@ fast/forms/radio-nested-labels.html
 fast/forms/radio_checked.html
 fast/forms/radio_checked_dynamic.html
 fast/forms/range-thumb-height-percentage.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/forms/searchfield-heights.html
 fast/forms/select-accesskey.html
 fast/forms/select-align.html
@@ -3553,7 +3544,6 @@ fast/repaint/reflection-redraw.html
 fast/repaint/reflection-repaint-test.html
 fast/repaint/renderer-destruction-by-invalidateSelection-crash.html
 fast/repaint/repaint-resized-overflow.html
-fast/repaint/search-field-cancel.html
 fast/repaint/selected-replaced.html
 fast/repaint/selection-clear.html
 fast/repaint/static-to-positioned.html
@@ -5216,10 +5206,6 @@ animations/suspend-resume-animation.html
 animations/suspend-resume-animation-events.html
 animations/stop-animation-on-suspend.html
 
-# [Qt] Search input field doesn't have cancel button
-# https://bugs.webkit.org/show_bug.cgi?id=42887
-fast/forms/search-cancel-button-events.html
-
 # [Qt] DRT sideeffect revealed by r63657
 # https://bugs.webkit.org/show_bug.cgi?id=42578
 http/tests/security/mixedContent/insecure-css-in-main-frame.html
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index f9a313e..b27fa37 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,41 @@
+2011-01-12  Robert Hogan  <robert at webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [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/graphics/qt/ImageQt.cpp:
+        (loadResourcePixmap):
+        * platform/qt/RenderThemeQt.cpp:
+        (WebCore::RenderThemeQt::isControlStyled):
+        (WebCore::RenderThemeQt::computeSizeBasedOnStyle):
+        (WebCore::RenderThemeQt::paintSearchField):
+        (WebCore::RenderThemeQt::adjustSearchFieldStyle):
+        (WebCore::RenderThemeQt::adjustSearchFieldCancelButtonStyle):
+        (WebCore::RenderThemeQt::convertToPaintingRect):
+        (WebCore::RenderThemeQt::paintSearchFieldCancelButton):
+        * platform/qt/RenderThemeQt.h:
+
 2011-01-12  Andrey Kosyakov  <caseq at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/Source/WebCore/platform/graphics/qt/ImageQt.cpp b/Source/WebCore/platform/graphics/qt/ImageQt.cpp
index 49afd29..b66a1ca 100644
--- a/Source/WebCore/platform/graphics/qt/ImageQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageQt.cpp
@@ -68,6 +68,10 @@ static QPixmap loadResourcePixmap(const char *name)
         pixmap = QWebSettings::webGraphic(QWebSettings::DeleteButtonGraphic);
     else if (!qstrcmp(name, "inputSpeech"))
         pixmap = QWebSettings::webGraphic(QWebSettings::InputSpeechButtonGraphic);
+    else if (!qstrcmp(name, "searchCancelButton"))
+        pixmap = QWebSettings::webGraphic(QWebSettings::SearchCancelButtonGraphic);
+    else if (!qstrcmp(name, "searchCancelButtonPressed"))
+        pixmap = QWebSettings::webGraphic(QWebSettings::SearchCancelButtonPressedGraphic);
 
     return pixmap;
 }
diff --git a/Source/WebCore/platform/qt/RenderThemeQt.cpp b/Source/WebCore/platform/qt/RenderThemeQt.cpp
index 2cc3625..9a1775c 100644
--- a/Source/WebCore/platform/qt/RenderThemeQt.cpp
+++ b/Source/WebCore/platform/qt/RenderThemeQt.cpp
@@ -50,6 +50,7 @@
 #include "Page.h"
 #include "QWebPageClient.h"
 #include "QtStyleOptionWebComboBox.h"
+#include "qwebsettings.h"
 #include "RenderBox.h"
 #if ENABLE(PROGRESS_TAG)
 #include "RenderProgress.h"
@@ -92,6 +93,15 @@ inline static void initStyleOption(QWidget *widget, QStyleOption& option)
         option.state = QStyle::State_Active | QStyle::State_Enabled;
     }
 }
+// These values all match Safari/Win/Chromium
+static const float defaultControlFontPixelSize = 13;
+static const float defaultCancelButtonSize = 9;
+static const float minCancelButtonSize = 5;
+static const float maxCancelButtonSize = 21;
+static const float defaultSearchFieldResultsDecorationSize = 13;
+static const float minSearchFieldResultsDecorationSize = 9;
+static const float maxSearchFieldResultsDecorationSize = 30;
+static const float defaultSearchFieldResultsButtonWidth = 18;
 
 
 StylePainter::StylePainter(RenderThemeQt* theme, const PaintInfo& paintInfo)
@@ -186,6 +196,7 @@ bool RenderThemeQt::isControlStyled(const RenderStyle* style, const BorderData&
     case PushButtonPart:
     case ButtonPart:
     case MenulistPart:
+    // FIXME: Need to add SearchFieldPart if it should be style-able.
     case TextFieldPart:
     case TextAreaPart:
         return true;
@@ -201,6 +212,20 @@ int RenderThemeQt::popupInternalPaddingBottom(RenderStyle* style) const
 {
     return 1;
 }
+#else
+// Remove this when SearchFieldPart is style-able in RenderTheme::isControlStyled()
+bool RenderThemeQt::isControlStyled(const RenderStyle* style, const BorderData& border, const FillLayer& fill, const Color& backgroundColor) const
+{
+    switch (style->appearance()) {
+    case SearchFieldPart:
+        // Test the style to see if the UA border and background match.
+        return (style->border() != border
+                || *style->backgroundLayers() != fill
+                || style->visitedDependentColor(CSSPropertyBackgroundColor) != backgroundColor);
+    default:
+        return RenderTheme::isControlStyled(style, border, fill, backgroundColor);
+    }
+}
 #endif
 
 // for some widget painting, we need to fallback to Windows style
@@ -413,6 +438,7 @@ void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
 
     switch (renderStyle->appearance()) {
     case TextAreaPart:
+    case SearchFieldPart:
     case TextFieldPart: {
         int padding = findFrameLineWidth(style);
 
@@ -611,6 +637,11 @@ bool RenderThemeQt::paintButton(RenderObject* o, const PaintInfo& i, const IntRe
 
 void RenderThemeQt::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
 {
+    // Resetting the style like this leads to differences like:
+    // - RenderTextControl {INPUT} at (2,2) size 168x25 [bgcolor=#FFFFFF] border: (2px inset #000000)]
+    // + RenderTextControl {INPUT} at (2,2) size 166x26
+    // in layout tests when a CSS style is applied that doesn't affect background color, border or
+    // padding. Just worth keeping in mind!
     style->setBackgroundColor(Color::transparent);
     style->resetBorder();
     style->resetPadding();
@@ -886,28 +917,73 @@ void RenderThemeQt::adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle* style
 bool RenderThemeQt::paintSearchField(RenderObject* o, const PaintInfo& pi,
                                      const IntRect& r)
 {
-    return true;
+    return paintTextField(o, pi, r);
 }
 
 void RenderThemeQt::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style,
                                            Element* e) const
 {
-    notImplemented();
-    RenderTheme::adjustSearchFieldStyle(selector, style, e);
+    // Resetting the style like this leads to differences like:
+    // - RenderTextControl {INPUT} at (2,2) size 168x25 [bgcolor=#FFFFFF] border: (2px inset #000000)]
+    // + RenderTextControl {INPUT} at (2,2) size 166x26
+    // in layout tests when a CSS style is applied that doesn't affect background color, border or
+    // padding. Just worth keeping in mind!
+    style->setBackgroundColor(Color::transparent);
+    style->resetBorder();
+    style->resetPadding();
+    computeSizeBasedOnStyle(style);
 }
 
 void RenderThemeQt::adjustSearchFieldCancelButtonStyle(CSSStyleSelector* selector, RenderStyle* style,
                                                        Element* e) const
 {
-    notImplemented();
-    RenderTheme::adjustSearchFieldCancelButtonStyle(selector, style, e);
+    // Logic taken from RenderThemeChromium.cpp.
+    // Scale the button size based on the font size.
+    float fontScale = style->fontSize() / defaultControlFontPixelSize;
+    int cancelButtonSize = lroundf(qMin(qMax(minCancelButtonSize, defaultCancelButtonSize * fontScale), maxCancelButtonSize));
+    style->setWidth(Length(cancelButtonSize, Fixed));
+    style->setHeight(Length(cancelButtonSize, Fixed));
+}
+
+// Function taken from RenderThemeChromium.cpp
+IntRect RenderThemeQt::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const
+{
+    // Compute an offset between the part renderer and the input renderer.
+    IntSize offsetFromInputRenderer = -(partRenderer->offsetFromAncestorContainer(inputRenderer));
+    // Move the rect into partRenderer's coords.
+    partRect.move(offsetFromInputRenderer);
+    // Account for the local drawing offset.
+    partRect.move(localOffset.x(), localOffset.y());
+
+    return partRect;
 }
 
 bool RenderThemeQt::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& pi,
                                                  const IntRect& r)
 {
-    notImplemented();
-    return RenderTheme::paintSearchFieldCancelButton(o, pi, r);
+    // Logic copied from RenderThemeChromium.cpp.
+
+    // Get the renderer of <input> element.
+    Node* input = o->node()->shadowAncestorNode();
+    if (!input->renderer()->isBox())
+        return false;
+    RenderBox* inputRenderBox = toRenderBox(input->renderer());
+    IntRect inputContentBox = inputRenderBox->contentBoxRect();
+
+    // Make sure the scaled button stays square and will fit in its parent's box.
+    int cancelButtonSize = qMin(inputContentBox.width(), qMin(inputContentBox.height(), r.height()));
+    // Calculate cancel button's coordinates relative to the input element.
+    // Center the button vertically.  Round up though, so if it has to be one pixel off-center, it will
+    // be one pixel closer to the bottom of the field.  This tends to look better with the text.
+    IntRect cancelButtonRect(o->offsetFromAncestorContainer(inputRenderBox).width(),
+                             inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2,
+                             cancelButtonSize, cancelButtonSize);
+    IntRect paintingRect = convertToPaintingRect(inputRenderBox, o, cancelButtonRect, r);
+    static Image* cancelImage = Image::loadPlatformResource("searchCancelButton").releaseRef();
+    static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelButtonPressed").releaseRef();
+    pi.context->drawImage(isPressed(o) ? cancelPressedImage : cancelImage,
+                                 o->style()->colorSpace(), paintingRect);
+    return false;
 }
 
 void RenderThemeQt::adjustSearchFieldDecorationStyle(CSSStyleSelector* selector, RenderStyle* style,
diff --git a/Source/WebCore/platform/qt/RenderThemeQt.h b/Source/WebCore/platform/qt/RenderThemeQt.h
index c28168a..6981641 100644
--- a/Source/WebCore/platform/qt/RenderThemeQt.h
+++ b/Source/WebCore/platform/qt/RenderThemeQt.h
@@ -81,8 +81,8 @@ public:
 
     virtual double caretBlinkInterval() const;
 
-#if USE(QT_MOBILE_THEME)
     virtual bool isControlStyled(const RenderStyle*, const BorderData&, const FillLayer&, const Color& backgroundColor) const;
+#if USE(QT_MOBILE_THEME)
     virtual int popupInternalPaddingBottom(RenderStyle*) const;
 #endif
 
@@ -180,6 +180,8 @@ private:
 
     QStyle* fallbackStyle() const;
 
+    IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const;
+
     Page* m_page;
 
 #ifdef Q_WS_MAC
diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp
index ed425c2..6c59d73 100644
--- a/WebKit/qt/Api/qwebsettings.cpp
+++ b/WebKit/qt/Api/qwebsettings.cpp
@@ -48,6 +48,7 @@
 #include <QSharedData>
 #include <QUrl>
 #include <QFileInfo>
+#include <QStyle>
 
 #include "NetworkStateNotifier.h"
 
@@ -101,6 +102,8 @@ static WebGraphicHash* graphics()
         hash->insert(QWebSettings::TextAreaSizeGripCornerGraphic, QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));
         hash->insert(QWebSettings::DeleteButtonGraphic, QPixmap(QLatin1String(":webkit/resources/deleteButton.png")));
         hash->insert(QWebSettings::InputSpeechButtonGraphic, QPixmap(QLatin1String(":webkit/resources/inputSpeech.png")));
+        hash->insert(QWebSettings::SearchCancelButtonGraphic, QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
+        hash->insert(QWebSettings::SearchCancelButtonPressedGraphic, QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
     }
 
     return hash;
@@ -372,6 +375,9 @@ QWebSettings* QWebSettings::globalSettings()
     \value DefaultFrameIconGraphic The default icon for QWebFrame::icon().
     \value TextAreaSizeGripCornerGraphic The graphic shown for the size grip of text areas.
     \value DeleteButtonGraphic The graphic shown for the WebKit-Editing-Delete-Button in Deletion UI.
+    \value InputSpeechButtonGraphic The graphic shown in input fields that support speech recognition.
+    \value SearchCancelButtonGraphic The graphic shown for clearing the text in a search field.
+    \value SearchCancelButtonPressedGraphic The graphic shown when SearchCancelButtonGraphic is pressed.
 */
 
 /*!
diff --git a/WebKit/qt/Api/qwebsettings.h b/WebKit/qt/Api/qwebsettings.h
index 0569ab0..008035b 100644
--- a/WebKit/qt/Api/qwebsettings.h
+++ b/WebKit/qt/Api/qwebsettings.h
@@ -85,7 +85,9 @@ public:
         DefaultFrameIconGraphic,
         TextAreaSizeGripCornerGraphic,
         DeleteButtonGraphic,
-        InputSpeechButtonGraphic
+        InputSpeechButtonGraphic,
+        SearchCancelButtonGraphic,
+        SearchCancelButtonPressedGraphic
     };
     enum FontSize {
         MinimumFontSize,
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index f03a0d3..9b49a2b 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,19 @@
+2011-01-12  Robert Hogan  <robert at webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [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:
+
 2011-01-12  Sheriff Bot  <webkit.review.bot at gmail.com>
 
         Unreviewed, rolling out r74344.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list