Changeset 140555 in webkit
- Timestamp:
- Jan 23, 2013, 11:04:28 AM (12 years ago)
- Location:
- branches/chromium/1391a/Source
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/chromium/1391a/Source/Platform/chromium/public/WebLayerTreeView.h
r138831 r140555 103 103 virtual WebSize deviceViewportSize() const = 0; 104 104 105 // Gives the corrected location for an event, accounting for the pinch-zoom transformation106 // in the compositor.107 virtual WebFloatPoint adjustEventPointForPinchZoom(const WebFloatPoint&) const = 0;108 109 105 virtual void setDeviceScaleFactor(float) = 0; 110 106 virtual float deviceScaleFactor() const = 0; -
branches/chromium/1391a/Source/WebCore/loader/HistoryController.cpp
r137792 r140555 88 88 item->setScrollPoint(m_frame->view()->scrollPosition()); 89 89 90 item->setPageScaleFactor(m_frame->frameScaleFactor()); 91 90 Page* page = m_frame->page(); 91 if (page && page->mainFrame() == m_frame) 92 item->setPageScaleFactor(page->pageScaleFactor()); 93 else 94 item->setPageScaleFactor(1); 95 92 96 // FIXME: It would be great to work out a way to put this code in WebCore instead of calling through to the client. 93 97 m_frame->loader()->client()->saveViewStateToItem(item); -
branches/chromium/1391a/Source/WebCore/page/FrameView.cpp
r140039 r140555 2808 2808 } 2809 2809 2810 float FrameView::visibleContentScaleFactor() const 2811 { 2812 if (!m_frame || !m_frame->page()) 2813 return 1; 2814 2815 if (!m_frame->settings()->applyPageScaleFactorInCompositor() || m_frame != m_frame->page()->mainFrame()) 2816 return 1; 2817 2818 return m_frame->page()->pageScaleFactor(); 2819 } 2820 2810 2821 void FrameView::setVisibleScrollerThumbRect(const IntRect& scrollerThumb) 2811 2822 { -
branches/chromium/1391a/Source/WebCore/page/FrameView.h
r139750 r140555 183 183 184 184 virtual IntRect windowResizerRect() const; 185 186 virtual float visibleContentScaleFactor() const OVERRIDE; 185 187 186 188 virtual void setFixedVisibleContentRect(const IntRect&) OVERRIDE; -
branches/chromium/1391a/Source/WebCore/page/Page.cpp
r139800 r140555 734 734 m_pageScaleFactor = scale; 735 735 736 if (document->renderer()) 737 document->renderer()->setNeedsLayout(true); 738 739 document->recalcStyle(Node::Force); 740 741 // Transform change on RenderView doesn't trigger repaint on non-composited contents. 742 mainFrame()->view()->invalidateRect(IntRect(LayoutRect::infiniteRect())); 736 if (!m_settings->applyPageScaleFactorInCompositor()) { 737 if (document->renderer()) 738 document->renderer()->setNeedsLayout(true); 739 740 document->recalcStyle(Node::Force); 741 742 // Transform change on RenderView doesn't trigger repaint on non-composited contents. 743 mainFrame()->view()->invalidateRect(IntRect(LayoutRect::infiniteRect())); 744 } 743 745 744 746 #if USE(ACCELERATED_COMPOSITING) -
branches/chromium/1391a/Source/WebCore/platform/ScrollView.cpp
r135029 r140555 226 226 } 227 227 228 #if !PLATFORM(GTK) 229 IntRect ScrollView::visibleContentRect(bool includeScrollbars) const 228 IntSize ScrollView::unscaledVisibleContentSize(bool includeScrollbars) const 230 229 { 231 230 if (platformWidget()) 232 return platformVisibleContentRect(includeScrollbars) ;231 return platformVisibleContentRect(includeScrollbars).size(); 233 232 234 233 if (!m_fixedVisibleContentRect.isEmpty()) 235 return m_fixedVisibleContentRect ;234 return m_fixedVisibleContentRect.size(); 236 235 237 236 int verticalScrollbarWidth = 0; … … 245 244 } 246 245 247 return IntRect(m_scrollOffset.width(), 248 m_scrollOffset.height(), 249 max(0, width() - verticalScrollbarWidth), 246 return IntSize(max(0, width() - verticalScrollbarWidth), 250 247 max(0, height() - horizontalScrollbarHeight)); 248 } 249 250 #if !PLATFORM(GTK) 251 IntRect ScrollView::visibleContentRect(bool includeScrollbars) const 252 { 253 if (platformWidget()) 254 return platformVisibleContentRect(includeScrollbars); 255 256 if (!m_fixedVisibleContentRect.isEmpty()) 257 return m_fixedVisibleContentRect; 258 259 FloatSize visibleContentSize = unscaledVisibleContentSize(includeScrollbars); 260 visibleContentSize.scale(1 / visibleContentScaleFactor()); 261 return IntRect(IntPoint(m_scrollOffset), expandedIntSize(visibleContentSize)); 251 262 } 252 263 #endif -
branches/chromium/1391a/Source/WebCore/platform/ScrollView.h
r139045 r140555 152 152 virtual int visibleHeight() const OVERRIDE { return visibleContentRect().height(); } 153 153 154 // visibleContentRect().size() is computed from unscaledVisibleContentSize() divided by the value of visibleContentScaleFactor. 155 // visibleContentScaleFactor is usually 1, except when the setting applyPageScaleFactorInCompositor is true and the 156 // ScrollView is the main frame; in that case, visibleContentScaleFactor is equal to the page's pageScaleFactor. 157 // Ports that don't use pageScaleFactor can treat unscaledVisibleContentSize and visibleContentRect().size() as equivalent. 158 IntSize unscaledVisibleContentSize(bool includeScrollbars) const; 159 virtual float visibleContentScaleFactor() const { return 1; } 160 154 161 // Functions for getting/setting the size webkit should use to layout the contents. By default this is the same as the visible 155 162 // content size. Explicitly setting a layout size value will cause webkit to layout the contents using this size instead. -
branches/chromium/1391a/Source/WebCore/rendering/RenderLayerCompositor.cpp
r140073 r140555 1164 1164 if (m_clipLayer) { 1165 1165 FrameView* frameView = m_renderView->frameView(); 1166 m_clipLayer->setSize(frameView-> visibleContentRect(false /* exclude scrollbars */).size());1166 m_clipLayer->setSize(frameView->unscaledVisibleContentSize(false /* exclude scrollbars */)); 1167 1167 1168 1168 frameViewDidScroll(); … … 1524 1524 if (m_clipLayer) { 1525 1525 FrameView* frameView = m_renderView->frameView(); 1526 m_clipLayer->setSize(frameView-> visibleContentRect(false /* exclude scrollbars */).size());1526 m_clipLayer->setSize(frameView->unscaledVisibleContentSize(false /* exclude scrollbars */)); 1527 1527 } 1528 1528 -
branches/chromium/1391a/Source/WebCore/rendering/TextAutosizer.cpp
r140193 r140555 85 85 if (windowInfo.windowSize.isEmpty()) { 86 86 bool includeScrollbars = !InspectorInstrumentation::shouldApplyScreenWidthOverride(mainFrame); 87 windowInfo.windowSize = mainFrame->view()-> visibleContentRect(includeScrollbars).size();87 windowInfo.windowSize = mainFrame->view()->unscaledVisibleContentSize(includeScrollbars); 88 88 if (!m_document->settings()->applyDeviceScaleFactorInCompositor()) 89 89 windowInfo.windowSize.scale(1 / m_document->page()->deviceScaleFactor()); -
branches/chromium/1391a/Source/WebKit/chromium/src/WebViewImpl.cpp
r140183 r140555 1603 1603 } 1604 1604 1605 IntSize WebViewImpl::scaledSize(float pageScaleFactor) const 1606 { 1607 FloatSize scaledSize = dipSize(); 1608 scaledSize.scale(1 / pageScaleFactor); 1609 return expandedIntSize(scaledSize); 1610 } 1611 1605 1612 WebSize WebViewImpl::size() 1606 1613 { 1607 if (isFixedLayoutModeEnabled() && settingsImpl()->applyPageScaleFactorInCompositor())1608 return layoutSize();1609 1610 1614 return m_size; 1611 1615 } … … 1638 1642 WebFrameImpl* webFrame = mainFrameImpl(); 1639 1643 if (webFrame->frameView()) 1640 webFrame->frameView()->resize( size());1644 webFrame->frameView()->resize(m_size); 1641 1645 } 1642 1646 … … 2074 2078 } 2075 2079 2076 if (!m_layerTreeView)2077 return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, inputEvent);2078 2079 2080 const WebInputEvent* inputEventTransformed = &inputEvent; 2080 WebMouseEvent mouseEvent; 2081 WebGestureEvent gestureEvent; 2082 if (WebInputEvent::isMouseEventType(inputEvent.type)) { 2083 mouseEvent = *static_cast<const WebMouseEvent*>(&inputEvent); 2084 2085 IntPoint transformedLocation = roundedIntPoint(m_layerTreeView->adjustEventPointForPinchZoom(WebFloatPoint(mouseEvent.x, mouseEvent.y))); 2086 mouseEvent.x = transformedLocation.x(); 2087 mouseEvent.y = transformedLocation.y(); 2088 inputEventTransformed = static_cast<const WebInputEvent*>(&mouseEvent); 2089 } else if (WebInputEvent::isGestureEventType(inputEvent.type)) { 2090 gestureEvent = *static_cast<const WebGestureEvent*>(&inputEvent); 2091 2092 IntPoint transformedLocation = roundedIntPoint(m_layerTreeView->adjustEventPointForPinchZoom(WebFloatPoint(gestureEvent.x, gestureEvent.y))); 2093 gestureEvent.x = transformedLocation.x(); 2094 gestureEvent.y = transformedLocation.y(); 2095 inputEventTransformed = static_cast<const WebInputEvent*>(&gestureEvent); 2096 } 2097 2098 bool handled = PageWidgetDelegate::handleInputEvent(m_page.get(), *this, *inputEventTransformed); 2099 return handled; 2081 if (m_page->settings()->applyPageScaleFactorInCompositor()) { 2082 WebMouseEvent mouseEvent; 2083 WebGestureEvent gestureEvent; 2084 if (WebInputEvent::isMouseEventType(inputEvent.type)) { 2085 mouseEvent = *static_cast<const WebMouseEvent*>(&inputEvent); 2086 mouseEvent.x = mouseEvent.x / pageScaleFactor(); 2087 mouseEvent.y = mouseEvent.y / pageScaleFactor(); 2088 inputEventTransformed = static_cast<const WebInputEvent*>(&mouseEvent); 2089 } else if (WebInputEvent::isGestureEventType(inputEvent.type)) { 2090 gestureEvent = *static_cast<const WebGestureEvent*>(&inputEvent); 2091 gestureEvent.x = gestureEvent.x / pageScaleFactor(); 2092 gestureEvent.y = gestureEvent.y / pageScaleFactor(); 2093 inputEventTransformed = static_cast<const WebInputEvent*>(&gestureEvent); 2094 } 2095 } 2096 2097 return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, *inputEventTransformed); 2100 2098 } 2101 2099 … … 2777 2775 // the caret height will become minReadableCaretHeight (adjusted for dpi 2778 2776 // and font scale factor). 2779 float targetScale = deviceScaleFactor();2777 float targetScale = settingsImpl()->applyDeviceScaleFactorInCompositor() ? 1 : deviceScaleFactor(); 2780 2778 #if ENABLE(TEXT_AUTOSIZING) 2781 2779 if (page() && page()->settings()) 2782 2780 targetScale *= page()->settings()->textAutosizingFontScaleFactor(); 2783 2781 #endif 2784 const float newScale = clampPageScaleFactorToLimits(pageScaleFactor() * minReadableCaretHeight * targetScale / caret.height); 2782 const float caretHeight = settingsImpl()->applyPageScaleFactorInCompositor() ? caret.height : caret.height * pageScaleFactor(); 2783 const float newScale = clampPageScaleFactorToLimits(targetScale * minReadableCaretHeight / caretHeight); 2785 2784 const float deltaScale = newScale / pageScaleFactor(); 2786 2785 … … 2788 2787 IntRect textboxRectInDocumentCoordinates = textboxRect; 2789 2788 textboxRectInDocumentCoordinates.move(mainFrame()->scrollOffset()); 2790 textboxRectInDocumentCoordinates.scale(deltaScale);2791 2789 IntRect caretInDocumentCoordinates = caret; 2792 2790 caretInDocumentCoordinates.move(mainFrame()->scrollOffset()); 2793 caretInDocumentCoordinates.scale(deltaScale); 2791 int viewWidth = m_size.width; 2792 int viewHeight = m_size.height; 2793 if (settingsImpl()->applyPageScaleFactorInCompositor()) { 2794 viewWidth /= newScale; 2795 viewHeight /= newScale; 2796 } else { 2797 textboxRectInDocumentCoordinates.scale(deltaScale); 2798 caretInDocumentCoordinates.scale(deltaScale); 2799 } 2794 2800 2795 2801 IntPoint newOffset; 2796 if (textboxRectInDocumentCoordinates.width() <= m_size.width) {2802 if (textboxRectInDocumentCoordinates.width() <= viewWidth) { 2797 2803 // Field is narrower than screen. Try to leave padding on left so field's 2798 2804 // label is visible, but it's more important to ensure entire field is 2799 2805 // onscreen. 2800 int idealLeftPadding = m_size.width * leftBoxRatio;2801 int maxLeftPaddingKeepingBoxOnscreen = m_size.width - textboxRectInDocumentCoordinates.width();2806 int idealLeftPadding = viewWidth * leftBoxRatio; 2807 int maxLeftPaddingKeepingBoxOnscreen = viewWidth - textboxRectInDocumentCoordinates.width(); 2802 2808 newOffset.setX(textboxRectInDocumentCoordinates.x() - min<int>(idealLeftPadding, maxLeftPaddingKeepingBoxOnscreen)); 2803 2809 } else { 2804 2810 // Field is wider than screen. Try to left-align field, unless caret would 2805 2811 // be offscreen, in which case right-align the caret. 2806 newOffset.setX(max<int>(textboxRectInDocumentCoordinates.x(), caretInDocumentCoordinates.x() + caretInDocumentCoordinates.width() + caretPadding - m_size.width));2807 } 2808 if (textboxRectInDocumentCoordinates.height() <= m_size.height) {2812 newOffset.setX(max<int>(textboxRectInDocumentCoordinates.x(), caretInDocumentCoordinates.x() + caretInDocumentCoordinates.width() + caretPadding - viewWidth)); 2813 } 2814 if (textboxRectInDocumentCoordinates.height() <= viewHeight) { 2809 2815 // Field is shorter than screen. Vertically center it. 2810 newOffset.setY(textboxRectInDocumentCoordinates.y() - ( m_size.height - textboxRectInDocumentCoordinates.height()) / 2);2816 newOffset.setY(textboxRectInDocumentCoordinates.y() - (viewHeight - textboxRectInDocumentCoordinates.height()) / 2); 2811 2817 } else { 2812 2818 // Field is taller than screen. Try to top align field, unless caret would 2813 2819 // be offscreen, in which case bottom-align the caret. 2814 newOffset.setY(max<int>(textboxRectInDocumentCoordinates.y(), caretInDocumentCoordinates.y() + caretInDocumentCoordinates.height() + caretPadding - m_size.height));2820 newOffset.setY(max<int>(textboxRectInDocumentCoordinates.y(), caretInDocumentCoordinates.y() + caretInDocumentCoordinates.height() + caretPadding - viewHeight)); 2815 2821 } 2816 2822 … … 2820 2826 needAnimation = true; 2821 2827 // If the caret is offscreen, then animate. 2822 IntRect sizeRect(0, 0, m_size.width, m_size.height);2828 IntRect sizeRect(0, 0, viewWidth, viewHeight); 2823 2829 if (!sizeRect.contains(caret)) 2824 2830 needAnimation = true; … … 2912 2918 } 2913 2919 2914 WebPoint WebViewImpl::clampOffsetAtScale(const WebPoint& offset, float scale) 2915 { 2916 // This is the scaled content size. We need to convert it to the new scale factor. 2917 WebSize contentSize = mainFrame()->contentsSize(); 2918 float deltaScale = scale / pageScaleFactor(); 2919 int docWidthAtNewScale = contentSize.width * deltaScale; 2920 int docHeightAtNewScale = contentSize.height * deltaScale; 2921 int viewWidth = m_size.width; 2922 int viewHeight = m_size.height; 2923 2924 // Enforce the maximum and minimum scroll positions at the new scale. 2920 IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale) const 2921 { 2925 2922 IntPoint clampedOffset = offset; 2926 clampedOffset = clampedOffset.shrunkTo(IntPoint(docWidthAtNewScale - viewWidth, docHeightAtNewScale - viewHeight)); 2927 clampedOffset.clampNegativeToZero(); 2923 if (!m_page->settings()->applyPageScaleFactorInCompositor()) { 2924 // This is the scaled content size. We need to convert it to the new scale factor. 2925 WebSize contentSize = unscaledContentsSize(); 2926 int docWidthAtNewScale = contentSize.width * scale; 2927 int docHeightAtNewScale = contentSize.height * scale; 2928 int viewWidth = m_size.width; 2929 int viewHeight = m_size.height; 2930 2931 // Enforce the maximum and minimum scroll positions at the new scale. 2932 clampedOffset = clampedOffset.shrunkTo(IntPoint(docWidthAtNewScale - viewWidth, docHeightAtNewScale - viewHeight)); 2933 clampedOffset.clampNegativeToZero(); 2934 } else { 2935 clampedOffset = clampedOffset.shrunkTo(IntPoint(unscaledContentsSize() - scaledSize(scale))); 2936 clampedOffset.clampNegativeToZero(); 2937 } 2938 2928 2939 return clampedOffset; 2929 2940 } … … 2931 2942 void WebViewImpl::setPageScaleFactorPreservingScrollOffset(float scaleFactor) 2932 2943 { 2933 // Pick a scale factor that is within the expected limits2934 2944 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); 2935 2945 2936 IntPoint scrollOffsetAtNewScale(mainFrame()->scrollOffset().width, mainFrame()->scrollOffset().height); 2937 float deltaScale = scaleFactor / pageScaleFactor(); 2938 scrollOffsetAtNewScale.scale(deltaScale, deltaScale); 2939 2940 WebPoint clampedOffsetAtNewScale = clampOffsetAtScale(scrollOffsetAtNewScale, scaleFactor); 2941 setPageScaleFactor(scaleFactor, clampedOffsetAtNewScale); 2946 IntPoint scrollOffset(mainFrame()->scrollOffset().width, mainFrame()->scrollOffset().height); 2947 if (!m_page->settings()->applyPageScaleFactorInCompositor()) { 2948 float deltaScale = scaleFactor / pageScaleFactor(); 2949 scrollOffset.scale(deltaScale, deltaScale); 2950 } 2951 scrollOffset = clampOffsetAtScale(scrollOffset, scaleFactor); 2952 2953 setPageScaleFactor(scaleFactor, scrollOffset); 2942 2954 } 2943 2955 … … 2950 2962 scaleFactor = 1; 2951 2963 2964 IntPoint scrollOffset = origin; 2952 2965 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); 2953 WebPoint scrollOffset; 2954 if (!m_page->settings()->applyPageScaleFactorInCompositor()) { 2955 // If page scale is not applied in the compositor, then the scroll offsets should 2956 // be modified by the scale factor. 2957 scrollOffset = clampOffsetAtScale(origin, scaleFactor); 2958 } else { 2959 IntPoint offset = origin; 2960 WebSize contentSize = mainFrame()->contentsSize(); 2961 offset.shrunkTo(IntPoint(contentSize.width - m_size.width, contentSize.height - m_size.height)); 2962 offset.clampNegativeToZero(); 2963 scrollOffset = offset; 2964 } 2965 2966 page()->setPageScaleFactor(scaleFactor, scrollOffset); 2966 scrollOffset = clampOffsetAtScale(scrollOffset, scaleFactor); 2967 2968 page()->setPageScaleFactor(scaleFactor, IntPoint(scrollOffset)); 2969 2967 2970 m_pageScaleFactorIsSet = true; 2971 2972 #if USE(ACCELERATED_COMPOSITING) 2973 updateLayerTreeViewport(); 2974 #endif 2968 2975 } 2969 2976 … … 3049 3056 } 3050 3057 3051 static IntSize unscaledContentsSize(Frame* frame) 3052 { 3058 IntSize WebViewImpl::unscaledContentsSize() const 3059 { 3060 Frame* frame = page()->mainFrame(); 3053 3061 RenderView* root = frame->contentRenderer(); 3054 3062 if (!root) 3055 3063 return IntSize(); 3056 return root->unscaledDocumentRect().size(); 3064 3065 if (!m_page->settings()->applyPageScaleFactorInCompositor()) 3066 return root->unscaledDocumentRect().size(); 3067 return root->documentRect().size(); 3057 3068 } 3058 3069 … … 3062 3073 return m_size; 3063 3074 3064 IntSize contentSize = unscaledContentsSize(page()->mainFrame()); 3075 IntSize contentSize = unscaledContentsSize(); 3076 3065 3077 if (fixedLayoutSize().width >= contentSize.width()) 3066 3078 return fixedLayoutSize(); … … 3090 3102 if (viewWidthNotIncludingScrollbars && view->verticalScrollbar() && !view->verticalScrollbar()->isOverlayScrollbar()) 3091 3103 viewWidthNotIncludingScrollbars -= view->verticalScrollbar()->width(); 3092 int unscaledContentsWidth = unscaledContentsSize( page()->mainFrame()).width();3104 int unscaledContentsWidth = unscaledContentsSize().width(); 3093 3105 if (viewWidthNotIncludingScrollbars && unscaledContentsWidth) { 3094 3106 // Limit page scaling down to the document width. … … 3751 3763 mayNeedLayout = computePageScaleFactorLimits(); 3752 3764 3753 FrameView* view = mainFrameImpl()->frameView();3754 if (settingsImpl()->applyPageScaleFactorInCompositor() && view && view->visibleContentRect(true).width() != layoutSize().width()) {3755 view->resize(layoutSize());3756 mayNeedLayout = true;3757 }3758 3759 3765 // didChangeContentsSize() may be called from FrameView::layout; we need to 3760 3766 // relayout to avoid triggering the assertion that needsLayout() isn't set 3761 3767 // at the end of a layout. 3768 FrameView* view = mainFrameImpl()->frameView(); 3762 3769 if (mayNeedLayout && view && view->needsLayout()) 3763 3770 view->layout(); … … 4231 4238 4232 4239 FrameView* view = page()->mainFrame()->view(); 4233 IntRect visibleRect = view->visibleContentRect(true /* include scrollbars */); 4234 IntPoint scroll(view->scrollX(), view->scrollY()); 4235 4236 m_nonCompositedContentHost->setViewport(visibleRect.size(), view->contentsSize(), scroll, view->scrollOrigin()); 4237 4238 IntSize layoutViewportSize = visibleRect.size(); 4240 4241 IntSize layoutViewportSize = layoutSize(); 4239 4242 IntSize deviceViewportSize = m_size; 4240 4243 if (m_webSettings->applyDeviceScaleFactorInCompositor()) 4241 4244 deviceViewportSize.scale(deviceScaleFactor()); 4245 4246 m_nonCompositedContentHost->setViewport(deviceViewportSize, view->contentsSize(), view->scrollPosition(), view->scrollOrigin()); 4242 4247 4243 4248 m_layerTreeView->setViewportSize(layoutViewportSize, deviceViewportSize); -
branches/chromium/1391a/Source/WebKit/chromium/src/WebViewImpl.h
r140183 r140555 462 462 WebCore::IntSize dipSize() const; 463 463 WebCore::IntSize layoutSize() const; 464 WebCore::IntSize scaledSize(float) const; 464 465 465 466 // Set the disposition for how this webview is to be initially shown. … … 612 613 bool computePageScaleFactorLimits(); 613 614 float clampPageScaleFactorToLimits(float scale); 614 WebPoint clampOffsetAtScale(const WebPoint& offset, float scale); 615 WebCore::IntPoint clampOffsetAtScale(const WebCore::IntPoint& offset, float scale) const; 616 WebCore::IntSize unscaledContentsSize() const; 615 617 616 618 void resetSavedScrollAndScaleState();
Note:
See TracChangeset
for help on using the changeset viewer.