Commit 4e507343 authored by diegohcg@webkit.org's avatar diegohcg@webkit.org

2011-03-27 Diego Gonzalez <diegohcg@webkit.org>

    [Qt] Re-draw the <input> fields for Qt Mobile Theme to do not override elements already styled.
    https://bugs.webkit.org/show_bug.cgi?id=57007

    Reviewed by Kenneth Rohde Christiansen.

    * CodeGenerators.pri:
    * css/themeQtMobile.css: Removed.
    * platform/qt/QtMobileWebStyle.cpp:
    (drawRectangularControlBackground):
    (QtMobileWebStyle::drawPrimitive):
    (QtMobileWebStyle::drawComplexControl):
    * platform/qt/QtMobileWebStyle.h:
    * platform/qt/RenderThemeQt.cpp:
    (WebCore::RenderThemeQt::isControlStyled):
    (WebCore::RenderThemeQt::paintTextField):

git-svn-id: svn://svn.chromium.org/blink/trunk@83051 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8040ceb5
2011-03-27 Diego Gonzalez <diegohcg@webkit.org>
Reviewed by Kenneth Rohde Christiansen.
[Qt] Re-draw the <input> fields for Qt Mobile Theme to do not override elements already styled.
https://bugs.webkit.org/show_bug.cgi?id=57007
* CodeGenerators.pri:
* css/themeQtMobile.css: Removed.
* platform/qt/QtMobileWebStyle.cpp:
(drawRectangularControlBackground):
(QtMobileWebStyle::drawPrimitive):
(QtMobileWebStyle::drawComplexControl):
* platform/qt/QtMobileWebStyle.h:
* platform/qt/RenderThemeQt.cpp:
(WebCore::RenderThemeQt::isControlStyled):
(WebCore::RenderThemeQt::paintTextField):
2011-04-06 Jia Pu <jpu@apple.com>
Reviewed by Darin Adler.
......@@ -62,8 +62,7 @@ STYLESHEETS_EMBED = \
$$PWD/css/mediaControls.css \
$$PWD/css/mediaControlsQt.css \
$$PWD/css/mediaControlsQtFullscreen.css \
$$PWD/css/themeQtNoListboxes.css \
$$PWD/css/themeQtMobile.css
$$PWD/css/themeQtNoListboxes.css
v8 {
IDL_BINDINGS += \
......
/*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
input[type="button"],
input[type="submit"],
input[type="reset"],
input[type="file"]::-webkit-file-upload-button, button,
select {
padding: 2px 18px 3px 18px;
border: 1px solid gray;
-webkit-border-radius:5px;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0.0, rgba(0, 0, 0, 0.35)), color-stop(0.4, rgba(0, 0, 0, 0.0)));
background-color: #ffffff;
color: #3e3e3e;
}
input[type="button"]:disabled,
input[type="submit"]:disabled,
input[type="reset"]:disabled,
input[type="file"]:disabled::-webkit-file-upload-button,
button:disabled,
select:disabled {
border: 1px solid gray;
}
input[type="button"]:active,
input[type="submit"]:active,
input[type="reset"]:active,
input[type="file"]:active::-webkit-file-upload-button,
button:active,
select:active {
background: ButtonShadow;
}
input[type="button"]:active:disabled,
input[type="submit"]:active:disabled,
input[type="reset"]:active:disabled,
input[type="file"]:active:disabled::-webkit-file-upload-button,
button:active:disabled,
select:active:disabled {
border: 1px solid gray;
}
input:not([type]),
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="color"],
input[type="search"],
input[type="date"],
input[type="datetime"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input[type="time"],
input[type="number"],
input[type="url"],
textarea {
border: 1px solid gray;
background: -webkit-gradient(linear, left top, left 30, color-stop(0.0, rgba(0, 0, 0, 0.35)), color-stop(0.2, rgba(0, 0, 0, 0.0)));
background-color: #ffffff;
color: #3e3e3e;
-webkit-border-radius:5px;
}
input:not([type]):disabled,
input[type="text"]:disabled,
input[type="password"]:disabled,
input[type="email"]:disabled,
input[type="tel"]:disabled,
input[type="color"]:disabled,
input[type="search"]:disabled,
input[type="date"]:disabled,
input[type="datetime"]:disabled,
input[type="datetime-local"]:disabled,
input[type="month"]:disabled,
input[type="week"]:disabled,
input[type="time"]:disabled,
input[type="number"]:disabled,
input[type="url"]:disabled,
textarea:disabled {
border: 1px solid gray;
background: -webkit-gradient(linear, left top, left 30, color-stop(0.0, rgba(0, 0, 0, 0.3)), color-stop(0.2, rgba(0, 0, 0, 0.0)));
background-color: #ffffff;
color: #e5e5e5;
}
input:not([type]):active,
input[type="text"]:active,
input[type="password"]:active,
input[type="email"]:active,
input[type="tel"]:active,
input[type="color"]:active,
input[type="search"]:active,
input[type="date"]:active,
input[type="datetime"]:active,
input[type="datetime-local"]:active,
input[type="month"]:active,
input[type="week"]:active,
input[type="time"]:active,
input[type="number"]:active,
input[type="url"]:active,
textarea:active {
background: ButtonShadow;
}
video {
background-color: #000000;
}
......@@ -34,12 +34,13 @@ static inline void drawRectangularControlBackground(QPainter* painter, const QPe
{
QPen oldPen = painter->pen();
QBrush oldBrush = painter->brush();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(pen);
painter->setBrush(brush);
int line = 1;
painter->drawRect(rect.adjusted(line, line, -line, -line));
painter->drawRoundedRect(rect.adjusted(line, line, -line, -line),
/* xRadius */ 5.0, /* yRadious */ 5.0);
painter->setPen(oldPen);
painter->setBrush(oldBrush);
}
......@@ -146,7 +147,9 @@ void QtMobileWebStyle::drawControl(ControlElement element, const QStyleOption* o
linearGradient.setColorAt(0.5, Qt::white);
}
drawRectangularControlBackground(painter, QPen(disabled ? Qt::lightGray : Qt::darkGray), rect, linearGradient);
painter->setPen(QPen(disabled ? Qt::lightGray : Qt::darkGray));
painter->setBrush(linearGradient);
painter->drawRect(rect);
rect.adjust(1, 1, -1, -1);
if (option->state & State_Off)
......@@ -169,10 +172,58 @@ void QtMobileWebStyle::drawControl(ControlElement element, const QStyleOption* o
painter->drawPixmap(option->rect.x(), option->rect.y(), radio);
break;
}
case CE_PushButton: {
QRect rect = option->rect;
QPen pen(Qt::darkGray, 1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter->setPen(pen);
const bool sunken = (option->state & State_Sunken);
if (sunken) {
drawRectangularControlBackground(painter, pen, rect, QBrush(Qt::darkGray));
break;
}
QLinearGradient linearGradient(rect.bottomLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y() - /* offset limit for gradient */ 20));
linearGradient.setColorAt(0.0, Qt::gray);
linearGradient.setColorAt(0.4, Qt::white);
drawRectangularControlBackground(painter, pen, rect, linearGradient);
break;
}
default:
QWindowsStyle::drawControl(element, option, painter, widget);
}
}
void QtMobileWebStyle::drawPrimitive(PrimitiveElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const
{
switch (element) {
case QStyle::PE_PanelLineEdit: {
const bool disabled = !(option->state & State_Enabled);
const bool sunken = (option->state & State_Sunken);
QRect rect = option->rect;
QPen pen(Qt::darkGray, 1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter->setPen(pen);
if (sunken) {
drawRectangularControlBackground(painter, pen, rect, QBrush(Qt::darkGray));
break;
}
QLinearGradient linearGradient(rect.topLeft(), QPoint(rect.topLeft().x(), rect.topLeft().y() + 20));
if (disabled) {
linearGradient.setColorAt(0.0, Qt::lightGray);
linearGradient.setColorAt(0.3, Qt::white);
} else {
linearGradient.setColorAt(0.0, Qt::darkGray);
linearGradient.setColorAt(0.35, Qt::white);
}
drawRectangularControlBackground(painter, pen, rect, linearGradient);
break;
}
default:
QWindowsStyle::drawPrimitive(element, option, painter, widget);
}
}
void QtMobileWebStyle::drawMultipleComboButton(QPainter* painter, const QSize& size, QColor color) const
{
......@@ -253,7 +304,6 @@ void QtMobileWebStyle::drawComplexControl(ComplexControl control, const QStyleOp
{
switch (control) {
case CC_ComboBox: {
bool multiple = false;
const bool disabled = !(option->state & State_Enabled);
......@@ -274,7 +324,15 @@ void QtMobileWebStyle::drawComplexControl(ComplexControl control, const QStyleOp
if (!(cmb->subControls & SC_ComboBoxArrow))
break;
QRect rect = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
QRect rect = option->rect;
QLinearGradient linearGradient(rect.bottomLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y() - /* offset limit for gradient */ 20));
linearGradient.setColorAt(0.0, Qt::gray);
linearGradient.setColorAt(0.4, Qt::white);
QPen pen(Qt::darkGray, 1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter->setPen(pen);
drawRectangularControlBackground(painter, pen, rect, linearGradient);
rect = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
QPixmap pic = findComboButton(rect.size(), multiple, disabled);
if (pic.isNull())
......@@ -293,3 +351,4 @@ void QtMobileWebStyle::drawComplexControl(ComplexControl control, const QStyleOp
QWindowsStyle::drawComplexControl(control, option, painter, widget);
}
}
......@@ -29,6 +29,7 @@ public:
void drawControl(ControlElement, const QStyleOption*, QPainter*, const QWidget*) const;
void drawComplexControl(ComplexControl, const QStyleOptionComplex*, QPainter*, const QWidget*) const;
void drawPrimitive(PrimitiveElement, const QStyleOption*, QPainter*, const QWidget*) const;
private:
void drawChecker(QPainter* painter, int size, QColor color) const;
......
......@@ -78,7 +78,6 @@
#include <QStyleOptionSlider>
#include <QWidget>
namespace WebCore {
using namespace HTMLNames;
......@@ -198,10 +197,13 @@ 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 SearchFieldPart:
case TextFieldPart:
case TextAreaPart:
return true;
// Test the style to see if the UA border and background match.
return (style->border() != border
|| *style->backgroundLayers() != fill
|| style->visitedDependentColor(CSSPropertyBackgroundColor) != backgroundColor);
case CheckboxPart:
case RadioPart:
return false;
......@@ -257,9 +259,6 @@ String RenderThemeQt::extraDefaultStyleSheet()
String result = RenderTheme::extraDefaultStyleSheet();
#if ENABLE(NO_LISTBOX_RENDERING)
result += String(themeQtNoListboxesUserAgentStyleSheet, sizeof(themeQtNoListboxesUserAgentStyleSheet));
#endif
#if USE(QT_MOBILE_THEME)
result += String(themeQtMobileUserAgentStyleSheet, sizeof(themeQtMobileUserAgentStyleSheet));
#endif
return result;
}
......@@ -448,7 +447,6 @@ void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
case SearchFieldPart:
case TextFieldPart: {
int padding = findFrameLineWidth(style);
renderStyle->setPaddingLeft(Length(padding, Fixed));
renderStyle->setPaddingRight(Length(padding, Fixed));
renderStyle->setPaddingTop(Length(padding, Fixed));
......@@ -458,7 +456,6 @@ void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
default:
break;
}
// If the width and height are both specified, then we have nothing to do.
if (!renderStyle->width().isIntrinsicOrAuto() && !renderStyle->height().isAuto())
return;
......@@ -480,6 +477,7 @@ void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
size = QSize(radioWidth, radioWidth);
break;
}
#if !USE(QT_MOBILE_THEME)
case PushButtonPart:
case ButtonPart: {
QStyleOptionButton styleOption;
......@@ -509,6 +507,7 @@ void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
size.setHeight(menuListSize.height());
break;
}
#endif
default:
break;
}
......@@ -564,13 +563,14 @@ void RenderThemeQt::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* s
fontDescription.setComputedSize(style->fontSize());
#endif
#if !USE(QT_MOBILE_THEME)
FontFamily fontFamily;
fontFamily.setFamily(m_buttonFontFamily);
fontDescription.setFamily(fontFamily);
style->setFontDescription(fontDescription);
style->font().update(selector->fontSelector());
#endif
style->setLineHeight(RenderStyle::initialLineHeight());
setButtonSize(style);
setButtonPadding(style);
}
......@@ -580,6 +580,7 @@ void RenderThemeQt::setButtonSize(RenderStyle* style) const
computeSizeBasedOnStyle(style);
}
#if !USE(QT_MOBILE_THEME)
void RenderThemeQt::setButtonPadding(RenderStyle* style) const
{
QStyleOptionButton styleOption;
......@@ -609,12 +610,22 @@ void RenderThemeQt::setButtonPadding(RenderStyle* style) const
// Can't use this right now because we don't have the baseline to compensate
// paddingBottom = layoutRect.bottom() - contentsRect.bottom();
}
style->setPaddingLeft(Length(paddingLeft, Fixed));
style->setPaddingRight(Length(paddingRight, Fixed));
style->setPaddingTop(Length(paddingTop, Fixed));
style->setPaddingBottom(Length(paddingBottom, Fixed));
}
#else
void RenderThemeQt::setButtonPadding(RenderStyle* style) const
{
if (!style)
return;
style->setPaddingLeft(Length(18, Fixed));
style->setPaddingRight(Length(18, Fixed));
style->setPaddingTop(Length(2, Fixed));
style->setPaddingBottom(Length(3, Fixed));
}
#endif
bool RenderThemeQt::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& r)
{
......@@ -662,7 +673,8 @@ bool RenderThemeQt::paintTextField(RenderObject* o, const PaintInfo& i, const In
initStyleOption(p.widget, panel);
panel.rect = r;
panel.lineWidth = findFrameLineWidth(qStyle());
panel.state |= QStyle::State_Sunken;
if (isPressed(o))
panel.state |= QStyle::State_Sunken;
panel.features = QStyleOptionFrameV2::None;
// Get the correct theme data for a text field
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment