Changeset 61342 in webkit
- Timestamp:
- Jun 17, 2010 1:02:22 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r61341 r61342 1 2010-06-17 Jesus Sanchez-Palencia <jesus@webkit.org>, Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 Reviewed by Simon Hausmann. 4 5 [Qt] QtWebKit does not support viewport meta tag 6 https://bugs.webkit.org/show_bug.cgi?id=39902 7 8 Add windowRect() to page client. 9 10 * platform/qt/QWebPageClient.h: 11 1 12 2010-06-17 Stephen White <senorblanco@chromium.org> 2 13 -
trunk/WebCore/platform/qt/QWebPageClient.h
r59765 r61342 88 88 89 89 virtual QStyle* style() const = 0; 90 90 91 91 virtual QRectF graphicsItemVisibleRect() const { return QRectF(); } 92 92 93 93 virtual bool viewResizesToContentsEnabled() const = 0; 94 95 virtual QRectF windowRect() const = 0; 94 96 95 97 protected: -
trunk/WebKit/qt/Api/qwebframe_p.h
r56208 r61342 72 72 , marginWidth(-1) 73 73 , marginHeight(-1) 74 , initialLayoutComplete(false) 74 75 {} 75 76 void init(QWebFrame* qframe, QWebFrameData* frameData); … … 99 100 int marginWidth; 100 101 int marginHeight; 102 bool initialLayoutComplete; 101 103 }; 102 104 -
trunk/WebKit/qt/Api/qwebpage.cpp
r61312 r61342 1699 1699 */ 1700 1700 1701 1702 /*! 1703 \class QWebPage::ViewportHints 1704 \since 4.7 1705 \brief The QWebPage::ViewportHints class describes hints that can be applied to a viewport. 1706 1707 QWebPage::ViewportHints provides a description of a viewport, such as viewport geometry, 1708 initial scale factor with limits, plus information about whether a user should be able 1709 to scale the contents in the viewport or not, ie. by zooming. 1710 1711 ViewportHints can be set by a web author using the viewport meta tag extension, documented 1712 at \l{http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/usingtheviewport/usingtheviewport.html}{Safari Reference Library: Using the Viewport Meta Tag}. 1713 1714 All values might not be set, as such when dealing with the hints, the developer needs to 1715 check whether the values are valid. Negative values denote an invalid qreal value. 1716 1717 \inmodule QtWebKit 1718 */ 1719 1720 /*! 1721 Constructs an empty QWebPage::ViewportHints. 1722 */ 1723 QWebPage::ViewportHints::ViewportHints() 1724 : d(0) 1725 , m_initialScaleFactor(-1.0) 1726 , m_minimumScaleFactor(-1.0) 1727 , m_maximumScaleFactor(-1.0) 1728 , m_isUserScalable(true) 1729 , m_isValid(false) 1730 { 1731 1732 } 1733 1734 /*! 1735 Constructs a QWebPage::ViewportHints which is a copy from \a other . 1736 */ 1737 QWebPage::ViewportHints::ViewportHints(const QWebPage::ViewportHints& other) 1738 : d(other.d) 1739 , m_initialScaleFactor(other.m_initialScaleFactor) 1740 , m_minimumScaleFactor(other.m_minimumScaleFactor) 1741 , m_maximumScaleFactor(other.m_maximumScaleFactor) 1742 , m_isUserScalable(other.m_isUserScalable) 1743 , m_isValid(other.m_isValid) 1744 , m_size(other.m_size) 1745 { 1746 1747 } 1748 1749 /*! 1750 Destroys the QWebPage::ViewportHints. 1751 */ 1752 QWebPage::ViewportHints::~ViewportHints() 1753 { 1754 1755 } 1756 1757 /*! 1758 Assigns the given QWebPage::ViewportHints to this viewport hints and returns a 1759 reference to this. 1760 */ 1761 QWebPage::ViewportHints& QWebPage::ViewportHints::operator=(const QWebPage::ViewportHints& other) 1762 { 1763 if (this != &other) { 1764 d = other.d; 1765 m_initialScaleFactor = other.m_initialScaleFactor; 1766 m_minimumScaleFactor = other.m_minimumScaleFactor; 1767 m_maximumScaleFactor = other.m_maximumScaleFactor; 1768 m_isUserScalable = other.m_isUserScalable; 1769 m_isValid = other.m_isValid; 1770 m_size = other.m_size; 1771 } 1772 1773 return *this; 1774 } 1775 1776 /*! \fn inline bool QWebPage::ViewportHints::isValid() const 1777 Returns whether this is a valid ViewportHints or not. 1778 1779 An invalid ViewportHints will have an empty QSize, negative values for scale factors and 1780 true for the boolean isUserScalable. 1781 */ 1782 1783 /*! \fn inline QSize QWebPage::ViewportHints::size() const 1784 Returns the size of the viewport. 1785 */ 1786 1787 /*! \fn inline qreal QWebPage::ViewportHints::initialScaleFactor() const 1788 Returns the initial scale of the viewport as a multiplier. 1789 */ 1790 1791 /*! \fn inline qreal QWebPage::ViewportHints::minimumScaleFactor() const 1792 Returns the minimum scale value of the viewport as a multiplier. 1793 */ 1794 1795 /*! \fn inline qreal QWebPage::ViewportHints::maximumScaleFactor() const 1796 Returns the maximum scale value of the viewport as a multiplier. 1797 */ 1798 1799 /*! \fn inline bool QWebPage::ViewportHints::isUserScalable() const 1800 Determines whether or not the scale can be modified by the user. 1801 */ 1802 1803 1701 1804 /*! 1702 1805 \class QWebPage … … 2228 2331 \property QWebPage::preferredContentsSize 2229 2332 \since 4.6 2230 \brief the preferred size of the contents 2231 2232 If this property is set to a valid size, it is used to lay out the page. 2233 If it is not set (the default), the viewport size is used instead. 2333 \brief a custom size used for laying out the page contents. 2334 2335 By default all pages are laid out using the viewport of the page as the base. 2336 2337 As pages mostly are designed for desktop usage, they often do not layout properly 2338 on small devices as the contents require a certain view width. For this reason 2339 it is common to use a different layout size and then scale the contents to fit 2340 within the actual view. 2341 2342 If this property is set to a valid size, this size is used for all layout needs 2343 instead of the size of the viewport. 2344 2345 Setting an invalid size, makes the page fall back to using the viewport size for layout. 2234 2346 2235 2347 \sa viewportSize 2236 2348 */ 2237 void QWebPage::setPreferredContentsSize(const QSize &size) const 2238 { 2349 void QWebPage::setPreferredContentsSize(const QSize& size) const 2350 { 2351 // FIXME: Rename this method to setCustomLayoutSize 2352 2239 2353 d->fixedLayoutSize = size; 2240 2354 2241 QWebFrame *frame = mainFrame(); 2242 if (frame->d->frame && frame->d->frame->view()) { 2243 WebCore::FrameView* view = frame->d->frame->view(); 2244 2245 if (size.isValid()) { 2246 view->setUseFixedLayout(true); 2247 view->setFixedLayoutSize(size); 2248 view->layout(); 2249 } else if (view->useFixedLayout()) { 2250 view->setUseFixedLayout(false); 2251 view->layout(); 2252 } 2253 } 2355 QWebFrame* frame = mainFrame(); 2356 if (!frame->d->frame || !frame->d->frame->view()) 2357 return; 2358 2359 WebCore::FrameView* view = frame->d->frame->view(); 2360 2361 if (size.isValid()) { 2362 view->setUseFixedLayout(true); 2363 view->setFixedLayoutSize(size); 2364 } else if (view->useFixedLayout()) 2365 view->setUseFixedLayout(false); 2366 2367 if (frame->d->initialLayoutComplete) 2368 view->layout(); 2254 2369 } 2255 2370 … … 3582 3697 3583 3698 /*! 3699 \since 4.7 3700 \fn void QWebPage::viewportChangeRequested(const QWebPage::ViewportHints& hints) 3701 3702 This signal is emitted before any layout of the contents, giving you the viewport \a arguments 3703 the web page would like you to use when laying out its contents, including elements fixed to the 3704 viewport. This viewport might be larger that your actual viewport, meaning that a initialScaleFactor 3705 should be applied. When no scale is given, it is assumed that the contents should be scaled 3706 such that the width of the scaled contents fits within the actual viewport. 3707 3708 The minimum and maximum allowed scale represents the min and max values that the page 3709 allows for scaling, and thus, affects the ability to zoom in on the page. 3710 3711 Invalid values are supplied for the values not explicitly set by the web author; thus an 3712 invalid viewport size, and negative values for scale factor and limits. The boolean 3713 ViewportHints::isUserScalable is set to true. 3714 3715 Page authors can provide the supplied values by using the viewport meta tag. More information 3716 about this can be found at \l{http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/usingtheviewport/usingtheviewport.html}{Safari Reference Library: Using the Viewport Meta Tag}. 3717 3718 \sa QWebPage::ViewportHints, setPreferredContentsSize(), QGraphicsWebView::setScale() 3719 */ 3720 3721 /*! 3584 3722 \fn void QWebPage::loadStarted() 3585 3723 -
trunk/WebKit/qt/Api/qwebpage.h
r61117 r61342 43 43 class QWebHistory; 44 44 45 class QWebFrameData; 46 class QWebHistoryItem; 47 class QWebHitTestResult; 48 class QWebNetworkInterface; 45 49 class QWebPagePrivate; 46 class QWebFrameData;47 class QWebNetworkInterface;48 50 class QWebPluginFactory; 49 class QWebHitTestResult; 50 class QWebHistoryItem; 51 class QtViewportHintsPrivate; 51 52 52 53 namespace WebCore { … … 195 196 }; 196 197 198 class ViewportHints { 199 public: 200 ViewportHints(); 201 ViewportHints(const QWebPage::ViewportHints& other); 202 203 ~ViewportHints(); 204 205 QWebPage::ViewportHints& operator=(const QWebPage::ViewportHints& other); 206 207 inline qreal initialScaleFactor() const { return m_initialScaleFactor; }; 208 inline qreal minimumScaleFactor() const { return m_minimumScaleFactor; }; 209 inline qreal maximumScaleFactor() const { return m_maximumScaleFactor; }; 210 inline bool isUserScalable() const { return m_isUserScalable; }; 211 inline bool isValid() const { return m_isValid; }; 212 inline QSize size() const { return m_size; }; 213 214 private: 215 QSharedDataPointer<QtViewportHintsPrivate> d; 216 qreal m_initialScaleFactor; 217 qreal m_minimumScaleFactor; 218 qreal m_maximumScaleFactor; 219 bool m_isUserScalable; 220 bool m_isValid; 221 QSize m_size; 222 223 friend class WebCore::ChromeClientQt; 224 }; 225 226 197 227 explicit QWebPage(QObject *parent = 0); 198 228 ~QWebPage(); … … 339 369 void saveFrameStateRequested(QWebFrame* frame, QWebHistoryItem* item); 340 370 void restoreFrameStateRequested(QWebFrame* frame); 371 372 void viewportChangeRequested(const QWebPage::ViewportHints& hints); 341 373 342 374 protected: -
trunk/WebKit/qt/Api/qwebpage_p.h
r60609 r61342 59 59 class QWebPageClient; 60 60 61 class QtViewportHintsPrivate : public QSharedData { 62 public: 63 QtViewportHintsPrivate(QWebPage::ViewportHints* qq) 64 : q(qq) 65 { } 66 67 QWebPage::ViewportHints* q; 68 }; 69 61 70 class QWebPagePrivate { 62 71 public: -
trunk/WebKit/qt/ChangeLog
r61325 r61342 1 2010-06-17 Jesus Sanchez-Palencia <jesus@webkit.org>, Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 Reviewed by Simon Hausmann. 4 5 [Qt] QtWebKit does not support viewport meta tag 6 https://bugs.webkit.org/show_bug.cgi?id=39902 7 8 Add viewport meta tag support to QtWebKit API layer. 9 10 This implements didReceiveViewportArguments in our ChromeClientQt 11 which is hooked up with QWebPage::viewportChangeRequested(). 12 This signal does not affect the current default behavior. 13 The documentation of the signal explains how to make use of this new feature. 14 15 * Api/qwebframe_p.h: 16 (QWebFramePrivate::QWebFramePrivate): 17 Store information about whether the page has been laid out or not. 18 * Api/qwebpage.cpp: 19 (QWebPage::viewportChangeRequested): 20 * Api/qwebpage_p.h: 21 Added class QtViewportHintsPrivate. 22 * Api/qwebpage.h: 23 (QWebPage::setPreferredContentsSize): 24 Improved documentation and now only layout if the page had already 25 passed layout phase. 26 Added class QWebPage::ViewportHints. 27 * WebCoreSupport/ChromeClientQt.cpp: 28 (WebCore::ChromeClientQt::windowRect): 29 Modified to work as intended by the DOM, for both QWebView 30 and QGraphicsWebView. 31 (WebCore::ChromeClientQt::didReceiveViewportArguments): 32 Emits the signal QWebPage::viewportChangeRequested. 33 * WebCoreSupport/ChromeClientQt.h: 34 * WebCoreSupport/FrameLoaderClientQt.cpp: 35 (WebCore::FrameLoaderClientQt::dispatchDidCommitLoad): 36 (WebCore::FrameLoaderClientQt::dispatchDidFirstLayout): 37 Update information about whether the page has been laid out or not. 38 If the page has been laid out we ignore any further viewport meta data. 39 * WebCoreSupport/PageClientQt.cpp: 40 (WebCore::PageClientQWidget::windowRect): 41 (WebCore::PageClientQGraphicsWidget::windowRect): 42 (WebCore::PageClientQGraphicsWidget::graphicsItemVisibleRect): 43 * WebCoreSupport/PageClientQt.h: 44 The PageClient is now responsible for providing the right window rect. 45 1 46 2010-06-17 Alexis Menard <alexis.menard@nokia.com> 2 47 -
trunk/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
r61117 r61342 38 38 #include "FrameView.h" 39 39 #include "Geolocation.h" 40 #if USE(ACCELERATED_COMPOSITING) 41 #include "GraphicsLayerQt.h" 42 #endif 40 43 #include "HitTestResult.h" 41 44 #include "Icon.h" 42 45 #include "NotImplemented.h" 43 46 #include "NotificationPresenterClientQt.h" 44 #include "ScrollbarTheme.h" 45 #include "WindowFeatures.h" 47 #include "PageClientQt.h" 46 48 #if defined(Q_WS_MAEMO_5) 47 49 #include "QtMaemoWebPopup.h" … … 50 52 #endif 51 53 #include "QWebPageClient.h" 54 #include "ScrollbarTheme.h" 52 55 #include "SecurityOrigin.h" 53 56 #include "ViewportArguments.h" 57 #include "WindowFeatures.h" 58 59 #include "qgraphicswebview.h" 54 60 #include "qwebframe_p.h" 55 61 #include "qwebpage.h" … … 58 64 #include "qwebsecurityorigin_p.h" 59 65 #include "qwebview.h" 60 61 66 #include <qdebug.h> 62 67 #include <qeventloop.h> … … 64 69 #include <qtooltip.h> 65 70 66 #if USE(ACCELERATED_COMPOSITING)67 #include "GraphicsLayerQt.h"68 #endif69 70 71 namespace WebCore { 71 72 … … 91 92 } 92 93 93 94 /*! 95 windowRect represents the rect of the Window, including all interface elements 96 like toolbars/scrollbars etc. It is used by the viewport meta tag as well as 97 by the DOM Window object: outerHeight(), outerWidth(), screenX(), screenY(). 98 */ 94 99 FloatRect ChromeClientQt::windowRect() 95 100 { 96 if (! m_webPage)101 if (!platformPageClient()) 97 102 return FloatRect(); 98 99 QWidget* view = m_webPage->view(); 100 if (!view) 101 return FloatRect(); 102 return IntRect(view->window()->geometry()); 103 } 104 103 return platformPageClient()->windowRect(); 104 } 105 105 106 106 FloatRect ChromeClientQt::pageRect() … … 627 627 #endif 628 628 629 } 629 void ChromeClientQt::didReceiveViewportArguments(Frame* frame, const ViewportArguments& arguments) const 630 { 631 if (m_webPage->mainFrame()->d->initialLayoutComplete) 632 return; 633 634 QSize viewportSize(arguments.width, arguments.height); 635 bool isUserScalable = arguments.userScalable == 1; 636 637 QWebPage::ViewportHints hints; 638 hints.m_isValid = true; 639 hints.m_size = viewportSize; 640 hints.m_initialScaleFactor = arguments.initialScale; 641 hints.m_minimumScaleFactor = arguments.minimumScale; 642 hints.m_maximumScaleFactor = arguments.maximumScale; 643 hints.m_isUserScalable = isUserScalable; 644 645 emit m_webPage->viewportChangeRequested(hints); 646 } 647 648 } // namespace WebCore -
trunk/WebKit/qt/WebCoreSupport/ChromeClientQt.h
r59611 r61342 49 49 struct FrameLoadRequest; 50 50 class QtAbstractWebPopup; 51 struct ViewportArguments; 51 52 52 53 class ChromeClientQt : public ChromeClient … … 178 179 QtAbstractWebPopup* createSelectPopup(); 179 180 181 virtual void didReceiveViewportArguments(Frame*, const ViewportArguments&) const; 182 180 183 QWebPage* m_webPage; 181 184 WebCore::KURL lastHoverURL; -
trunk/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
r61110 r61342 381 381 return; 382 382 383 m_webFrame->d->initialLayoutComplete = false; 384 383 385 emit m_webFrame->urlChanged(m_webFrame->url()); 384 386 m_webFrame->page()->d->updateNavigationActions(); … … 388 390 // This properly resets the title when we navigate to a URI without a title. 389 391 emit titleChanged(String()); 392 393 bool isMainFrame = (m_frame == m_frame->page()->mainFrame()); 394 if (!isMainFrame) 395 return; 396 397 emit m_webFrame->page()->viewportChangeRequested(QWebPage::ViewportHints()); 390 398 } 391 399 … … 425 433 void FrameLoaderClientQt::dispatchDidFirstLayout() 426 434 { 427 notImplemented();435 m_webFrame->d->initialLayoutComplete = true; 428 436 } 429 437 -
trunk/WebKit/qt/WebCoreSupport/PageClientQt.cpp
r60041 r61342 104 104 } 105 105 106 QRectF PageClientQWidget::windowRect() const 107 { 108 return QRectF(view->window()->geometry()); 109 } 110 106 111 PageClientQGraphicsWidget::~PageClientQGraphicsWidget() 107 112 { … … 293 298 #if ENABLE(TILED_BACKING_STORE) 294 299 QRectF PageClientQGraphicsWidget::graphicsItemVisibleRect() const 295 { 300 { 296 301 if (!view->scene()) 297 302 return QRectF(); … … 300 305 if (views.isEmpty()) 301 306 return QRectF(); 302 307 303 308 QGraphicsView* graphicsView = views.at(0); 304 309 int xOffset = graphicsView->horizontalScrollBar()->value(); … … 318 323 } 319 324 320 321 322 } 325 QRectF PageClientQGraphicsWidget::windowRect() const 326 { 327 if (!view->scene()) 328 return QRectF(); 329 330 // The sceneRect is a good approximation of the size of the application, independent of the view. 331 return view->scene()->sceneRect(); 332 } 333 334 } // namespace WebCore -
trunk/WebKit/qt/WebCoreSupport/PageClientQt.h
r60929 r61342 77 77 78 78 virtual QStyle* style() const; 79 79 80 80 virtual bool viewResizesToContentsEnabled() const { return false; } 81 82 virtual QRectF windowRect() const; 81 83 82 84 QWidget* view; … … 183 185 #endif 184 186 187 virtual QRectF windowRect() const; 188 185 189 QGraphicsWidget* view; 186 190 QWebPage* page;
Note: See TracChangeset
for help on using the changeset viewer.