- Revision
- 123353
- Author
- [email protected]
- Date
- 2012-07-23 11:23:58 -0700 (Mon, 23 Jul 2012)
Log Message
[Qt] RenderThemeQtMobile highlight colors are not being used
https://bugs.webkit.org/show_bug.cgi?id=92004
Reviewed by Noam Rosenthal.
Source/WebCore:
The issue here is that setPaletteFromPageClientIfExists() is being used as a
virtual function, but it isn't, so when platformActiveSelectionBackgroundColor()
runs, it doesn't pick the right palette.
Besides fixing this virtual behavior, the patch changes the structure a bit,
because setPaletteFromPageClientIfExists() was being "overriden" in mobile theme
to set the palette, which isn't exactly what the function name says.
* platform/qt/RenderThemeQt.cpp:
(WebCore::RenderThemeQt::platformActiveSelectionBackgroundColor):
(WebCore::RenderThemeQt::platformInactiveSelectionBackgroundColor):
(WebCore::RenderThemeQt::platformActiveSelectionForegroundColor):
(WebCore::RenderThemeQt::platformInactiveSelectionForegroundColor):
(WebCore::RenderThemeQt::platformFocusRingColor):
(WebCore::RenderThemeQt::systemColor):
(WebCore::RenderThemeQt::getMediaControlForegroundColor):
(WebCore::RenderThemeQt::paintMediaVolumeSliderTrack):
Use the virtual colorPalette() to get the palette.
(WebCore::RenderThemeQt::colorPalette):
(WebCore): Removed the code for getting the page client from here since it is
used only by the QStyle variant.
* platform/qt/RenderThemeQt.h:
(RenderThemeQt):
* platform/qt/RenderThemeQtMobile.cpp:
(WebCore::RenderThemeQtMobile::colorPalette):
(WebCore):
* platform/qt/RenderThemeQtMobile.h:
(RenderThemeQtMobile):
Source/WebKit/qt:
* WebCoreSupport/RenderThemeQStyle.cpp:
(WebCore::RenderThemeQStyle::setPaletteFromPageClientIfExists): Moved here since
it's used only by RenderThemeQStyle. Remove unnecessary check for m_page->chrome().
(WebCore):
(WebCore::RenderThemeQStyle::colorPalette):
* WebCoreSupport/RenderThemeQStyle.h:
(RenderThemeQStyle):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (123352 => 123353)
--- trunk/Source/WebCore/ChangeLog 2012-07-23 18:17:17 UTC (rev 123352)
+++ trunk/Source/WebCore/ChangeLog 2012-07-23 18:23:58 UTC (rev 123353)
@@ -1,3 +1,41 @@
+2012-07-23 Caio Marcelo de Oliveira Filho <[email protected]>
+
+ [Qt] RenderThemeQtMobile highlight colors are not being used
+ https://bugs.webkit.org/show_bug.cgi?id=92004
+
+ Reviewed by Noam Rosenthal.
+
+ The issue here is that setPaletteFromPageClientIfExists() is being used as a
+ virtual function, but it isn't, so when platformActiveSelectionBackgroundColor()
+ runs, it doesn't pick the right palette.
+
+ Besides fixing this virtual behavior, the patch changes the structure a bit,
+ because setPaletteFromPageClientIfExists() was being "overriden" in mobile theme
+ to set the palette, which isn't exactly what the function name says.
+
+ * platform/qt/RenderThemeQt.cpp:
+ (WebCore::RenderThemeQt::platformActiveSelectionBackgroundColor):
+ (WebCore::RenderThemeQt::platformInactiveSelectionBackgroundColor):
+ (WebCore::RenderThemeQt::platformActiveSelectionForegroundColor):
+ (WebCore::RenderThemeQt::platformInactiveSelectionForegroundColor):
+ (WebCore::RenderThemeQt::platformFocusRingColor):
+ (WebCore::RenderThemeQt::systemColor):
+ (WebCore::RenderThemeQt::getMediaControlForegroundColor):
+ (WebCore::RenderThemeQt::paintMediaVolumeSliderTrack):
+ Use the virtual colorPalette() to get the palette.
+
+ (WebCore::RenderThemeQt::colorPalette):
+ (WebCore): Removed the code for getting the page client from here since it is
+ used only by the QStyle variant.
+
+ * platform/qt/RenderThemeQt.h:
+ (RenderThemeQt):
+ * platform/qt/RenderThemeQtMobile.cpp:
+ (WebCore::RenderThemeQtMobile::colorPalette):
+ (WebCore):
+ * platform/qt/RenderThemeQtMobile.h:
+ (RenderThemeQtMobile):
+
2012-07-23 Simon Fraser <[email protected]>
Part 1 of: Implement sticky positioning
Modified: trunk/Source/WebCore/platform/qt/RenderThemeQt.cpp (123352 => 123353)
--- trunk/Source/WebCore/platform/qt/RenderThemeQt.cpp 2012-07-23 18:17:17 UTC (rev 123352)
+++ trunk/Source/WebCore/platform/qt/RenderThemeQt.cpp 2012-07-23 18:23:58 UTC (rev 123353)
@@ -48,7 +48,6 @@
#include "NotImplemented.h"
#include "Page.h"
#include "PaintInfo.h"
-#include "QWebPageClient.h"
#include "RenderBox.h"
#if ENABLE(PROGRESS_ELEMENT)
#include "RenderProgress.h"
@@ -235,37 +234,27 @@
Color RenderThemeQt::platformActiveSelectionBackgroundColor() const
{
- QPalette pal = QGuiApplication::palette();
- setPaletteFromPageClientIfExists(pal);
- return pal.brush(QPalette::Active, QPalette::Highlight).color();
+ return colorPalette().brush(QPalette::Active, QPalette::Highlight).color();
}
Color RenderThemeQt::platformInactiveSelectionBackgroundColor() const
{
- QPalette pal = QGuiApplication::palette();
- setPaletteFromPageClientIfExists(pal);
- return pal.brush(QPalette::Inactive, QPalette::Highlight).color();
+ return colorPalette().brush(QPalette::Inactive, QPalette::Highlight).color();
}
Color RenderThemeQt::platformActiveSelectionForegroundColor() const
{
- QPalette pal = QGuiApplication::palette();
- setPaletteFromPageClientIfExists(pal);
- return pal.brush(QPalette::Active, QPalette::HighlightedText).color();
+ return colorPalette().brush(QPalette::Active, QPalette::HighlightedText).color();
}
Color RenderThemeQt::platformInactiveSelectionForegroundColor() const
{
- QPalette pal = QGuiApplication::palette();
- setPaletteFromPageClientIfExists(pal);
- return pal.brush(QPalette::Inactive, QPalette::HighlightedText).color();
+ return colorPalette().brush(QPalette::Inactive, QPalette::HighlightedText).color();
}
Color RenderThemeQt::platformFocusRingColor() const
{
- QPalette pal = QGuiApplication::palette();
- setPaletteFromPageClientIfExists(pal);
- return pal.brush(QPalette::Active, QPalette::Highlight).color();
+ return colorPalette().brush(QPalette::Active, QPalette::Highlight).color();
}
void RenderThemeQt::systemFont(int, FontDescription&) const
@@ -275,8 +264,7 @@
Color RenderThemeQt::systemColor(int cssValueId) const
{
- QPalette pal = QGuiApplication::palette();
- setPaletteFromPageClientIfExists(pal);
+ QPalette pal = colorPalette();
switch (cssValueId) {
case CSSValueButtontext:
return pal.brush(QPalette::Active, QPalette::ButtonText).color();
@@ -456,6 +444,11 @@
return partRect;
}
+QPalette RenderThemeQt::colorPalette() const
+{
+ return QGuiApplication::palette();
+}
+
bool RenderThemeQt::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& pi,
const IntRect& r)
{
@@ -539,23 +532,6 @@
}
}
-void RenderThemeQt::setPaletteFromPageClientIfExists(QPalette& palette) const
-{
- // If the webview has a custom palette, use it
- if (!m_page)
- return;
- Chrome* chrome = m_page->chrome();
- if (!chrome)
- return;
- ChromeClient* chromeClient = chrome->client();
- if (!chromeClient)
- return;
- QWebPageClient* pageClient = chromeClient->platformPageClient();
- if (!pageClient)
- return;
- palette = pageClient->palette();
-}
-
#if ENABLE(VIDEO)
String RenderThemeQt::extraMediaControlsStyleSheet()
@@ -620,11 +596,8 @@
if (o->node()->active())
fgColor = fgColor.lighter();
- if (!mediaElementCanPlay(o)) {
- QPalette pal = QGuiApplication::palette();
- setPaletteFromPageClientIfExists(pal);
- fgColor = pal.brush(QPalette::Disabled, QPalette::Text).color();
- }
+ if (!mediaElementCanPlay(o))
+ fgColor = colorPalette().brush(QPalette::Disabled, QPalette::Text).color();
return fgColor;
}
@@ -759,9 +732,7 @@
int width = b.width();
int height = b.height();
- // Get the scale color from the page client
- QPalette pal = QGuiApplication::palette();
- setPaletteFromPageClientIfExists(pal);
+ QPalette pal = colorPalette();
const QColor highlightText = pal.brush(QPalette::Active, QPalette::HighlightedText).color();
const QColor scaleColor(highlightText.red(), highlightText.green(), highlightText.blue(), mediaControlsBaselineOpacity() * 255);
Modified: trunk/Source/WebCore/platform/qt/RenderThemeQt.h (123352 => 123353)
--- trunk/Source/WebCore/platform/qt/RenderThemeQt.h 2012-07-23 18:17:17 UTC (rev 123352)
+++ trunk/Source/WebCore/platform/qt/RenderThemeQt.h 2012-07-23 18:23:58 UTC (rev 123353)
@@ -25,6 +25,7 @@
#include "RenderTheme.h"
#include <QBrush>
+#include <QPalette>
#include <QSharedPointer>
#include <QString>
@@ -164,8 +165,6 @@
virtual QRect inflateButtonRect(const QRect& originalRect) const;
- void setPaletteFromPageClientIfExists(QPalette&) const;
-
virtual void setPopupPadding(RenderStyle*) const = 0;
virtual QSharedPointer<StylePainter> getStylePainter(const PaintInfo&) = 0;
@@ -174,6 +173,8 @@
IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const;
+ virtual QPalette colorPalette() const;
+
Page* m_page;
QString m_buttonFontFamily;
Modified: trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp (123352 => 123353)
--- trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp 2012-07-23 18:17:17 UTC (rev 123352)
+++ trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp 2012-07-23 18:23:58 UTC (rev 123353)
@@ -202,6 +202,12 @@
return QSharedPointer<StylePainter>(new StylePainterMobile(this, pi));
}
+QPalette RenderThemeQtMobile::colorPalette() const
+{
+ static QPalette lightGrayPalette(Qt::lightGray);
+ return lightGrayPalette;
+}
+
StylePainterMobile::StylePainterMobile(RenderThemeQtMobile* theme, const PaintInfo& paintInfo)
: StylePainter(theme, paintInfo)
{
@@ -896,13 +902,6 @@
return select ? select->multiple() : false;
}
-void RenderThemeQtMobile::setPaletteFromPageClientIfExists(QPalette& palette) const
-{
- static QPalette lightGrayPalette(Qt::lightGray);
- palette = lightGrayPalette;
- return;
-}
-
void RenderThemeQtMobile::adjustSliderThumbSize(RenderStyle* style, Element* element) const
{
const ControlPart part = style->appearance();
Modified: trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.h (123352 => 123353)
--- trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.h 2012-07-23 18:17:17 UTC (rev 123352)
+++ trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.h 2012-07-23 18:23:58 UTC (rev 123353)
@@ -83,12 +83,12 @@
virtual void computeSizeBasedOnStyle(RenderStyle*) const;
virtual QSharedPointer<StylePainter> getStylePainter(const PaintInfo&);
+ virtual QPalette colorPalette() const;
+
private:
bool checkMultiple(RenderObject*) const;
void setButtonPadding(RenderStyle*) const;
void setPopupPadding(RenderStyle*) const;
-
- void setPaletteFromPageClientIfExists(QPalette&) const;
};
struct KeyIdentifier {
Modified: trunk/Source/WebKit/qt/ChangeLog (123352 => 123353)
--- trunk/Source/WebKit/qt/ChangeLog 2012-07-23 18:17:17 UTC (rev 123352)
+++ trunk/Source/WebKit/qt/ChangeLog 2012-07-23 18:23:58 UTC (rev 123353)
@@ -1,3 +1,18 @@
+2012-07-23 Caio Marcelo de Oliveira Filho <[email protected]>
+
+ [Qt] RenderThemeQtMobile highlight colors are not being used
+ https://bugs.webkit.org/show_bug.cgi?id=92004
+
+ Reviewed by Noam Rosenthal.
+
+ * WebCoreSupport/RenderThemeQStyle.cpp:
+ (WebCore::RenderThemeQStyle::setPaletteFromPageClientIfExists): Moved here since
+ it's used only by RenderThemeQStyle. Remove unnecessary check for m_page->chrome().
+ (WebCore):
+ (WebCore::RenderThemeQStyle::colorPalette):
+ * WebCoreSupport/RenderThemeQStyle.h:
+ (RenderThemeQStyle):
+
2012-07-22 Kent Tamura <[email protected]>
Rename ENABLE_METER_TAG and ENABLE_PROGRESS_TAG to ENABLE_METER_ELEMENT and ENABLE_PROGRESS_ELEMENT respectively
Modified: trunk/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp (123352 => 123353)
--- trunk/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp 2012-07-23 18:17:17 UTC (rev 123352)
+++ trunk/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp 2012-07-23 18:23:58 UTC (rev 123353)
@@ -161,6 +161,20 @@
return (m_fallbackStyle) ? m_fallbackStyle : QApplication::style();
}
+void RenderThemeQStyle::setPaletteFromPageClientIfExists(QPalette& palette) const
+{
+ if (!m_page)
+ return;
+
+ ASSERT(m_page->chrome());
+ ChromeClient* chromeClient = m_page->chrome()->client();
+ if (!chromeClient)
+ return;
+
+ if (QWebPageClient* pageClient = chromeClient->platformPageClient())
+ palette = pageClient->palette();
+}
+
QStyle* RenderThemeQStyle::qStyle() const
{
if (m_page) {
@@ -432,6 +446,12 @@
style->setPaddingBottom(Length(2, Fixed));
}
+QPalette RenderThemeQStyle::colorPalette() const
+{
+ QPalette palette = RenderThemeQt::colorPalette();
+ setPaletteFromPageClientIfExists(palette);
+ return palette;
+}
bool RenderThemeQStyle::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r)
{
Modified: trunk/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h (123352 => 123353)
--- trunk/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h 2012-07-23 18:17:17 UTC (rev 123352)
+++ trunk/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h 2012-07-23 18:23:58 UTC (rev 123353)
@@ -97,6 +97,8 @@
virtual void setPopupPadding(RenderStyle*) const;
+ virtual QPalette colorPalette() const;
+
private:
ControlPart initializeCommonQStyleOptions(QStyleOption&, RenderObject*) const;
@@ -106,6 +108,8 @@
QStyle* fallbackStyle() const;
+ void setPaletteFromPageClientIfExists(QPalette&) const;
+
#ifdef Q_OS_MAC
int m_buttonFontPixelSize;
#endif