diff options
author | Steve Block <steveblock@google.com> | 2011-05-25 19:08:45 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-06-08 13:51:31 +0100 |
commit | 2bde8e466a4451c7319e3a072d118917957d6554 (patch) | |
tree | 28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebKit/qt/Api/qgraphicswebview.cpp | |
parent | 6939c99b71d9372d14a0c74a772108052e8c48c8 (diff) | |
download | external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2 |
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebKit/qt/Api/qgraphicswebview.cpp')
-rw-r--r-- | Source/WebKit/qt/Api/qgraphicswebview.cpp | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/Source/WebKit/qt/Api/qgraphicswebview.cpp b/Source/WebKit/qt/Api/qgraphicswebview.cpp index b1c9586..b7b28bc 100644 --- a/Source/WebKit/qt/Api/qgraphicswebview.cpp +++ b/Source/WebKit/qt/Api/qgraphicswebview.cpp @@ -55,7 +55,8 @@ public: QGraphicsWebViewPrivate(QGraphicsWebView* parent) : q(parent) , page(0) - , resizesToContents(false) {} + , resizesToContents(false) + , renderHints(QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform) {} virtual ~QGraphicsWebViewPrivate(); @@ -74,6 +75,7 @@ public: QGraphicsWebView* q; QWebPage* page; bool resizesToContents; + QPainter::RenderHints renderHints; QGraphicsItemOverlay* overlay() const { @@ -279,6 +281,8 @@ QWebPage* QGraphicsWebView::page() const */ void QGraphicsWebView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget*) { + QPainter::RenderHints oldHints = painter->renderHints(); + painter->setRenderHints(oldHints | d->renderHints); #if ENABLE(TILED_BACKING_STORE) if (WebCore::TiledBackingStore* backingStore = QWebFramePrivate::core(page()->mainFrame())->tiledBackingStore()) { // FIXME: We should set the backing store viewport earlier than in paint @@ -286,6 +290,7 @@ void QGraphicsWebView::paint(QPainter* painter, const QStyleOptionGraphicsItem* // QWebFrame::render is a public API, bypass it for tiled rendering so behavior does not need to change. WebCore::GraphicsContext context(painter); page()->mainFrame()->d->renderFromTiledBackingStore(&context, option->exposedRect.toAlignedRect()); + painter->setRenderHints(oldHints); return; } #endif @@ -294,6 +299,7 @@ void QGraphicsWebView::paint(QPainter* painter, const QStyleOptionGraphicsItem* #else page()->mainFrame()->render(painter, QWebFrame::AllLayers, option->exposedRect.toRect()); #endif + painter->setRenderHints(oldHints); } /*! \reimp @@ -357,6 +363,65 @@ QVariant QGraphicsWebView::inputMethodQuery(Qt::InputMethodQuery query) const return QVariant(); } +/*! + \property QGraphicsWebView::renderHints + \since 4.8 + \brief the default render hints for the view + + These hints are used to initialize QPainter before painting the Web page. + + QPainter::TextAntialiasing and QPainter::SmoothPixmapTransform are enabled by default and will be + used to render the item in addition of what has been set on the painter given by QGraphicsScene. + + \note This property is not available on Symbian. However, the getter and + setter functions can still be used directly. + + \sa QPainter::renderHints() +*/ + +/*! + \since 4.8 + Returns the render hints used by the view to render content. + + \sa QPainter::renderHints() +*/ +QPainter::RenderHints QGraphicsWebView::renderHints() const +{ + return d->renderHints; +} + +/*! + \since 4.8 + Sets the render hints used by the view to the specified \a hints. + + \sa QPainter::setRenderHints() +*/ +void QGraphicsWebView::setRenderHints(QPainter::RenderHints hints) +{ + if (hints == d->renderHints) + return; + d->renderHints = hints; + update(); +} + +/*! + \since 4.8 + If \a enabled is true, enables the specified render \a hint; otherwise + disables it. + + \sa renderHints, QPainter::renderHints() +*/ +void QGraphicsWebView::setRenderHint(QPainter::RenderHint hint, bool enabled) +{ + QPainter::RenderHints oldHints = d->renderHints; + if (enabled) + d->renderHints |= hint; + else + d->renderHints &= ~hint; + if (oldHints != d->renderHints) + update(); +} + /*! \reimp */ bool QGraphicsWebView::event(QEvent* event) |