Changeset 139189 in webkit
- Timestamp:
- Jan 9, 2013, 5:59:48 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r139184 r139189 1 2013-01-09 Andras Becsi <andras.becsi@digia.com> 2 3 [Qt][EFL][WK2] Remove redundant device pixel ratio adjustment from PageViewportController 4 https://bugs.webkit.org/show_bug.cgi?id=106355 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Since r137597 Qt uses the device pixel ratio of the underlying 9 platform window as the device pixel ratio in WebCore. 10 The tiles are rendered with the effective scale (scale adjusted with 11 the device scale factor) and the projection matrix is also adjusted 12 with the device pixel ratio when painting. 13 As a result we can follow the same approach as QtQuick and all the 14 coordinates in PageViewportController need to be in device independent 15 pixels (UI pixels) thus we do no longer need to adjust with the device 16 pixel ratio when calculating the viewport attributes. 17 This simplifies the logic significantly and increases robustness, 18 but does not allow to set a custom device pixel ratio different from 19 the factor of the underlying platform (eg. for testing purposes). 20 This patch is conceptually a follow-up of r137597 and fixes layout 21 and canvas size on retina display. 22 23 * UIProcess/PageViewportController.cpp: 24 (WebKit::PageViewportController::PageViewportController): 25 (WebKit::PageViewportController::innerBoundedViewportScale): 26 (WebKit::PageViewportController::outerBoundedViewportScale): 27 (WebKit::PageViewportController::pixelAlignedFloatPoint): 28 (WebKit::PageViewportController::boundContentsPosition): 29 (WebKit::PageViewportController::didRenderFrame): 30 (WebKit::PageViewportController::pageTransitionViewportReady): 31 (WebKit::PageViewportController::didChangeContentsVisibility): 32 (WebKit::PageViewportController::syncVisibleContents): 33 (WebKit::PageViewportController::visibleContentsSize): 34 (WebKit::PageViewportController::applyScaleAfterRenderingContents): 35 (WebKit::PageViewportController::updateMinimumScaleToFit): 36 * UIProcess/PageViewportController.h: 37 (WebKit::PageViewportController::currentContentsScale): 38 (PageViewportController): 39 * UIProcess/efl/PageViewportControllerClientEfl.cpp: 40 (WebKit::PageViewportControllerClientEfl::updateViewportSize): 41 Adjust the viewport size with the device pixel ratio to keep previous 42 behaviour. 43 * UIProcess/qt/PageViewportControllerClientQt.cpp: 44 (WebKit::PageViewportControllerClientQt::focusEditableArea): 45 (WebKit::PageViewportControllerClientQt::zoomToAreaGestureEnded): 46 * UIProcess/qt/QtWebPageSGNode.cpp: 47 (WebKit::ContentsSGNode::clipRect): 48 * WebProcess/WebPage/WebPage.cpp: 49 (WebKit::WebPage::sendViewportAttributesChanged): 50 1 51 2013-01-09 Carlos Garcia Campos <cgarcia@igalia.com> 2 52 -
trunk/Source/WebKit2/UIProcess/PageViewportController.cpp
r138149 r139189 48 48 , m_hasSuspendedContent(false) 49 49 , m_hadUserInteraction(false) 50 , m_ effectiveScale(1)50 , m_contentsScale(1) 51 51 , m_pendingPositionChange(false) 52 52 , m_pendingScaleChange(false) … … 69 69 float PageViewportController::innerBoundedViewportScale(float viewportScale) const 70 70 { 71 return clampTo(viewportScale, toViewportScale(m_minimumScaleToFit), toViewportScale(m_rawAttributes.maximumScale));71 return clampTo(viewportScale, m_minimumScaleToFit, m_rawAttributes.maximumScale); 72 72 } 73 73 … … 76 76 if (m_allowsUserScaling) { 77 77 // Bounded by [0.1, 10.0] like the viewport meta code in WebCore. 78 float hardMin = toViewportScale(std::max<float>(0.1, 0.5 * m_minimumScaleToFit));79 float hardMax = toViewportScale(std::min<float>(10, 2 * m_rawAttributes.maximumScale));78 float hardMin = std::max<float>(0.1, 0.5 * m_minimumScaleToFit); 79 float hardMax = std::min<float>(10, 2 * m_rawAttributes.maximumScale); 80 80 return clampTo(viewportScale, hardMin, hardMax); 81 81 } … … 96 96 { 97 97 #if PLATFORM(EFL) 98 if (!isIntegral(m_ effectiveScale)) {98 if (!isIntegral(m_contentsScale)) { 99 99 // To avoid blurryness, modify the position so that it maps into a discrete device position. 100 100 FloatPoint scaledPos(framePosition); 101 101 102 102 // Scale by the effective scale factor to compute the screen-relative position. 103 scaledPos.scale(m_ effectiveScale, m_effectiveScale);103 scaledPos.scale(m_contentsScale, m_contentsScale); 104 104 105 105 // Round to integer boundaries. … … 107 107 108 108 // Convert back to CSS coordinates. 109 alignedPos.scale(1 / m_ effectiveScale, 1 / m_effectiveScale);109 alignedPos.scale(1 / m_contentsScale, 1 / m_contentsScale); 110 110 111 111 return alignedPos; … … 134 134 FloatPoint PageViewportController::boundContentsPosition(const WebCore::FloatPoint& framePosition) 135 135 { 136 return boundContentsPositionAtScale(framePosition, m_ effectiveScale);136 return boundContentsPositionAtScale(framePosition, m_contentsScale); 137 137 } 138 138 … … 190 190 if (m_pendingScaleChange) { 191 191 m_pendingScaleChange = false; 192 m_client->setContentsScale(m_ effectiveScale);192 m_client->setContentsScale(m_contentsScale); 193 193 194 194 // The scale changed, we have to re-pixel align. … … 212 212 m_hadUserInteraction = false; 213 213 float initialScale = m_initiallyFitToViewport ? m_minimumScaleToFit : m_rawAttributes.initialScale; 214 applyScaleAfterRenderingContents(innerBoundedViewportScale( toViewportScale(initialScale)));214 applyScaleAfterRenderingContents(innerBoundedViewportScale(initialScale)); 215 215 } 216 216 … … 257 257 m_contentsPosition = position; 258 258 if (!m_pendingScaleChange) 259 m_ effectiveScale = scale;259 m_contentsScale = scale; 260 260 261 261 syncVisibleContents(trajectoryVector); … … 270 270 FloatRect visibleContentsRect(boundContentsPosition(m_contentsPosition), visibleContentsSize()); 271 271 visibleContentsRect.intersect(FloatRect(FloatPoint::zero(), m_contentsSize)); 272 drawingArea->setVisibleContentsRect(visibleContentsRect, m_ effectiveScale, trajectoryVector);272 drawingArea->setVisibleContentsRect(visibleContentsRect, m_contentsScale, trajectoryVector); 273 273 274 274 m_client->didChangeVisibleContents(); … … 300 300 FloatSize PageViewportController::visibleContentsSize() const 301 301 { 302 return FloatSize(m_viewportSize.width() / m_ effectiveScale, m_viewportSize.height() / m_effectiveScale);302 return FloatSize(m_viewportSize.width() / m_contentsScale, m_viewportSize.height() / m_contentsScale); 303 303 } 304 304 … … 325 325 void PageViewportController::applyScaleAfterRenderingContents(float scale) 326 326 { 327 m_ effectiveScale = scale;327 m_contentsScale = scale; 328 328 m_pendingScaleChange = true; 329 329 syncVisibleContents(); … … 342 342 return false; 343 343 344 bool currentlyScaledToFit = fuzzyCompare(m_ effectiveScale, toViewportScale(m_minimumScaleToFit), 0.0001);345 346 float minimumScale = WebCore::computeMinimumScaleFactorForContentContained(m_rawAttributes, WebCore::roundedIntSize(m_viewportSize), WebCore::roundedIntSize(m_contentsSize), devicePixelRatio());344 bool currentlyScaledToFit = fuzzyCompare(m_contentsScale, m_minimumScaleToFit, 0.0001); 345 346 float minimumScale = WebCore::computeMinimumScaleFactorForContentContained(m_rawAttributes, WebCore::roundedIntSize(m_viewportSize), WebCore::roundedIntSize(m_contentsSize), 1); 347 347 348 348 if (minimumScale <= 0) … … 354 354 if (!hasSuspendedContent()) { 355 355 if (!m_hadUserInteraction || (userInitiatedUpdate && currentlyScaledToFit)) 356 applyScaleAfterRenderingContents( toViewportScale(m_minimumScaleToFit));356 applyScaleAfterRenderingContents(m_minimumScaleToFit); 357 357 else { 358 358 // Ensure the effective scale stays within bounds. 359 float boundedScale = innerBoundedViewportScale(m_ effectiveScale);360 if (!fuzzyCompare(boundedScale, m_ effectiveScale, 0.0001))359 float boundedScale = innerBoundedViewportScale(m_contentsScale); 360 if (!fuzzyCompare(boundedScale, m_contentsScale, 0.0001)) 361 361 applyScaleAfterRenderingContents(boundedScale); 362 362 } -
trunk/Source/WebKit2/UIProcess/PageViewportController.h
r137304 r139189 69 69 float minimumContentsScale() const { return m_minimumScaleToFit; } 70 70 float maximumContentsScale() const { return m_rawAttributes.maximumScale; } 71 float currentContentsScale() const { return fromViewportScale(m_effectiveScale); }71 float currentContentsScale() const { return m_contentsScale; } 72 72 73 73 void setHadUserInteraction(bool didUserInteract) { m_hadUserInteraction = didUserInteract; } … … 86 86 87 87 private: 88 float fromViewportScale(float scale) const { return scale / devicePixelRatio(); }89 float toViewportScale(float scale) const { return scale * devicePixelRatio(); }90 88 void syncVisibleContents(const WebCore::FloatPoint &trajectoryVector = WebCore::FloatPoint::zero()); 91 89 void applyScaleAfterRenderingContents(float scale); … … 109 107 WebCore::FloatSize m_viewportSize; 110 108 WebCore::IntSize m_clientContentsSize; 111 float m_ effectiveScale; // Should always be cssScale * devicePixelRatio.109 float m_contentsScale; 112 110 113 111 bool m_pendingPositionChange; -
trunk/Source/WebKit2/UIProcess/efl/PageViewportControllerClientEfl.cpp
r137718 r139189 63 63 { 64 64 ASSERT(m_controller); 65 m_controller->didChangeViewportSize(m_viewImpl->size()); 65 FloatSize size = m_viewImpl->size(); 66 // The viewport controller expects sizes in UI units, and not raw device units. 67 size.scale(1 / m_controller->devicePixelRatio()); 68 m_controller->didChangeViewportSize(size); 66 69 } 67 70 -
trunk/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp
r137149 r139189 183 183 ASSERT(m_controller->hadUserInteraction()); 184 184 185 const float editingFixedScale = 2 * m_controller->devicePixelRatio();185 const float editingFixedScale = 2; 186 186 float targetScale = m_controller->innerBoundedViewportScale(editingFixedScale); 187 187 const QRectF viewportRect = m_viewportItem->boundingRect(); 188 188 189 189 qreal x; 190 const qreal borderOffset = 10 * m_controller->devicePixelRatio();190 const qreal borderOffset = 10; 191 191 if ((targetArea.width() + borderOffset) * targetScale <= viewportRect.width()) { 192 192 // Center the input field in the middle of the view, if it is smaller than … … 222 222 return; 223 223 224 const float margin = 10 * m_controller->devicePixelRatio(); // We want at least a little bit of margin.224 const float margin = 10; // We want at least a little bit of margin. 225 225 QRectF endArea = targetArea.adjusted(-margin, -margin, margin, margin); 226 226 227 227 const QRectF viewportRect = m_viewportItem->boundingRect(); 228 228 229 qreal minViewportScale = qreal(2.5) * m_controller->devicePixelRatio();229 const qreal minViewportScale = qreal(2.5); 230 230 qreal targetScale = viewportRect.size().width() / endArea.size().width(); 231 targetScale = m_controller->innerBoundedViewportScale(qM in(minViewportScale, targetScale));231 targetScale = m_controller->innerBoundedViewportScale(qMax(minViewportScale, targetScale)); 232 232 qreal currentScale = m_pageItem->contentsScale(); 233 233 … … 269 269 case ZoomBack: { 270 270 if (m_scaleStack.isEmpty()) { 271 targetScale = m_controller->minimumContentsScale() * m_controller->devicePixelRatio();271 targetScale = m_controller->minimumContentsScale(); 272 272 endPosition.setY(hotspot.y() - viewportHotspot.y() / targetScale); 273 273 endPosition.setX(0); -
trunk/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp
r138715 r139189 88 88 for (const QSGClipNode* clip = clipList(); clip; clip = clip->clipList()) { 89 89 QMatrix4x4 clipMatrix; 90 if (clip->matrix()) 90 if (pageNode()->devicePixelRatio() != 1.0) { 91 clipMatrix.scale(pageNode()->devicePixelRatio()); 92 if (clip->matrix()) 93 clipMatrix *= (*clip->matrix()); 94 } else if (clip->matrix()) 91 95 clipMatrix = *clip->matrix(); 92 clipMatrix.scale(pageNode()->devicePixelRatio());93 96 94 97 QRectF currentClip; -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r139050 r139189 1032 1032 Settings* settings = m_page->settings(); 1033 1033 1034 int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), int(m_viewportSize.width() / m_page->deviceScaleFactor()));1034 int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), m_viewportSize.width()); 1035 1035 1036 1036 // If unset we use the viewport dimensions. This fits with the behavior of desktop browsers. … … 1038 1038 int deviceHeight = (settings->deviceHeight() > 0) ? settings->deviceHeight() : m_viewportSize.height(); 1039 1039 1040 ViewportAttributes attr = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, deviceWidth, deviceHeight, m_page->deviceScaleFactor(), m_viewportSize);1040 ViewportAttributes attr = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, deviceWidth, deviceHeight, 1, m_viewportSize); 1041 1041 1042 1042 FrameView* view = m_page->mainFrame()->view(); … … 1048 1048 // Use FloatSize to avoid truncated values during scale. 1049 1049 FloatSize contentFixedSize = m_viewportSize; 1050 1051 contentFixedSize.scale(1 / m_page->deviceScaleFactor());1052 1050 1053 1051 #if ENABLE(CSS_DEVICE_ADAPTATION)
Note:
See TracChangeset
for help on using the changeset viewer.