Changeset 79409 in webkit


Ignore:
Timestamp:
Feb 22, 2011 10:54:35 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-02-22 Alexis Menard <alexis.menard@openbossa.org>

Reviewed by Andreas Kling.

[Qt] QWebView ignores a palette set with QWebView::setPalette()
https://bugs.webkit.org/show_bug.cgi?id=31742

Use custom QWebView palette if the view provides one.
Modified version of a patch made by Fabrizio Machado.

  • platform/qt/RenderThemeQt.cpp: (WebCore::RenderThemeQt::platformActiveSelectionBackgroundColor): (WebCore::RenderThemeQt::platformInactiveSelectionBackgroundColor): (WebCore::RenderThemeQt::platformActiveSelectionForegroundColor): (WebCore::RenderThemeQt::platformInactiveSelectionForegroundColor): (WebCore::RenderThemeQt::platformFocusRingColor):

2011-02-22 Alexis Menard <alexis.menard@openbossa.org>

Reviewed by Andreas Kling.

[Qt] QWebView ignores a palette set with QWebView::setPalette()
https://bugs.webkit.org/show_bug.cgi?id=31742

Test case to check that the palette sets on the QWebView is taken
into account.

  • tests/qwebview/tst_qwebview.cpp: (tst_QWebView::setPalette_data): (tst_QWebView::setPalette):
Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r79408 r79409  
     12011-02-22  Alexis Menard  <alexis.menard@openbossa.org>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] QWebView ignores a palette set with QWebView::setPalette()
     6        https://bugs.webkit.org/show_bug.cgi?id=31742
     7
     8        Use custom QWebView palette if the view provides one.
     9        Modified version of a patch made by Fabrizio Machado.
     10
     11        * platform/qt/RenderThemeQt.cpp:
     12        (WebCore::RenderThemeQt::platformActiveSelectionBackgroundColor):
     13        (WebCore::RenderThemeQt::platformInactiveSelectionBackgroundColor):
     14        (WebCore::RenderThemeQt::platformActiveSelectionForegroundColor):
     15        (WebCore::RenderThemeQt::platformInactiveSelectionForegroundColor):
     16        (WebCore::RenderThemeQt::platformFocusRingColor):
     17
    1182011-02-22  Brian Salomon  <bsalomon@google.com>
    219
  • trunk/Source/WebCore/platform/qt/RenderThemeQt.cpp

    r79407 r79409  
    382382{
    383383    QPalette pal = QApplication::palette();
     384    setPaletteFromPageClientIfExists(pal);
    384385    return pal.brush(QPalette::Active, QPalette::Highlight).color();
    385386}
     
    388389{
    389390    QPalette pal = QApplication::palette();
     391    setPaletteFromPageClientIfExists(pal);
    390392    return pal.brush(QPalette::Inactive, QPalette::Highlight).color();
    391393}
     
    394396{
    395397    QPalette pal = QApplication::palette();
     398    setPaletteFromPageClientIfExists(pal);
    396399    return pal.brush(QPalette::Active, QPalette::HighlightedText).color();
    397400}
     
    400403{
    401404    QPalette pal = QApplication::palette();
     405    setPaletteFromPageClientIfExists(pal);
    402406    return pal.brush(QPalette::Inactive, QPalette::HighlightedText).color();
    403407}
     
    406410{
    407411    QPalette pal = QApplication::palette();
     412    setPaletteFromPageClientIfExists(pal);
    408413    return pal.brush(QPalette::Active, QPalette::Highlight).color();
    409414}
  • trunk/Source/WebKit/qt/ChangeLog

    r79396 r79409  
     12011-02-22  Alexis Menard  <alexis.menard@openbossa.org>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] QWebView ignores a palette set with QWebView::setPalette()
     6        https://bugs.webkit.org/show_bug.cgi?id=31742
     7
     8        Test case to check that the palette sets on the QWebView is taken
     9        into account.
     10
     11        * tests/qwebview/tst_qwebview.cpp:
     12        (tst_QWebView::setPalette_data):
     13        (tst_QWebView::setPalette):
     14
    1152011-02-22  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
    216
  • trunk/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp

    r74271 r79409  
    5252
    5353    void crashTests();
     54
     55    void setPalette_data();
     56    void setPalette();
    5457};
    5558
     
    307310}
    308311
     312void tst_QWebView::setPalette_data()
     313{
     314    QTest::addColumn<bool>("active");
     315    QTest::addColumn<bool>("background");
     316    QTest::newRow("activeBG") << true << true;
     317    QTest::newRow("activeFG") << true << false;
     318    QTest::newRow("inactiveBG") << false << true;
     319    QTest::newRow("inactiveFG") << false << false;
     320}
     321
     322// Render a QWebView to a QImage twice, each time with a different palette set,
     323// verify that images rendered are not the same, confirming WebCore usage of
     324// custom palette on selections.
     325void tst_QWebView::setPalette()
     326{
     327    QString html = "<html><head></head>"
     328                   "<body>"
     329                   "Some text here"
     330                   "</body>"
     331                   "</html>";
     332
     333    QFETCH(bool, active);
     334    QFETCH(bool, background);
     335
     336    // Use controlView to manage active/inactive state of test views by raising
     337    // or lowering their position in the window stack.
     338    QWebView controlView;
     339    controlView.setHtml(html);
     340
     341    QWebView view1;
     342
     343    QPalette palette1;
     344    QBrush brush1(QColor(Qt::red));
     345    brush1.setStyle(Qt::SolidPattern);
     346    if (active && background) {
     347        // Rendered image must have red background on an active QWebView.
     348        palette1.setBrush(QPalette::Active, QPalette::Highlight, brush1);
     349    } else if (active && !background) {
     350        // Rendered image must have red foreground on an active QWebView.
     351        palette1.setBrush(QPalette::Active, QPalette::HighlightedText, brush1);
     352    } else if (!active && background) {
     353        // Rendered image must have red background on an inactive QWebView.
     354        palette1.setBrush(QPalette::Inactive, QPalette::Highlight, brush1);
     355    } else if (!active && !background) {
     356        // Rendered image must have red foreground on an inactive QWebView.
     357        palette1.setBrush(QPalette::Inactive, QPalette::HighlightedText, brush1);
     358    }
     359
     360    view1.setPalette(palette1);
     361    view1.setHtml(html);
     362    view1.page()->setViewportSize(view1.page()->currentFrame()->contentsSize());
     363    view1.show();
     364
     365    QTest::qWaitForWindowShown(&view1);
     366
     367    if (!active) {
     368        controlView.show();
     369        controlView.activateWindow();
     370        QTest::qWaitForWindowShown(&controlView);
     371    } else
     372        view1.activateWindow();
     373
     374    view1.page()->triggerAction(QWebPage::SelectAll);
     375
     376    QImage img1(view1.page()->viewportSize(), QImage::Format_ARGB32);
     377    QPainter painter1(&img1);
     378    view1.page()->currentFrame()->render(&painter1);
     379    painter1.end();
     380    view1.close();
     381    controlView.close();
     382
     383    QWebView view2;
     384
     385    QPalette palette2;
     386    QBrush brush2(QColor(Qt::blue));
     387    brush2.setStyle(Qt::SolidPattern);
     388    if (active && background) {
     389        // Rendered image must have blue background on an active QWebView.
     390        palette2.setBrush(QPalette::Active, QPalette::Highlight, brush2);
     391    } else if (active && !background) {
     392        // Rendered image must have blue foreground on an active QWebView.
     393        palette2.setBrush(QPalette::Active, QPalette::HighlightedText, brush2);
     394    } else if (!active && background) {
     395        // Rendered image must have blue background on an inactive QWebView.
     396        palette2.setBrush(QPalette::Inactive, QPalette::Highlight, brush2);
     397    } else if (!active && !background) {
     398        // Rendered image must have blue foreground on an inactive QWebView.
     399        palette2.setBrush(QPalette::Inactive, QPalette::HighlightedText, brush2);
     400    }
     401
     402    view2.setPalette(palette2);
     403    view2.setHtml(html);
     404    view2.page()->setViewportSize(view2.page()->currentFrame()->contentsSize());
     405    view2.show();
     406
     407    QTest::qWaitForWindowShown(&view2);
     408
     409    if (!active) {
     410        controlView.show();
     411        controlView.activateWindow();
     412        QTest::qWaitForWindowShown(&controlView);
     413    } else
     414        view2.activateWindow();
     415
     416    view2.page()->triggerAction(QWebPage::SelectAll);
     417
     418    QImage img2(view2.page()->viewportSize(), QImage::Format_ARGB32);
     419    QPainter painter2(&img2);
     420    view2.page()->currentFrame()->render(&painter2);
     421    painter2.end();
     422
     423    view2.close();
     424    controlView.close();
     425
     426    QVERIFY(img1 != img2);
     427}
     428
    309429QTEST_MAIN(tst_QWebView)
    310430#include "tst_qwebview.moc"
Note: See TracChangeset for help on using the changeset viewer.