Separate scrolling code out of RenderLayer
https://bugs.webkit.org/show_bug.cgi?id=60305

Reviewed by Simon Fraser.

Move all scrolling/overflow handling out of RenderLayer, to
streamline its interface and make it re-usable for layer
types that do not need nor support scrolling/overflow.

Many variables tracking scrolling/overflow state were migrated to
RenderLayerScrollableArea, which is only created if the renderer
corresponding to the layer has a CSS 'resize' property != 'none',
has potentially scrollable overflow content or <marquee>.

For the common case (no scrollable overflow), the RenderLayer
overhead is reduced: less memory, less state tracking.

Covered by existing tests.

* WebCore.xcodeproj/project.pbxproj: Make RenderLayerScrollableArea.h
include work in WebKit project.
* accessibility/AccessibilityRenderObject.cpp: Adapt to the fact that
RenderLayer is no longer a ScrollableArea.
(WebCore::AccessibilityRenderObject::getScrollableAreaIfScrollable const):
* html/TextFieldInputType.cpp: Adapt to the fact that RenderLayer is
no longer a ScrollableArea.
(WebCore::TextFieldInputType::elementDidBlur):
* page/EventHandler.cpp: Ditto.
(WebCore::EventHandler::enclosingScrollableArea):
(WebCore::EventHandler::handleWheelEventInAppropriateEnclosingBox):
* page/FrameView.cpp: Ditto.
(WebCore::FrameView::enclosingScrollableArea const):
* page/ios/FrameIOS.mm: Ditto.
(WebCore::Frame::overflowScrollPositionChangedForNode):
* page/mac/EventHandlerMac.mm:
(WebCore::scrollableAreaForBox):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::requiresLayerWithScrollableArea const): Decides
whether a RenderLayer needs a RenderLayerScrollableArea. The presence
of resize/marquee/overflow triggers creation of a
RenderLayerScrollableArea object.
* rendering/RenderBox.h:
* rendering/RenderLayer.cpp: Move all overflow/resize/marquee/scroll
handling to RenderLayerScrollableArea and adapt the affected code.
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::~RenderLayer):
(WebCore::RenderLayer::currentScrollType const):
(WebCore::RenderLayer::scrollAnimator const):
(WebCore::RenderLayer::scrollOffset const):
(WebCore::RenderLayer::scrollToOffset):
(WebCore::RenderLayer::scrollToXPosition):
(WebCore::RenderLayer::scrollToYPosition):
(WebCore::RenderLayer::setScrollPosition):
(WebCore::RenderLayer::scrollByRecursively):
(WebCore::RenderLayer::setRequiresScrollPositionReconciliation):
(WebCore::RenderLayer::setAdjustForIOSCaretWhenScrolling):
(WebCore::RenderLayer::setScrollShouldClearLatchedState):
(WebCore::RenderLayer::shouldPlaceBlockDirectionScrollbarOnLeft const):
(WebCore::RenderLayer::containsDirtyOverlayScrollbars const):
(WebCore::RenderLayer::hasScrollableOrRubberbandableAncestor):
(WebCore::RenderLayer::marquee const):
(WebCore::RenderLayer::updateLayerPositionsAfterDocumentScroll):
(WebCore::RenderLayer::hitTestOverflowControls):
(WebCore::RenderLayer::paintOverflowControls):
(WebCore::RenderLayer::paintResizer):
(WebCore::RenderLayer::paintScrollCorner):
(WebCore::RenderLayer::paintOverlayScrollbars):
(WebCore::RenderLayer::reachableTotalContentsSize const):
(WebCore::RenderLayer::horizontalScrollbarHiddenByStyle const):
(WebCore::RenderLayer::verticalScrollbarHiddenByStyle const):
(WebCore::RenderLayer::setPostLayoutScrollPosition):
(WebCore::RenderLayer::panScrollFromPoint):
(WebCore::RenderLayer::scrollPosition const):
(WebCore::RenderLayer::layerForHorizontalScrollbar const):
(WebCore::RenderLayer::layerForVerticalScrollbar const):
(WebCore::RenderLayer::horizontalScrollbar const):
(WebCore::RenderLayer::verticalScrollbar const):
(WebCore::RenderLayer::scrollingMayRevealBackground const):
(WebCore::RenderLayer::hasScrollableHorizontalOverflow const):
(WebCore::RenderLayer::hasScrollableVerticalOverflow const):
(WebCore::RenderLayer::verticalScrollbarWidth const):
(WebCore::RenderLayer::horizontalScrollbarHeight const):
(WebCore::RenderLayer::scroll):
(WebCore::RenderLayer::setConstrainsScrollingToContentEdge):
(WebCore::RenderLayer::updateLayerPositions):
(WebCore::RenderLayer::updateLayerPositionsAfterScroll):
(WebCore::RenderLayer::updateLayerPosition):
(WebCore::RenderLayer::enclosingFrameRenderLayer const):
(WebCore::RenderLayer::enclosingContainingBlockLayer const):
(WebCore::RenderLayer::enclosingScrollableLayer const):
(WebCore::frameElementAndViewPermitScroll):
(WebCore::RenderLayer::allowsCurrentScroll const):
(WebCore::RenderLayer::scrollRectToVisible):
(WebCore::RenderLayer::resize):
(WebCore::RenderLayer::visibleSize const):
(WebCore::RenderLayer::overflowControlsRects const):
(WebCore::RenderLayer::debugDescription const):
(WebCore::RenderLayer::offsetFromResizeCorner const):
(WebCore::RenderLayer::scrollWidth const):
(WebCore::RenderLayer::scrollHeight const):
(WebCore::RenderLayer::updateScrollInfoAfterLayout):
(WebCore::RenderLayer::canUseCompositedScrolling const):
(WebCore::RenderLayer::hasCompositedScrollableOverflow const):
(WebCore::RenderLayer::hasOverlayScrollbars const):
(WebCore::RenderLayer::usesCompositedScrolling const):
(WebCore::RenderLayer::isPointInResizeControl const):
(WebCore::RenderLayer::paintLayerContents):
(WebCore::RenderLayer::paintOverflowControlsForFragments):
(WebCore::RenderLayer::hitTest):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h: Ditto.
(WebCore::RenderLayer::hasScrollbars const):
(WebCore::RenderLayer::hasHorizontalScrollbar const):
(WebCore::RenderLayer::hasVerticalScrollbar const):
(WebCore::RenderLayer::scrollToXOffset):
(WebCore::RenderLayer::scrollToYOffset):
* rendering/RenderLayerBacking.cpp: Adapt to the fact that
RenderLayer is no longer a ScrollableArea.
(WebCore::RenderLayerBacking::updateOverflowControlsLayers):
* rendering/RenderLayerCompositor.cpp: Adapt to the fact that
RenderLayer is no longer a ScrollableArea.
(WebCore::RenderLayerCompositor::parentRelativeScrollableRect const):
(WebCore::RenderLayerCompositor::updateScrollingNodeForScrollingRole):
(WebCore::RenderLayerCompositor::scrollableAreaForScrollingNodeID const):
* rendering/RenderLayerModelObject.cpp: Adapt to the fact that
RenderLayer is no longer a ScrollableArea.
(WebCore::RenderLayerModelObject::styleDidChange):
* rendering/RenderLayerScrollableArea.cpp: Mostly moved from
RenderLayer.
(WebCore::RenderLayerScrollableArea::RenderLayerScrollableArea):
(WebCore::RenderLayerScrollableArea::~RenderLayerScrollableArea):
(WebCore::RenderLayerScrollableArea::storeScrollPosition):
(WebCore::RenderLayerScrollableArea::handleTouchEvent):
(WebCore::RenderLayerScrollableArea::registerAsTouchEventListenerForScrolling):
(WebCore::RenderLayerScrollableArea::unregisterAsTouchEventListenerForScrolling):
(WebCore::RenderLayerScrollableArea::scrollableAreaBoundingBox const):
(WebCore::RenderLayerScrollableArea::isUserScrollInProgress const):
(WebCore::RenderLayerScrollableArea::isRubberBandInProgress const):
(WebCore::RenderLayerScrollableArea::forceUpdateScrollbarsOnMainThreadForPerformanceTesting const):
(WebCore::RenderLayerScrollableArea::usesAsyncScrolling const):
(WebCore::RenderLayerScrollableArea::setPostLayoutScrollPosition):
(WebCore::RenderLayerScrollableArea::applyPostLayoutScrollPositionIfNeeded):
(WebCore::RenderLayerScrollableArea::scrollToXPosition):
(WebCore::RenderLayerScrollableArea::scrollToYPosition):
(WebCore::RenderLayerScrollableArea::setScrollPosition):
(WebCore::RenderLayerScrollableArea::clampScrollOffset const):
(WebCore::RenderLayerScrollableArea::requestScrollPositionUpdate):
(WebCore::RenderLayerScrollableArea::scrollToOffset):
(WebCore::RenderLayerScrollableArea::scrollTo):
(WebCore::RenderLayerScrollableArea::updateCompositingLayersAfterScroll):
(WebCore::RenderLayerScrollableArea::scrollWidth const):
(WebCore::RenderLayerScrollableArea::scrollHeight const):
(WebCore::RenderLayerScrollableArea::updateMarqueePosition):
(WebCore::RenderLayerScrollableArea::createOrDestroyMarquee):
(WebCore::RenderLayerScrollableArea::scrollsOverflow const):
(WebCore::RenderLayerScrollableArea::canUseCompositedScrolling const):
(WebCore::RenderLayerScrollableArea::setScrollOffset):
(WebCore::RenderLayerScrollableArea::scrollingNodeID const):
(WebCore::RenderLayerScrollableArea::handleWheelEventForScrolling):
(WebCore::RenderLayerScrollableArea::visibleContentRectInternal const):
(WebCore::RenderLayerScrollableArea::overhangAmount const):
(WebCore::RenderLayerScrollableArea::scrollCornerRect const):
(WebCore::RenderLayerScrollableArea::isScrollCornerVisible const):
(WebCore::RenderLayerScrollableArea::convertFromScrollbarToContainingView const):
(WebCore::RenderLayerScrollableArea::convertFromContainingViewToScrollbar const):
(WebCore::RenderLayerScrollableArea::visibleSize const):
(WebCore::RenderLayerScrollableArea::contentsSize const):
(WebCore::RenderLayerScrollableArea::reachableTotalContentsSize const):
(WebCore::RenderLayerScrollableArea::availableContentSizeChanged):
(WebCore::RenderLayerScrollableArea::shouldSuspendScrollAnimations const):
(WebCore::RenderLayerScrollableArea::didStartScroll):
(WebCore::RenderLayerScrollableArea::didEndScroll):
(WebCore::RenderLayerScrollableArea::didUpdateScroll):
(WebCore::RenderLayerScrollableArea::overflowControlsRects const):
(WebCore::RenderLayerScrollableArea::scrollbarOffset const):
(WebCore::RenderLayerScrollableArea::invalidateScrollbarRect):
(WebCore::RenderLayerScrollableArea::invalidateScrollCornerRect):
(WebCore::scrollbarHiddenByStyle):
(WebCore::RenderLayerScrollableArea::horizontalScrollbarHiddenByStyle const):
(WebCore::RenderLayerScrollableArea::verticalScrollbarHiddenByStyle const):
(WebCore::rendererForScrollbar):
(WebCore::RenderLayerScrollableArea::createScrollbar):
(WebCore::RenderLayerScrollableArea::destroyScrollbar):
(WebCore::RenderLayerScrollableArea::setHasHorizontalScrollbar):
(WebCore::RenderLayerScrollableArea::setHasVerticalScrollbar):
(WebCore::RenderLayerScrollableArea::enclosingScrollableArea const):
(WebCore::RenderLayerScrollableArea::isScrollableOrRubberbandable):
(WebCore::RenderLayerScrollableArea::hasScrollableOrRubberbandableAncestor):
(WebCore::RenderLayerScrollableArea::verticalScrollbarWidth const):
(WebCore::RenderLayerScrollableArea::horizontalScrollbarHeight const):
(WebCore::RenderLayerScrollableArea::hasOverflowControls const):
(WebCore::RenderLayerScrollableArea::positionOverflowControls):
(WebCore::RenderLayerScrollableArea::overflowTop const):
(WebCore::RenderLayerScrollableArea::overflowBottom const):
(WebCore::RenderLayerScrollableArea::overflowLeft const):
(WebCore::RenderLayerScrollableArea::overflowRight const):
(WebCore::RenderLayerScrollableArea::computeScrollDimensions):
(WebCore::RenderLayerScrollableArea::computeHasCompositedScrollableOverflow):
(WebCore::RenderLayerScrollableArea::hasScrollableHorizontalOverflow const):
(WebCore::RenderLayerScrollableArea::hasScrollableVerticalOverflow const):
(WebCore::RenderLayerScrollableArea::hasHorizontalOverflow const):
(WebCore::RenderLayerScrollableArea::hasVerticalOverflow const):
(WebCore::styleRequiresScrollbar):
(WebCore::styleDefinesAutomaticScrollbar):
(WebCore::RenderLayerScrollableArea::updateScrollbarsAfterLayout):
(WebCore::RenderLayerScrollableArea::updateScrollInfoAfterLayout):
(WebCore::RenderLayerScrollableArea::overflowControlsIntersectRect const):
(WebCore::RenderLayerScrollableArea::showsOverflowControls const):
(WebCore::RenderLayerScrollableArea::paintOverflowControls):
(WebCore::RenderLayerScrollableArea::paintScrollCorner):
(WebCore::RenderLayerScrollableArea::drawPlatformResizerImage):
(WebCore::RenderLayerScrollableArea::paintResizer):
(WebCore::RenderLayerScrollableArea::hitTestOverflowControls):
(WebCore::RenderLayerScrollableArea::scroll):
(WebCore::RenderLayerScrollableArea::isActive const):
(WebCore::RenderLayerScrollableArea::lastKnownMousePositionInView const):
(WebCore::RenderLayerScrollableArea::isHandlingWheelEvent const):
(WebCore::RenderLayerScrollableArea::useDarkAppearance const):
(WebCore::RenderLayerScrollableArea::updateSnapOffsets):
(WebCore::RenderLayerScrollableArea::isScrollSnapInProgress const):
(WebCore::RenderLayerScrollableArea::paintOverlayScrollbars):
(WebCore::RenderLayerScrollableArea::hitTestResizerInFragments const):
(WebCore::RenderLayerScrollableArea::layerForHorizontalScrollbar const):
(WebCore::RenderLayerScrollableArea::layerForVerticalScrollbar const):
(WebCore::RenderLayerScrollableArea::layerForScrollCorner const):
(WebCore::RenderLayerScrollableArea::scrollingMayRevealBackground const):
(WebCore::RenderLayerScrollableArea::updateScrollbarsAfterStyleChange):
(WebCore::RenderLayerScrollableArea::updateScrollableAreaSet):
(WebCore::RenderLayerScrollableArea::updateScrollCornerStyle):
(WebCore::RenderLayerScrollableArea::clearScrollCorner):
(WebCore::RenderLayerScrollableArea::updateResizerStyle):
(WebCore::RenderLayerScrollableArea::clearResizer):
(WebCore::RenderLayerScrollableArea::updateAllScrollbarRelatedStyle):
(WebCore::RenderLayerScrollableArea::usesCompositedScrolling const):
(WebCore::adjustedScrollDelta):
(WebCore::RenderLayerScrollableArea::panScrollFromPoint):
(WebCore::RenderLayerScrollableArea::updateScrollPosition):
(WebCore::RenderLayerScrollableArea::scrollByRecursively):
(WebCore::RenderLayerScrollableArea::updateLayerPositionsAfterDocumentScroll):
(WebCore::RenderLayerScrollableArea::updateLayerPositionsAfterOverflowScroll):
(WebCore::RenderLayerScrollableArea::usesMockScrollAnimator const):
(WebCore::RenderLayerScrollableArea::logMockScrollAnimatorMessage const):
(WebCore::RenderLayerScrollableArea::debugDescription const):
* rendering/RenderLayerScrollableArea.h:
* rendering/RenderListBox.cpp: Adapt to the fact that
RenderLayer is no longer a ScrollableArea.
(WebCore::RenderListBox::enclosingScrollableArea const):
* rendering/RenderObject.cpp: Add 'S' state in debug output,
indicating whether the RenderLayer has a RenderLayerScrollableArea.
(WebCore::outputRenderTreeLegend):
(WebCore::RenderObject::outputRenderObject const):
* rendering/RenderObject.h: Add friendship with
RenderLayerScrollableArea.
* testing/Internals.cpp: Adapt to the fact that
RenderLayer is no longer a ScrollableArea.
(WebCore::Internals::scrollBySimulatingWheelEvent):
(WebCore:: const):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@271559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed
tree: cc4cc4b38d55dc2623b12758c8ec973d47d3b092
  1. JSTests/
  2. LayoutTests/
  3. ManualTests/
  4. PerformanceTests/
  5. resources/
  6. Source/
  7. Tools/
  8. WebDriverTests/
  9. WebKit.xcworkspace/
  10. WebKitLibraries/
  11. Websites/
  12. .ccls
  13. .clang-format
  14. .dir-locals.el
  15. .editorconfig
  16. .gitattributes
  17. .gitignore
  18. ChangeLog
  19. ChangeLog-2012-05-22
  20. ChangeLog-2018-01-01
  21. CMakeLists.txt
  22. Introduction.md
  23. Makefile
  24. Makefile.shared
  25. ReadMe.md
ReadMe.md

WebKit

WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.

Feature Status

Visit WebKit Feature Status page to see which Web API has been implemented, in development, or under consideration.

Trying the Latest

On macOS, download Safari Technology Preview to test the latest version of WebKit. On Linux, download Epiphany Technology Preview. On Windows, you'll have to build it yourself.

Reporting Bugs

  1. Search WebKit Bugzilla to see if there is an existing report for the bug you've encountered.
  2. Create a Bugzilla account to to report bugs (and to comment on them) if you haven't done so already.
  3. File a bug in accordance with our guidelines.

Once your bug is filed, you will receive email when it is updated at each stage in the bug life cycle. After the bug is considered fixed, you may be asked to download the latest nightly and confirm that the fix works for you.

Getting the Code

On Windows, follow the instructions on our website.

Cloning the Git SVN Repository

Run the following command to clone WebKit's Git SVN repository:

git clone git@github.com:WebKit/WebKit.git WebKit

or

git clone https://github.com/WebKit/WebKit.git WebKit

If you want to be able to track Subversion revision from your git checkout, you can run the following command to do so:

Tools/Scripts/git-webkit setup-git-svn

For information about this, and other aspects of using Git with WebKit, read the wiki page.

Checking out the Subversion Repository

If you don‘t want to use Git, run the following command to check out WebKit’s Subversion repository:

svn checkout https://svn.webkit.org/repository/webkit/trunk WebKit

Building WebKit

Building macOS Port

Install Xcode and its command line tools if you haven't done so already:

  1. Install Xcode Get Xcode from https://developer.apple.com/downloads. To build WebKit for OS X, Xcode 5.1.1 or later is required. To build WebKit for iOS Simulator, Xcode 7 or later is required.
  2. Install the Xcode Command Line Tools In Terminal, run the command: xcode-select --install

Run the following command to build a debug build with debugging symbols and assertions:

Tools/Scripts/build-webkit --debug

For performance testing, and other purposes, use --release instead.

Using Xcode

You can open WebKit.xcworkspace to build and debug WebKit within Xcode.

If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use WebKitBuild directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select “Custom”, “Relative to Workspace”, and enter WebKitBuild for both Products and Intermediates.

Embedded Builds

iOS, tvOS and watchOS are all considered embedded builds. The first time after you install a new Xcode, you will need to run:

sudo Tools/Scripts/configure-xcode-for-embedded-development

Without this step, you will see the error message: “target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphonesimulator’ platform.” when building target JSCLLIntOffsetsExtractor of project JavaScriptCore.

Run the following command to build a debug build with debugging symbols and assertions for embededded simulators:

Tools/Scripts/build-webkit --debug --<platform>-simulator

or embedded devices:

Tools/Scripts/build-webkit --debug --<platform>-device

where platform is ios, tvos or watchos.

Building the GTK+ Port

For production builds:

cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja
ninja
sudo ninja install

For development builds:

Tools/gtk/install-dependencies
Tools/Scripts/update-webkitgtk-libs
Tools/Scripts/build-webkit --gtk --debug

For more information on building WebKitGTK+, see the wiki page.

Building the WPE Port

For production builds:

cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja
ninja
sudo ninja install

For development builds:

Tools/wpe/install-dependencies
Tools/Scripts/update-webkitwpe-libs
Tools/Scripts/build-webkit --wpe --debug

Building Windows Port

For building WebKit on Windows, see the wiki page.

Running WebKit

With Safari and Other macOS Applications

Run the following command to launch Safari with your local build of WebKit:

Tools/Scripts/run-safari --debug

The run-safari script sets the DYLD_FRAMEWORK_PATH environment variable to point to your build products, and then launches /Applications/Safari.app. DYLD_FRAMEWORK_PATH tells the system loader to prefer your build products over the frameworks installed in /System/Library/Frameworks.

To run other applications with your local build of WebKit, run the following command:

Tools/Scripts/run-webkit-app <application-path>

iOS Simulator

Run the following command to launch iOS simulator with your local build of WebKit:

run-safari --debug --ios-simulator

In both cases, if you have built release builds instead, use --release instead of --debug.

Linux Ports

If you have a development build, you can use the run-minibrowser script, e.g.:

run-minibrowser --debug --wpe

Pass one of --gtk, --jsc-only, or --wpe to indicate the port to use.

Contribute

Congratulations! You’re up and running. Now you can begin coding in WebKit and contribute your fixes and new features to the project. For details on submitting your code to the project, read Contributing Code.