Changeset 122647 in webkit
- Timestamp:
- Jul 13, 2012 5:15:43 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r122642 r122647 1 2012-07-13 Pierre Rossi <pierre.rossi@gmail.com> 2 3 [Qt] Improve the mobile theme slightly 4 https://bugs.webkit.org/show_bug.cgi?id=90806 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Improve drawing of the mobile theme's controls' background. 9 10 Ensure the focus ring never appears with the mobile theme, since it 11 looks bad in combination with the highlights. 12 13 No new tests. The painting code from the mobile theme is still 14 not covered specifically (it will when we revive pixel tests). 15 16 * platform/qt/RenderThemeQtMobile.cpp: 17 (WebCore): 18 (WebCore::addPointToOctants): Added. This is simply a helper to avoid 19 doing too much duplicate work in drawControlBackground. 20 (WebCore::drawControlBackground): Rely on the octant logic added above 21 and take the opportunity to increase the granularity. 22 (WebCore::borderPen): 23 (WebCore::StylePainterMobile::findLineEdit): 24 (WebCore::RenderThemeQtMobile::adjustTextFieldStyle): 25 * platform/qt/RenderThemeQtMobile.h: 26 (RenderThemeQtMobile): 27 (WebCore::RenderThemeQtMobile::supportsFocusRing): 28 1 29 2012-07-13 Julien Chaffraix <jchaffraix@webkit.org> 2 30 -
trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp
r119547 r122647 67 67 static const float buttonPaddingBottom = 3; 68 68 static const float menuListPadding = 9; 69 static const float textFieldPadding = 5;69 static const float textFieldPadding = 10; 70 70 static const float radiusFactor = 0.36; 71 71 static const float progressBarChunkPercentage = 0.2; … … 109 109 } 110 110 111 /* 112 * The octants' indices are identified below, for each point (x,y) 113 * in the first octant, we can populate the 7 others with the corresponding 114 * point. 115 * 116 * index | xpos | ypos 117 * xd --------------------------- 118 * 4 |<--->| 3 0 | xd + x | y 119 * __________________ 1 | xd + y | x 120 * / \ 2 | xd + y | -x 121 * 5 | .(c) | 2 3 | xd + x | -y 122 * 6 | | 1 4 | -xd - x | -y 123 * \__________________/ 5 | -xd - y | -x 124 * 6 | -xd - y | x 125 * 7 0 7 | -xd - x | y 126 * 127 **/ 128 129 static void addPointToOctants(QVector<QPainterPath>& octants, const QPointF& center, qreal x, qreal y , int xDelta = 0) 130 { 131 ASSERT(octants.count() == 8); 132 133 for (short i = 0; i < 8; ++i) { 134 QPainterPath& octant = octants[i]; 135 QPointF pos(center); 136 // The Gray code corresponding to the octant's index helps doing the math in a more generic way. 137 const short gray = (i >> 1) ^ i; 138 const qreal xOffset = xDelta + ((gray & 1) ? y : x); 139 pos.ry() += ((gray & 2)? -1 : 1) * ((gray & 1) ? x : y); 140 pos.rx() += (i < 4) ? xOffset : -xOffset; 141 142 if (octant.elementCount()) 143 octant.lineTo(pos); 144 else // The path is empty. Initialize the start point. 145 octant.moveTo(pos); 146 } 147 } 148 111 149 static void drawControlBackground(QPainter* painter, const QPen& pen, const QRect& rect, const QBrush& brush) 112 150 { … … 117 155 painter->setBrush(brush); 118 156 119 const int line = 1;120 const QRect paddedRect = rect.adjusted(line, line, -line, -line);121 122 const int n = 3;157 static const qreal line = 1.5; 158 const QRectF paddedRect = rect.adjusted(line, line, -line, -line); 159 160 static const int n = 3; 123 161 const qreal invPow = 1 / double(n); 124 162 ASSERT(paddedRect.width() >= paddedRect.height()); 125 163 const int radius = paddedRect.height() / 2; 126 164 const int xDelta = paddedRect.width() / 2 - radius; 127 const QPoint center = paddedRect.topLeft() + QPoint(xDelta + radius, radius); 128 qreal x, y; 129 QPainterPath path; 130 path.moveTo(-xDelta, -radius); 131 for (y = -radius ; y <= radius; ++y) { 132 x = -xDelta - radius * pow(1 - pow(qAbs(y) / radius , n), invPow); 133 path.lineTo(x, y); 134 } 135 for (y = radius ; y >= -radius; --y) { 136 x = xDelta + radius * pow(1 - pow(qAbs(y) / radius , n), invPow); 137 path.lineTo(x, y); 165 const QPointF center = paddedRect.center(); 166 qreal x = 0; 167 qreal y; 168 QVector<QPainterPath> octants(8); 169 // Stay within reasonable distance from edge values, which can cause artifacts at certain zoom levels. 170 static const float epsilon = 0.02; 171 for (y = radius - epsilon; y - epsilon > x; y -= 0.5) { 172 x = radius * pow(1 - pow(qAbs(y) / radius , n), invPow); 173 addPointToOctants(octants, center, x, y, xDelta); 174 } 175 176 QPainterPath path = octants.first(); 177 for (int i = 1; i < 8; ++i) { 178 // Due to the orientation of the arcs, we need to reverse the paths with odd indices. 179 QPainterPath subPath = (i % 2) ? octants.at(i).toReversed() : octants.at(i); 180 path.connectPath(subPath); 138 181 } 139 182 path.closeSubpath(); 140 path.translate(center);141 183 142 184 painter->drawPath(path); … … 153 195 static inline QPen borderPen(QPainter* painter = 0) 154 196 { 155 return QPen(darkColor, 0.4 * painterScale(painter), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);197 return QPen(darkColor, qMin(1.0, 0.4 * painterScale(painter))); 156 198 } 157 199 … … 384 426 if (!findCachedControl(id, &result)) { 385 427 const int focusFrame = painterScale(painter); 386 result = QPixmap(size + QSize(2 * focusFrame, 2 * focusFrame));428 result = QPixmap(size); 387 429 result.fill(Qt::transparent); 388 430 const QRect rect = result.rect().adjusted(focusFrame, focusFrame, -focusFrame, -focusFrame); … … 391 433 392 434 if (focused) { 393 QPen focusPen(highlightColor, focusFrame, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);435 QPen focusPen(highlightColor, 1.2 * painterScale(painter), Qt::SolidLine); 394 436 drawControlBackground(&cachePainter, focusPen, rect, Qt::NoBrush); 395 437 } … … 698 740 style->setBackgroundColor(Color::transparent); 699 741 style->resetBorder(); 742 style->setBorderTopWidth(frameWidth); 743 style->setBorderRightWidth(frameWidth); 744 style->setBorderBottomWidth(frameWidth); 745 style->setBorderLeftWidth(frameWidth); 700 746 style->resetPadding(); 701 747 computeSizeBasedOnStyle(style); -
trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.h
r119547 r122647 54 54 virtual bool delegatesMenuListRendering() const { return true; } 55 55 56 // drawFocusRing() will return early if the color is invalid. 57 virtual Color platformFocusRingColor() const { return Color(); } 56 // We don't want the focus ring to be drawn by the graphics context so we 57 // always claim to support it in the theme. 58 // FIXME: This could be a usability problem in the case of contenteditable divs. 59 virtual bool supportsFocusRing(const RenderStyle*) const { return true; } 58 60 59 61 protected:
Note: See TracChangeset
for help on using the changeset viewer.