From ce9aa787cb5dc6fa055704b478db77482431b834 Mon Sep 17 00:00:00 2001 From: Ojan Vafai Date: Tue, 28 Oct 2014 19:27:52 -0700 Subject: [PATCH] Remove more frame-level scrolling machinery. This is all dead code. No change in behavior. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/678193005 --- engine/core/frame/FrameView.cpp | 54 ++----------------- engine/core/frame/FrameView.h | 9 ---- engine/core/rendering/RenderBlockFlow.cpp | 7 +-- engine/core/rendering/RenderBox.cpp | 1 - .../compositing/RenderLayerCompositor.cpp | 28 ---------- .../compositing/RenderLayerCompositor.h | 1 - engine/public/web/WebDocument.h | 6 --- engine/public/web/WebFrame.h | 7 --- engine/public/web/WebWidget.h | 6 --- engine/web/WebDocument.cpp | 21 -------- engine/web/WebLocalFrameImpl.cpp | 24 --------- engine/web/WebLocalFrameImpl.h | 3 -- engine/web/WebViewImpl.cpp | 20 +------ engine/web/WebViewImpl.h | 1 - 14 files changed, 6 insertions(+), 182 deletions(-) diff --git a/engine/core/frame/FrameView.cpp b/engine/core/frame/FrameView.cpp index 1eabef73eaf..1c86b0b55ec 100644 --- a/engine/core/frame/FrameView.cpp +++ b/engine/core/frame/FrameView.cpp @@ -68,8 +68,6 @@ namespace blink { double FrameView::s_currentFrameTimeStamp = 0.0; bool FrameView::s_inPaintContents = false; -static const double resourcePriorityUpdateDelayAfterScroll = 0.250; - FrameView::FrameView(LocalFrame* frame) : m_frame(frame) , m_hasPendingLayout(false) @@ -88,7 +86,6 @@ FrameView::FrameView(LocalFrame* frame) , m_visibleContentScaleFactor(1) , m_inputEventsScaleFactorForEmulation(1) , m_layoutSizeFixedToFrameSize(true) - , m_didScrollTimer(this, &FrameView::didScrollTimerFired) { ASSERT(m_frame); init(); @@ -113,12 +110,8 @@ FrameView::~FrameView() if (m_postLayoutTasksTimer.isActive()) m_postLayoutTasksTimer.stop(); - if (m_didScrollTimer.isActive()) - m_didScrollTimer.stop(); - ASSERT(m_frame); ASSERT(m_frame->view() != this || !m_frame->contentRenderer()); - // FIXME: Do we need to do something here for OOPI? } void FrameView::reset() @@ -560,32 +553,6 @@ void FrameView::setLayoutSize(const IntSize& size) setLayoutSizeInternal(size); } -void FrameView::scrollPositionChanged() -{ - setWasScrolledByUser(true); - - Document* document = m_frame->document(); - document->enqueueScrollEventForNode(document); - - m_frame->eventHandler().dispatchFakeMouseMoveEventSoon(); - - if (RenderView* renderView = document->renderView()) { - if (renderView->usesCompositing()) - renderView->compositor()->frameViewDidScroll(); - } - - if (m_didScrollTimer.isActive()) - m_didScrollTimer.stop(); - m_didScrollTimer.startOneShot(resourcePriorityUpdateDelayAfterScroll, FROM_HERE); -} - -void FrameView::didScrollTimerFired(Timer*) -{ - if (m_frame->document() && m_frame->document()->renderView()) { - ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->updateAllImageResourcePriorities(); - } -} - void FrameView::updateCompositedSelectionBoundsIfNeeded() { if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled()) @@ -616,9 +583,7 @@ void FrameView::contentRectangleForPaintInvalidation(const IntRect& r) ASSERT(paintInvalidationIsAllowed()); if (m_isTrackingPaintInvalidations) { - IntRect paintInvalidationRect = r; - paintInvalidationRect.move(-scrollOffset()); - m_trackedPaintInvalidationRects.append(paintInvalidationRect); + m_trackedPaintInvalidationRects.append(r); // FIXME: http://crbug.com/368518. Eventually, invalidateContentRectangleForPaint // is going away entirely once all layout tests are FCM. In the short // term, no code should be tracking non-composited FrameView paint invalidations. @@ -1098,21 +1063,12 @@ void FrameView::forceLayout(bool allowSubtree) IntRect FrameView::convertFromRenderer(const RenderObject& renderer, const IntRect& rendererRect) const { - IntRect rect = pixelSnappedIntRect(enclosingLayoutRect(renderer.localToAbsoluteQuad(FloatRect(rendererRect)).boundingBox())); - - // Convert from page ("absolute") to FrameView coordinates. - rect.moveBy(-scrollPosition()); - - return rect; + return pixelSnappedIntRect(enclosingLayoutRect(renderer.localToAbsoluteQuad(FloatRect(rendererRect)).boundingBox())); } IntRect FrameView::convertToRenderer(const RenderObject& renderer, const IntRect& viewRect) const { IntRect rect = viewRect; - - // Convert from FrameView coords into page ("absolute") coordinates. - rect.moveBy(scrollPosition()); - // FIXME: we don't have a way to map an absolute rect down to a local quad, so just // move the rect for now. rect.setLocation(roundedIntPoint(renderer.absoluteToLocal(rect.location(), UseTransforms))); @@ -1121,11 +1077,7 @@ IntRect FrameView::convertToRenderer(const RenderObject& renderer, const IntRect IntPoint FrameView::convertFromRenderer(const RenderObject& renderer, const IntPoint& rendererPoint) const { - IntPoint point = roundedIntPoint(renderer.localToAbsolute(rendererPoint, UseTransforms)); - - // Convert from page ("absolute") to FrameView coordinates. - point.moveBy(-scrollPosition()); - return point; + return roundedIntPoint(renderer.localToAbsolute(rendererPoint, UseTransforms)); } IntPoint FrameView::convertToRenderer(const RenderObject& renderer, const IntPoint& viewPoint) const diff --git a/engine/core/frame/FrameView.h b/engine/core/frame/FrameView.h index e946050b004..2ceb7c49b48 100644 --- a/engine/core/frame/FrameView.h +++ b/engine/core/frame/FrameView.h @@ -219,10 +219,6 @@ public: IntPoint contentsToWindow(const IntPoint& contentsPoint) const { return contentsToWindow(contentsPoint); } IntRect windowToContents(const IntRect& windowRect) const { return convertFromContainingWindow(windowRect); } IntRect contentsToWindow(const IntRect& contentsRect) const { return contentsToWindow(contentsRect); } - IntSize scrollOffset() const { return IntSize(); } - IntPoint minimumScrollPosition() const { return IntPoint(); } - IntPoint maximumScrollPosition() const { return IntPoint(); } - IntPoint scrollPosition() const { return IntPoint(); } bool scheduleAnimation(); IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollbars) const { return IntRect(IntPoint(), expandedIntSize(frameRect().size())); } IntSize unscaledVisibleContentSize(IncludeScrollbarsInRect = ExcludeScrollbars) const { return frameRect().size(); } @@ -271,9 +267,6 @@ private: bool wasViewportResized(); void sendResizeEventIfNeeded(); - void scrollPositionChanged(); - void didScrollTimerFired(Timer*); - void updateCompositedSelectionBoundsIfNeeded(); void setLayoutSizeInternal(const IntSize&); @@ -341,8 +334,6 @@ private: IntSize m_layoutSize; bool m_layoutSizeFixedToFrameSize; - Timer m_didScrollTimer; - Vector m_tickmarks; }; diff --git a/engine/core/rendering/RenderBlockFlow.cpp b/engine/core/rendering/RenderBlockFlow.cpp index 80c4b21d472..d8511c898cb 100644 --- a/engine/core/rendering/RenderBlockFlow.cpp +++ b/engine/core/rendering/RenderBlockFlow.cpp @@ -2070,11 +2070,6 @@ bool RenderBlockFlow::hitTestFloats(const HitTestRequest& request, HitTestResult if (!m_floatingObjects) return false; - LayoutPoint adjustedLocation = accumulatedOffset; - if (isRenderView()) { - adjustedLocation += toLayoutSize(toRenderView(this)->frameView()->scrollPosition()); - } - const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); FloatingObjectSetIterator begin = floatingObjectSet.begin(); for (FloatingObjectSetIterator it = floatingObjectSet.end(); it != begin;) { @@ -2083,7 +2078,7 @@ bool RenderBlockFlow::hitTestFloats(const HitTestRequest& request, HitTestResult if (floatingObject->shouldPaint() && !floatingObject->renderer()->hasSelfPaintingLayer()) { LayoutUnit xOffset = xPositionForFloatIncludingMargin(floatingObject) - floatingObject->renderer()->x(); LayoutUnit yOffset = yPositionForFloatIncludingMargin(floatingObject) - floatingObject->renderer()->y(); - LayoutPoint childPoint = flipFloatForWritingModeForChild(floatingObject, adjustedLocation + LayoutSize(xOffset, yOffset)); + LayoutPoint childPoint = flipFloatForWritingModeForChild(floatingObject, accumulatedOffset + LayoutSize(xOffset, yOffset)); if (floatingObject->renderer()->hitTest(request, result, locationInContainer, childPoint)) { updateHitTestResult(result, locationInContainer.point() - toLayoutSize(childPoint)); return true; diff --git a/engine/core/rendering/RenderBox.cpp b/engine/core/rendering/RenderBox.cpp index 69fb76d92bd..25cc78ef7b3 100644 --- a/engine/core/rendering/RenderBox.cpp +++ b/engine/core/rendering/RenderBox.cpp @@ -604,7 +604,6 @@ IntSize RenderBox::calculateAutoscrollDirection(const IntPoint& windowPoint) con return IntSize(); IntRect box(absoluteBoundingBoxRect()); - box.move(view()->frameView()->scrollOffset()); IntRect windowBox = view()->frameView()->contentsToWindow(box); IntPoint windowAutoscrollPoint = windowPoint; diff --git a/engine/core/rendering/compositing/RenderLayerCompositor.cpp b/engine/core/rendering/compositing/RenderLayerCompositor.cpp index d21aac2d966..0d3eb33f9f2 100644 --- a/engine/core/rendering/compositing/RenderLayerCompositor.cpp +++ b/engine/core/rendering/compositing/RenderLayerCompositor.cpp @@ -366,38 +366,10 @@ void RenderLayerCompositor::frameViewDidChangeSize() if (m_containerLayer) { FrameView* frameView = m_renderView.frameView(); m_containerLayer->setSize(frameView->unscaledVisibleContentSize()); - - frameViewDidScroll(); updateOverflowControlsLayers(); } } -enum AcceleratedFixedRootBackgroundHistogramBuckets { - ScrolledMainFrameBucket = 0, - ScrolledMainFrameWithAcceleratedFixedRootBackground = 1, - ScrolledMainFrameWithUnacceleratedFixedRootBackground = 2, - AcceleratedFixedRootBackgroundHistogramMax = 3 -}; - -void RenderLayerCompositor::frameViewDidScroll() -{ - FrameView* frameView = m_renderView.frameView(); - IntPoint scrollPosition = frameView->scrollPosition(); - - if (!m_scrollLayer) - return; - - // Scroll position = scroll minimum + scroll offset. Adjust the layer's - // position to handle whatever the scroll coordinator isn't handling. - // The minimum scroll position is non-zero for RTL pages with overflow. - m_scrollLayer->setPosition(-scrollPosition); - - - Platform::current()->histogramEnumeration("Renderer.AcceleratedFixedRootBackground", - ScrolledMainFrameBucket, - AcceleratedFixedRootBackgroundHistogramMax); -} - void RenderLayerCompositor::rootFixedBackgroundsChanged() { if (!supportsFixedRootBackgroundCompositing()) diff --git a/engine/core/rendering/compositing/RenderLayerCompositor.h b/engine/core/rendering/compositing/RenderLayerCompositor.h index a95c7ff2c3e..bb87fb6a1ea 100644 --- a/engine/core/rendering/compositing/RenderLayerCompositor.h +++ b/engine/core/rendering/compositing/RenderLayerCompositor.h @@ -135,7 +135,6 @@ public: // Update the geometry of the layers used for clipping and scrolling in frames. void frameViewDidChangeLocation(const IntPoint& contentsOffset); void frameViewDidChangeSize(); - void frameViewDidScroll(); void rootFixedBackgroundsChanged(); bool scrollingLayerDidChange(RenderLayer*); diff --git a/engine/public/web/WebDocument.h b/engine/public/web/WebDocument.h index 7421c41d39d..3312fd6f3de 100644 --- a/engine/public/web/WebDocument.h +++ b/engine/public/web/WebDocument.h @@ -89,12 +89,6 @@ public: BLINK_EXPORT WebDOMEvent createEvent(const WebString& eventType); BLINK_EXPORT WebReferrerPolicy referrerPolicy() const; BLINK_EXPORT WebElement createElement(const WebString& tagName); - // Shorthand of frame()->scrollOffset(). - BLINK_EXPORT WebSize scrollOffset() const; - // Shorthand of frame()->minimumScrollOffset(). - BLINK_EXPORT WebSize minimumScrollOffset() const; - // Shorthand of frame()->maximumScrollOffset(). - BLINK_EXPORT WebSize maximumScrollOffset() const; BLINK_EXPORT v8::Handle registerEmbedderCustomElement(const WebString& name, v8::Handle options, WebExceptionCode&); diff --git a/engine/public/web/WebFrame.h b/engine/public/web/WebFrame.h index 48c1361d09c..9f5a281b16b 100644 --- a/engine/public/web/WebFrame.h +++ b/engine/public/web/WebFrame.h @@ -104,13 +104,6 @@ public: // NOTE: These routines do not force page layout so their results may // not be accurate if the page layout is out-of-date. - // The scroll offset from the top-left corner of the frame in pixels. - virtual WebSize scrollOffset() const = 0; - - // The minimum and maxium scroll positions in pixels. - virtual WebSize minimumScrollOffset() const = 0; - virtual WebSize maximumScrollOffset() const = 0; - // The size of the contents area. virtual WebSize contentsSize() const = 0; diff --git a/engine/public/web/WebWidget.h b/engine/public/web/WebWidget.h index 17ffb448fb3..5263ca3bc23 100644 --- a/engine/public/web/WebWidget.h +++ b/engine/public/web/WebWidget.h @@ -136,12 +136,6 @@ public: // Check whether the given point hits any registered touch event handlers. virtual bool hasTouchEventHandlersAt(const WebPoint&) { return true; } - // Applies a scroll delta to the root layer, which is bundled with a page - // scale factor that may apply a CSS transform on the whole document (used - // for mobile-device pinch zooming). This is triggered by events sent to the - // compositor thread. - virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) { } - // Called to inform the WebWidget that mouse capture was lost. virtual void mouseCaptureLost() { } diff --git a/engine/web/WebDocument.cpp b/engine/web/WebDocument.cpp index 30c97f8b070..d20426220a2 100644 --- a/engine/web/WebDocument.cpp +++ b/engine/web/WebDocument.cpp @@ -136,27 +136,6 @@ WebElement WebDocument::createElement(const WebString& tagName) return element; } -WebSize WebDocument::scrollOffset() const -{ - if (FrameView* view = constUnwrap()->view()) - return view->scrollOffset(); - return WebSize(); -} - -WebSize WebDocument::minimumScrollOffset() const -{ - if (FrameView* view = constUnwrap()->view()) - return toIntSize(view->minimumScrollPosition()); - return WebSize(); -} - -WebSize WebDocument::maximumScrollOffset() const -{ - if (FrameView* view = constUnwrap()->view()) - return toIntSize(view->maximumScrollPosition()); - return WebSize(); -} - v8::Handle WebDocument::registerEmbedderCustomElement(const WebString& name, v8::Handle options, WebExceptionCode& ec) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); diff --git a/engine/web/WebLocalFrameImpl.cpp b/engine/web/WebLocalFrameImpl.cpp index c0415c3dbf9..6ec435a86ba 100644 --- a/engine/web/WebLocalFrameImpl.cpp +++ b/engine/web/WebLocalFrameImpl.cpp @@ -227,30 +227,6 @@ void WebLocalFrameImpl::close() deref(); // Balances ref() acquired in WebFrame::create } -WebSize WebLocalFrameImpl::scrollOffset() const -{ - FrameView* view = frameView(); - if (!view) - return WebSize(); - return view->scrollOffset(); -} - -WebSize WebLocalFrameImpl::minimumScrollOffset() const -{ - FrameView* view = frameView(); - if (!view) - return WebSize(); - return toIntSize(view->minimumScrollPosition()); -} - -WebSize WebLocalFrameImpl::maximumScrollOffset() const -{ - FrameView* view = frameView(); - if (!view) - return WebSize(); - return toIntSize(view->maximumScrollPosition()); -} - WebSize WebLocalFrameImpl::contentsSize() const { return frame()->view()->size(); diff --git a/engine/web/WebLocalFrameImpl.h b/engine/web/WebLocalFrameImpl.h index 0094cfe8641..a123be2987e 100644 --- a/engine/web/WebLocalFrameImpl.h +++ b/engine/web/WebLocalFrameImpl.h @@ -63,9 +63,6 @@ public: virtual bool isWebLocalFrame() const override; virtual WebLocalFrame* toWebLocalFrame() override; virtual void close() override; - virtual WebSize scrollOffset() const override; - virtual WebSize minimumScrollOffset() const override; - virtual WebSize maximumScrollOffset() const override; virtual WebSize contentsSize() const override; virtual bool hasVisibleContent() const override; virtual WebRect visibleContentRect() const override; diff --git a/engine/web/WebViewImpl.cpp b/engine/web/WebViewImpl.cpp index f1eb3427c8f..1dbcb640351 100644 --- a/engine/web/WebViewImpl.cpp +++ b/engine/web/WebViewImpl.cpp @@ -619,13 +619,10 @@ WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int target WebSize maxSize; if (mainFrame()) maxSize = mainFrame()->contentsSize(); - IntSize scrollOffset; - if (mainFrame()) - scrollOffset = mainFrame()->scrollOffset(); int leftMargin = targetMargin; int rightMargin = targetMargin; - const int absoluteSourceX = source.x + scrollOffset.width(); + const int absoluteSourceX = source.x; if (leftMargin > absoluteSourceX) { leftMargin = absoluteSourceX; rightMargin = std::max(leftMargin, minimumMargin); @@ -641,7 +638,7 @@ WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int target const int newX = source.x - leftMargin; ASSERT(newWidth >= 0); - ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width); + ASSERT(newX + newWidth <= maxSize.width); return WebRect(newX, source.y, newWidth, source.height); } @@ -2333,19 +2330,6 @@ void WebViewImpl::updateMainFrameScrollPosition(const IntPoint& scrollPosition, // FIXME(sky): Remove } -void WebViewImpl::applyScrollAndScale(const WebSize& scrollDelta, float pageScaleDelta) -{ - if (!mainFrameImpl() || !mainFrameImpl()->frameView()) - return; - - // TODO(bokan): Old pinch path only - virtual viewport pinch scrolls are automatically updated via GraphicsLayer::DidScroll. - // this should be removed once old pinch is removed. - TRACE_EVENT_INSTANT2("blink", "WebViewImpl::applyScrollAndScale::scrollBy", "x", scrollDelta.width, "y", scrollDelta.height); - WebSize webScrollOffset = mainFrame()->scrollOffset(); - IntPoint scrollOffset(webScrollOffset.width + scrollDelta.width, webScrollOffset.height + scrollDelta.height); - updateMainFrameScrollPosition(scrollOffset, false); -} - void WebViewImpl::updateLayerTreeBackgroundColor() { if (!m_layerTreeView) diff --git a/engine/web/WebViewImpl.h b/engine/web/WebViewImpl.h index 70f3ebd3e3c..290c5485b49 100644 --- a/engine/web/WebViewImpl.h +++ b/engine/web/WebViewImpl.h @@ -91,7 +91,6 @@ public: virtual bool handleInputEvent(const WebInputEvent&) override; virtual void setCursorVisibilityState(bool isVisible) override; virtual bool hasTouchEventHandlersAt(const WebPoint&) override; - virtual void applyScrollAndScale(const WebSize&, float) override; virtual void mouseCaptureLost() override; virtual void setFocus(bool enable) override; virtual bool setComposition(