Tapping after CSS-based table casues an infinite loop in wordRangeFromPosition
https://bugs.webkit.org/show_bug.cgi?id=185465
<rdar://problem/35263057>

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Rebaselined the tests. h2

* web-platform-tests/dom/nodes/getElementsByClassName-30-expected.txt: table is generating a new line as expected.
* web-platform-tests/html/syntax/parsing/html5lib_menuitem-element-expected.txt: h2 is generating an extra line
to emulate its margin as expected.
* web-platform-tests/html/syntax/parsing/html5lib_tests11-expected.txt: Ditto.
* web-platform-tests/html/syntax/parsing/html5lib_tests21-expected.txt: Ditto.
* web-platform-tests/html/syntax/parsing/html5lib_tests25-expected.txt: Ditto.
* web-platform-tests/html/syntax/parsing/html5lib_webkit02-expected.txt: Ditto.

Source/WebCore:

The bug was caused by TextIterator not emitting a line break when exiting a CSS-based table when an element
with `display: table-row` has an invisible text node. Specifically, TextIterator::exitNode is never called on
an element with `table-cell: row` when m_node is a text node with whitespaces which appears after an element
with `display: table-cell`.

For example, for a tree structure like:
table-row (R)
  table-cell (C)
    "text" (1)
  " " (2)
Getting out of (C) would result in moving onto (2) without generating a line break for (R).

When this happens in nextBoundary as it tries to find the end of the last word in the table cell, we end up
finding the end of the document as the end of the word. As a result, nextWordBoundaryInDirection, the caller
of nextBoundary, ends up infinite looping between the positon at the end of the document and the position
immediately before the last word in the last table cell when it traverses words backwards.

This patch fixes the hang by addressing this root cause in TextIterator. Namely, TextIterator now generates
a line break when exiting a block while walking up ancestors in TextIterator::advance().

Tests: editing/selection/tapping-in-table-at-end-of-document.html
       editing/text-iterator/table-at-end-of-document.html

* editing/TextIterator.cpp:
(WebCore::TextIterator::advance): Fixed the bug.
(WebCore::shouldEmitNewlineAfterNode): Do generate a new line at the end of a document when we're trying to
generate every visible poitions even there are no renderers beyond this point. e.g. a position inside the
last cell of a table at the end of a document hits this condition.
(WebCore::shouldEmitExtraNewlineForNode): Don't emit a line break when the render box's height is 0px
to avoid generating many empty lines for empty paragraph and header elements (this function is used to generate
a blank line between p's and h1/h2/...'s).
(WebCore::TextIterator::exitNode):

LayoutTests:

Rebaselined the tests. Most of these are due to new extra line breaks being generated after table and
header elements as expected. See inline comments for some newly discovered bugs and rebaselines due to
other non-obvious reasons.

* accessibility/internal-link-anchors2-expected.txt: This test now demonstrates a bug that WebKit doesn't
generate an extra line break before h3 when it has a large margin-top since an extra line break is only
generated after a node at the moment.
* accessibility/mac/mathml-elements-expected.txt:
* accessibility/table-headers-expected.txt:
* compositing/layer-creation/overlap-transformed-preserved-3d-expected.txt:
* css3/flexbox/box-orient-button-expected.txt:
* css3/flexbox/flexitem-expected.txt:
* editing/execCommand/19087-expected.txt: The second blockquote which has the height of 0px no longer
generates an extra new line.
* editing/inserting/insert-list-in-table-cell-08-expected.txt: Selection is now being restored properly
using TextIterator in InsertListCommand.
* editing/selection/tapping-in-table-at-end-of-document-expected.txt: Added.
* editing/selection/tapping-in-table-at-end-of-document.html: Added.
* editing/text-iterator/table-at-end-of-document-expected.txt: Added.
* editing/text-iterator/table-at-end-of-document.html: Added.
* fast/block/positioning/insert-positioned-in-anonymous-crash-expected.txt:
* fast/css/css3-ch-unit-expected.txt: Line breaks are generated between block & inline-block elements
as expected.
* fast/css/percent-min-width-img-src-change-expected.txt:
* fast/css/percent-width-img-src-change-expected.txt:
* fast/css/pseudo-empty-display-none-expected.txt:
* fast/dom/HTMLAnchorElement/anchor-in-noscroll-iframe-crash-expected.txt:
* fast/dom/HTMLDivElement/align/getset-expected.txt:
* fast/dom/HTMLSelectElement/listbox-select-reset-expected.txt:
* fast/dom/HTMLTableElement/table-with-invalid-border-expected.txt:
* fast/forms/option-mouseevents-expected.txt:
* fast/history/multiple-classes-visited-expected.txt:
* fast/history/self-is-visited-expected.txt:
* fast/html/marquee-reparent-check-expected.txt:
* fast/inline-block/anonymous-block-crash-expected.txt: This test now demonstrates a bug that we're not
generating an empty line before a block in some cases.
* fast/inline/inline-position-top-align-expected.txt:
* fast/invalid/test-case-tr-th-td-should-not-close-dl-list-expected.txt:
* fast/overflow/scrollbar-click-retains-focus-expected.txt:
* fast/parser/comments-expected.txt:
* fast/parser/fragment-parser-doctype-expected.txt:
* fast/ruby/ruby-base-merge-block-children-crash-2-expected.txt:
* fast/spatial-navigation/snav-radio-group-expected.txt: A line break is generated after a nested table.
* fast/sub-pixel/table-cells-have-stable-width-expected.txt:
* fast/table/table-row-oveflow-crash-expected.txt: A line break is generated after a table as expected,
which is followed by a BR which creates a blank line.
* fast/table/table-with-borderattr-null-expected.txt:
* fast/table/table-with-borderattr-set-to-null-expected.txt:
* fast/text/international/dynamic-text-combine-crash-expected.txt:
* fast/xsl/mozilla-tests-expected.txt:
* http/tests/misc/large-js-program-expected.txt:
* imported/blink/plugins/empty-per-context-data-expected.txt:
* inspector/console/js-isLikelyStackTrace-expected.txt:
* inspector/console/js-source-locations-expected.txt:
* mathml/out-of-flow-in-token-crash-expected.txt:
* mathml/presentation/stretchy-depth-height-expected.txt:
* platform/mac/accessibility/table-cells-roles-expected.txt: Line breaks are generated after a block
followed by two two consecutive BRs.
* platform/mac/accessibility/table-roles-hierarchy-expected.txt: Ditto.
* svg/foreignObject/fO-fixed-position-crash-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-region-basic-expected.txt:
* transforms/3d/hit-testing/coplanar-with-camera-expected.txt:


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

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 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 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.