Implement line clamp for mail.
https://bugs.webkit.org/show_bug.cgi?id=180818

Reviewed by Dean Jackson.

Source/WebCore:

This patch implements a form of clamping that can clamp lines at both the top
and the bottom, and the interior can be replaced with a DOM element (identified
by id) that replaces the middle section.

The implementation derives from the multicolumn classes, but ultimately the
clamp should derive from the fragmentset classes instead (with most of the current
multicolumn code moving into base classes).

The virtualization of many of the multicolumn functions is something that would happen
once we move pages/printing over to this pagination model anyway.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
Add the new clamp classes.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyinStyle):
* css/CSSProperties.json:
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyValueWebkitLinesClamp):
* css/parser/CSSParser.cpp:
(WebCore::CSSParserContext::CSSParserContext):
* css/parser/CSSParserMode.h:
(WebCore::CSSParserContextHash::hash):
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeLinesClamp):
(WebCore::CSSPropertyParser::parseSingleValue):
Implement the new CSS property, webkit-lines-clamp. This is only exposed if a preference
is set, so it is not exposed to the Web.

* page/Settings.yaml:
Add a new setting to control allowing access to the new CSS property.

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::willCreateColumns const):
Make sure columns are created when lines clamp is set.

(WebCore::getHeightForLineCount):
(WebCore::RenderBlockFlow::logicalHeightForLineCount):
(WebCore::RenderBlockFlow::logicalHeightExcludingLineCount):
(WebCore::RenderBlockFlow::layoutExcludedChildren):
(WebCore::RenderBlockFlow::heightForLineCount): Deleted.
* rendering/RenderBlockFlow.h:
Re-use the same clamping logic as the old line clamp code, but modernize it to work
with writing modes and to be able to go backwards from the end of the block.

* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::applyLineClamp):
The line count method got renamed to have the word "logical" in it, since it now
works with vertical writing.

* rendering/RenderFragmentContainer.cpp:
(WebCore::RenderFragmentContainer::pageLogicalHeightForOffset const):
* rendering/RenderFragmentContainer.h:
Since line clamp sets have variable page heights, this new method takes the offset
as an argument so that it can return the appropriate page for the given offset.
This method will eventually be used by printing/page sets as well, since pages
can have variable heights.

* rendering/RenderFragmentedFlow.cpp:
(WebCore::RenderFragmentedFlow::validateFragments):
(WebCore::RenderFragmentedFlow::pageLogicalHeightForOffset const):
(WebCore::RenderFragmentedFlow::pageRemainingLogicalHeightForOffset const):
* rendering/RenderFragmentedFlow.h:
Support for variable page heights in a fragment set.

* rendering/RenderLinesClampFlow.cpp: Added.
(WebCore::RenderLinesClampFlow::RenderLinesClampFlow):
(WebCore::RenderLinesClampFlow::renderName const):
(WebCore::RenderLinesClampFlow::layout):
(WebCore::RenderLinesClampFlow::createMultiColumnSet):
(WebCore::RenderLinesClampFlow::isChildAllowedInFragmentedFlow const):
(WebCore::RenderLinesClampFlow::layoutFlowExcludedObjects):
* rendering/RenderLinesClampFlow.h: Added.
* rendering/RenderLinesClampSet.cpp: Added.
(WebCore::RenderLinesClampSet::RenderLinesClampSet):
(WebCore::RenderLinesClampSet::recalculateColumnHeight):
(WebCore::RenderLinesClampSet::computeLogicalHeight const):
(WebCore::RenderLinesClampSet::columnCount const):
(WebCore::RenderLinesClampSet::columnRectAt const):
(WebCore::RenderLinesClampSet::columnIndexAtOffset const):
(WebCore::RenderLinesClampSet::pageLogicalTopForOffset const):
(WebCore::RenderLinesClampSet::pageLogicalHeightForOffset const):
(WebCore::RenderLinesClampSet::fragmentedFlowPortionRectAt const):
(WebCore::RenderLinesClampSet::fragmentedFlowPortionOverflowRect):
(WebCore::RenderLinesClampSet::customBlockProgressionAdjustmentForColumn const):
(WebCore::RenderLinesClampSet::renderName const):
* rendering/RenderLinesClampSet.h: Added.
The new classes. They subclass all the methods necessary to do multi-pass layout,
and to determine the page heights of each section.

* rendering/RenderMultiColumnFlow.cpp:
(WebCore::RenderMultiColumnFlow::isColumnSpanningDescendant const):
(WebCore::isValidColumnSpanner):
(WebCore::RenderMultiColumnFlow::processPossibleSpannerDescendant):
(WebCore::RenderMultiColumnFlow::createMultiColumnSet):
* rendering/RenderMultiColumnFlow.h:
* rendering/RenderMultiColumnSet.cpp:
(WebCore::RenderMultiColumnSet::collectLayerFragments):
(WebCore::RenderMultiColumnSet::columnTranslationForOffset const):
* rendering/RenderMultiColumnSet.h:
(WebCore::RenderMultiColumnSet::skipLayerFragmentCollectionForColumn const):
(WebCore::RenderMultiColumnSet::customBlockProgressionAdjustmentForColumn const):
Virtualized methods so that lines clamp can subclass and change behavior.

* rendering/RenderObject.h:
(WebCore::RenderObject::isRenderLinesClampFlow const):
(WebCore::RenderObject::isRenderLinesClampSet const):
Add new functions for type checking.

* rendering/RenderRubyText.cpp:
Include adjustment.

* rendering/style/LineClampValue.h:
(WebCore::LinesClampValue::LinesClampValue):
(WebCore::LinesClampValue::isNone const):
(WebCore::LinesClampValue::operator== const):
(WebCore::LinesClampValue::operator!= const):
(WebCore::LinesClampValue::start const):
(WebCore::LinesClampValue::end const):
(WebCore::LinesClampValue::center const):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::linesClamp const):
(WebCore::RenderStyle::hasLinesClamp const):
(WebCore::RenderStyle::setLinesClamp):
(WebCore::RenderStyle::initialLinesClamp):
(WebCore::RenderStyle::hasInlineColumnAxis const):
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator== const):
* rendering/style/StyleRareNonInheritedData.h:
The front end style implementation of the new property.

* rendering/updating/RenderTreeBuilderMultiColumn.cpp:
(WebCore::RenderTreeBuilder::MultiColumn::createFragmentedFlow):
Make sure to build the correct renderer when lines clamp is set.

LayoutTests:

Added parsing tests, basic and advanced clamping examples, and vertical
writing tests. Revised an iOS clamp test to account for a slight change
in rendering caused by altering clamping to be consistent with the pagination
model of breaking beteween lines.

* fast/block/lines-clamp-advanced-expected.html: Added.
* fast/block/lines-clamp-advanced-rl-expected.html: Added.
* fast/block/lines-clamp-advanced-rl.html: Added.
* fast/block/lines-clamp-advanced.html: Added.
* fast/block/lines-clamp-basic-expected.html: Added.
* fast/block/lines-clamp-basic-rl-expected.html: Added.
* fast/block/lines-clamp-basic-rl.html: Added.
* fast/block/lines-clamp-basic.html: Added.
* fast/css/lines-clamp-parsing-expected.txt: Added.
* fast/css/lines-clamp-parsing.html: Added.
* platform/ios-simulator-wk2/fast/overflow: Added.
* platform/ios-simulator-wk2/fast/overflow/line-clamp-expected.txt: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@227577 268f45cc-cd09-0410-ab3c-d52691b4dbfc
44 files changed
tree: 848e728def51a143d43eeb2d7aca516b8d2ea892
  1. Examples/
  2. JSTests/
  3. LayoutTests/
  4. ManualTests/
  5. PerformanceTests/
  6. Source/
  7. Tools/
  8. WebDriverTests/
  9. WebKit.xcworkspace/
  10. WebKitLibraries/
  11. Websites/
  12. .dir-locals.el
  13. .gitattributes
  14. .gitignore
  15. ChangeLog
  16. ChangeLog-2012-05-22
  17. ChangeLog-2018-01-01
  18. CMakeLists.txt
  19. Makefile
  20. Makefile.shared
  21. 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

Downloading Safari Technology Preview to test the latest version of WebKit.

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://git.webkit.org/WebKit.git WebKit

If you want to be able to commit changes to the repository, or just want to check out branches that aren’t contained in WebKit.git, you will need track WebKit's Subversion repository. You can run the following command to configure this and other options of the new Git clone for WebKit development.

Tools/Scripts/webkit-patch setup-git-clone

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

Checking out the Subversion Repository

Run the following command to check out WebKit's subversion repository:

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

Building WebKit

Building Mac 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 WebKit.

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.

Building iOS Port

The first time after you install a new Xcode, you will need to run the following command to enable Xcode to build command line tools for iOS Simulator:

 sudo Tools/Scripts/configure-xcode-for-ios-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 iOS:

Tools/Scripts/build-webkit --debug --ios-simulator.

Building GTK+ Port

Install the dependencies by running the following command:

Tools/gtk/install-dependencies

Then run the following command to build additional dependencies:

Tools/Scripts/update-webkitgtk-libs

Run the following command to build WebKit with debugging symbols for GTK+ port:

Tools/Scripts/build-webkit --debug --gtk

Note that the procedure for building a release tarball is different. For more information, see the wiki page.

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.

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.