Modified: trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp (122646 => 122647)
--- trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp 2012-07-13 23:55:18 UTC (rev 122646)
+++ trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp 2012-07-14 00:15:43 UTC (rev 122647)
@@ -66,7 +66,7 @@
static const float buttonPaddingTop = 2;
static const float buttonPaddingBottom = 3;
static const float menuListPadding = 9;
-static const float textFieldPadding = 5;
+static const float textFieldPadding = 10;
static const float radiusFactor = 0.36;
static const float progressBarChunkPercentage = 0.2;
#if ENABLE(PROGRESS_TAG)
@@ -108,6 +108,44 @@
return hash;
}
+/*
+ * The octants' indices are identified below, for each point (x,y)
+ * in the first octant, we can populate the 7 others with the corresponding
+ * point.
+ *
+ * index | xpos | ypos
+ * xd ---------------------------
+ * 4 |<--->| 3 0 | xd + x | y
+ * __________________ 1 | xd + y | x
+ * / \ 2 | xd + y | -x
+ * 5 | .(c) | 2 3 | xd + x | -y
+ * 6 | | 1 4 | -xd - x | -y
+ * \__________________/ 5 | -xd - y | -x
+ * 6 | -xd - y | x
+ * 7 0 7 | -xd - x | y
+ *
+ **/
+
+static void addPointToOctants(QVector<QPainterPath>& octants, const QPointF& center, qreal x, qreal y , int xDelta = 0)
+{
+ ASSERT(octants.count() == 8);
+
+ for (short i = 0; i < 8; ++i) {
+ QPainterPath& octant = octants[i];
+ QPointF pos(center);
+ // The Gray code corresponding to the octant's index helps doing the math in a more generic way.
+ const short gray = (i >> 1) ^ i;
+ const qreal xOffset = xDelta + ((gray & 1) ? y : x);
+ pos.ry() += ((gray & 2)? -1 : 1) * ((gray & 1) ? x : y);
+ pos.rx() += (i < 4) ? xOffset : -xOffset;
+
+ if (octant.elementCount())
+ octant.lineTo(pos);
+ else // The path is empty. Initialize the start point.
+ octant.moveTo(pos);
+ }
+}
+
static void drawControlBackground(QPainter* painter, const QPen& pen, const QRect& rect, const QBrush& brush)
{
QPen oldPen = painter->pen();
@@ -116,28 +154,32 @@
painter->setPen(pen);
painter->setBrush(brush);
- const int line = 1;
- const QRect paddedRect = rect.adjusted(line, line, -line, -line);
+ static const qreal line = 1.5;
+ const QRectF paddedRect = rect.adjusted(line, line, -line, -line);
- const int n = 3;
+ static const int n = 3;
const qreal invPow = 1 / double(n);
ASSERT(paddedRect.width() >= paddedRect.height());
const int radius = paddedRect.height() / 2;
const int xDelta = paddedRect.width() / 2 - radius;
- const QPoint center = paddedRect.topLeft() + QPoint(xDelta + radius, radius);
- qreal x, y;
- QPainterPath path;
- path.moveTo(-xDelta, -radius);
- for (y = -radius ; y <= radius; ++y) {
- x = -xDelta - radius * pow(1 - pow(qAbs(y) / radius , n), invPow);
- path.lineTo(x, y);
+ const QPointF center = paddedRect.center();
+ qreal x = 0;
+ qreal y;
+ QVector<QPainterPath> octants(8);
+ // Stay within reasonable distance from edge values, which can cause artifacts at certain zoom levels.
+ static const float epsilon = 0.02;
+ for (y = radius - epsilon; y - epsilon > x; y -= 0.5) {
+ x = radius * pow(1 - pow(qAbs(y) / radius , n), invPow);
+ addPointToOctants(octants, center, x, y, xDelta);
}
- for (y = radius ; y >= -radius; --y) {
- x = xDelta + radius * pow(1 - pow(qAbs(y) / radius , n), invPow);
- path.lineTo(x, y);
+
+ QPainterPath path = octants.first();
+ for (int i = 1; i < 8; ++i) {
+ // Due to the orientation of the arcs, we need to reverse the paths with odd indices.
+ QPainterPath subPath = (i % 2) ? octants.at(i).toReversed() : octants.at(i);
+ path.connectPath(subPath);
}
path.closeSubpath();
- path.translate(center);
painter->drawPath(path);
painter->setPen(oldPen);
@@ -152,7 +194,7 @@
static inline QPen borderPen(QPainter* painter = 0)
{
- return QPen(darkColor, 0.4 * painterScale(painter), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
+ return QPen(darkColor, qMin(1.0, 0.4 * painterScale(painter)));
}
QSharedPointer<StylePainter> RenderThemeQtMobile::getStylePainter(const PaintInfo& pi)
@@ -383,14 +425,14 @@
if (!findCachedControl(id, &result)) {
const int focusFrame = painterScale(painter);
- result = QPixmap(size + QSize(2 * focusFrame, 2 * focusFrame));
+ result = QPixmap(size);
result.fill(Qt::transparent);
const QRect rect = result.rect().adjusted(focusFrame, focusFrame, -focusFrame, -focusFrame);
QPainter cachePainter(&result);
drawControlBackground(&cachePainter, borderPen(painter), rect, Qt::white);
if (focused) {
- QPen focusPen(highlightColor, focusFrame, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
+ QPen focusPen(highlightColor, 1.2 * painterScale(painter), Qt::SolidLine);
drawControlBackground(&cachePainter, focusPen, rect, Qt::NoBrush);
}
insertIntoCache(id, result);
@@ -697,6 +739,10 @@
// padding. Just worth keeping in mind!
style->setBackgroundColor(Color::transparent);
style->resetBorder();
+ style->setBorderTopWidth(frameWidth);
+ style->setBorderRightWidth(frameWidth);
+ style->setBorderBottomWidth(frameWidth);
+ style->setBorderLeftWidth(frameWidth);
style->resetPadding();
computeSizeBasedOnStyle(style);
style->setPaddingLeft(Length(textFieldPadding, Fixed));