2 * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #import "RemoteScrollingCoordinator.h"
29 #if ENABLE(ASYNC_SCROLLING)
31 #import "ArgumentCoders.h"
32 #import "GraphicsLayerCARemote.h"
33 #import "RemoteLayerTreeDrawingArea.h"
34 #import "RemoteScrollingCoordinatorMessages.h"
35 #import "RemoteScrollingCoordinatorTransaction.h"
36 #import "WebCoreArgumentCoders.h"
38 #import "WebProcess.h"
39 #import <WebCore/Frame.h>
40 #import <WebCore/FrameView.h>
41 #import <WebCore/GraphicsLayer.h>
42 #import <WebCore/RenderLayerCompositor.h>
43 #import <WebCore/RenderView.h>
44 #import <WebCore/ScrollingTreeFixedNode.h>
45 #import <WebCore/ScrollingTreeStickyNode.h>
48 using namespace WebCore;
50 RemoteScrollingCoordinator::RemoteScrollingCoordinator(WebPage* page)
51 : AsyncScrollingCoordinator(page->corePage())
54 WebProcess::singleton().addMessageReceiver(Messages::RemoteScrollingCoordinator::messageReceiverName(), m_webPage->pageID(), *this);
57 RemoteScrollingCoordinator::~RemoteScrollingCoordinator()
59 WebProcess::singleton().removeMessageReceiver(Messages::RemoteScrollingCoordinator::messageReceiverName(), m_webPage->pageID());
62 void RemoteScrollingCoordinator::scheduleTreeStateCommit()
64 if (auto* drawingArea = m_webPage->drawingArea())
65 drawingArea->scheduleCompositingLayerFlush();
68 bool RemoteScrollingCoordinator::coordinatesScrollingForFrameView(const FrameView& frameView) const
70 RenderView* renderView = frameView.renderView();
71 return renderView && renderView->usesCompositing();
74 bool RemoteScrollingCoordinator::isRubberBandInProgress() const
76 // FIXME: need to maintain state in the web process?
80 bool RemoteScrollingCoordinator::isScrollSnapInProgress() const
82 // FIXME: need to maintain state in the web process?
86 void RemoteScrollingCoordinator::setScrollPinningBehavior(ScrollPinningBehavior)
88 // FIXME: send to the UI process.
91 void RemoteScrollingCoordinator::buildTransaction(RemoteScrollingCoordinatorTransaction& transaction)
94 transaction.setStateTreeToEncode(scrollingStateTree()->commit(LayerRepresentation::PlatformLayerIDRepresentation));
97 // Notification from the UI process that we scrolled.
98 void RemoteScrollingCoordinator::scrollPositionChangedForNode(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, bool syncLayerPosition)
100 scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, std::nullopt, false /* FIXME */, syncLayerPosition ? ScrollingLayerPositionAction::Sync : ScrollingLayerPositionAction::Set);
103 void RemoteScrollingCoordinator::currentSnapPointIndicesChangedForNode(ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical)
105 setActiveScrollSnapIndices(nodeID, horizontal, vertical);
108 } // namespace WebKit
110 #endif // ENABLE(ASYNC_SCROLLING)