Changeset 79884 in webkit


Ignore:
Timestamp:
Feb 28, 2011 11:08:22 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-02-28 Viatcheslav Ostapenko <ostapenko.viatcheslav@nokia.com>

Reviewed by Andreas Kling.

[Qt] Add clipped version of QWebElement::render method.
Allows faster rendering of web element part.
https://bugs.webkit.org/show_bug.cgi?id=50311

  • Api/qwebelement.cpp: (QWebElement::render):
  • Api/qwebelement.h:
  • tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::render):
Location:
trunk/Source/WebKit/qt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/qt/Api/qwebelement.cpp

    r78686 r79884  
    14881488void QWebElement::render(QPainter* painter)
    14891489{
     1490    render(painter, QRect());
     1491}
     1492
     1493/*!
     1494  Render the element into \a painter clipping to \a clip.
     1495*/
     1496void QWebElement::render(QPainter* painter, const QRect& clip)
     1497{
    14901498    WebCore::Element* e = m_element;
    14911499    Document* doc = e ? e->document() : 0;
     
    15061514        return;
    15071515
     1516    QRect finalClipRect = rect;
     1517    if (!clip.isEmpty())
     1518        rect.intersect(clip.translated(rect.location()));
     1519
    15081520    GraphicsContext context(painter);
    15091521
    15101522    context.save();
    15111523    context.translate(-rect.x(), -rect.y());
     1524    painter->setClipRect(finalClipRect, Qt::IntersectClip);
    15121525    view->setNodeToDraw(e);
    1513     view->paintContents(&context, rect);
     1526    view->paintContents(&context, finalClipRect);
    15141527    view->setNodeToDraw(0);
    15151528    context.restore();
  • trunk/Source/WebKit/qt/Api/qwebelement.h

    r67301 r79884  
    157157
    158158    void render(QPainter* painter);
     159    void render(QPainter* painter, const QRect& clipRect);
    159160
    160161private:
  • trunk/Source/WebKit/qt/ChangeLog

    r79848 r79884  
     12011-02-28  Viatcheslav Ostapenko  <ostapenko.viatcheslav@nokia.com>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] Add clipped version of QWebElement::render method.
     6        Allows faster rendering of web element part.
     7        https://bugs.webkit.org/show_bug.cgi?id=50311
     8
     9        * Api/qwebelement.cpp:
     10        (QWebElement::render):
     11        * Api/qwebelement.h:
     12        * tests/qwebelement/tst_qwebelement.cpp:
     13        (tst_QWebElement::render):
     14
    1152011-02-28  Kristian Amlie  <kristian.amlie@nokia.com>
    216
  • trunk/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp

    r72510 r79884  
    940940    QString html( "<html>"
    941941                    "<head><style>"
    942                        "body, iframe { margin: 0px; border: none; }"
     942                       "body, iframe { margin: 0px; border: none; background: white; }"
    943943                    "</style></head>"
    944944                    "<body><table width='300px' height='300px' border='1'>"
     
    10131013
    10141014    QVERIFY(image3 == image4);
     1015
     1016    // Chunked render test reuses page rendered in image4 in previous test
     1017    const int chunkHeight = tableRect.height();
     1018    const int chunkWidth = tableRect.width() / 3;
     1019    QImage chunk(chunkWidth, chunkHeight, QImage::Format_ARGB32);
     1020    QRect chunkRect(0, 0, chunkWidth, chunkHeight);
     1021    for (int x = 0; x < tableRect.width(); x += chunkWidth) {
     1022        QPainter painter(&chunk);
     1023        painter.fillRect(chunkRect, Qt::white);
     1024        QRect chunkPaintRect(x, 0, chunkWidth, chunkHeight);
     1025        tables[0].render(&painter, chunkPaintRect);
     1026        painter.end();
     1027
     1028        QVERIFY(chunk == image4.copy(chunkPaintRect));
     1029    }
    10151030}
    10161031
Note: See TracChangeset for help on using the changeset viewer.