gecko-dev/testing/web-platform/tests/css/css-text/white-space/trailing-space-position-001.html
Koji Ishii 3a9623eda4 Bug 1585391 [wpt PR 19447] - [LayoutNG] Include empty/space-only trailing spans, a=testonly
Automatic update from web-platform-tests
[LayoutNG] Include empty/space-only trailing spans

This patch changes |NGLineBreaker| to include empty or space-
only trailing spans into the line.

Such spans were thought not observable, but it turned out
that they are in a few cases; e.g.,:
a. The space is wrapped in an inline box with borders; e.g.,
      text<span style="border: 1px solid"> </span>text
b. When it is not collapsed (e.g., `pre-wrap`) and is in an
   inline box with background.

Open tags are in most cases not-trailable but sometimes they
are. Before this change, |NGLineBreaker| assumed open tags
are not-trailable, and handles exceptional cases separately.
This patch changes open tags to be trailable. Then non-
trailable open tags were removed after the line breaking was
determined. With this chagne, the rare logic runs only once
for each wrapped line.

This patch:
1. Split over-loaded `kTrailing` state to `kOverflow` and
   `kTrailing`. This simplifies the conditions when each
   state can transit to other states.
2. Re-implemented negative margins[r674177]. The logic became
   simpler because open tags are now trailable by default.
3. Re-implemented hanging trailing space fix[r674430]. In
   addition to the fix, this patch handles trailing spaces in
   a span. We do not handle multiple space nodes yet as in
   TODO(crbug.com/1009936) comment, but this change moves one
   step closer to support it.

[r674177]: https://crrev.com/c/1684243
[r674430]: https://crrev.com/c/1662451

Bug: 1001241, 1003184
Change-Id: Ife2f8470a510f6e006da9d2397df5c5153e3abd1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1826063
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701601}

--

wpt-commits: 1239af63c689316e7485d02b4377dcb78ff71a83
wpt-pr: 19447
2019-10-14 11:23:21 +00:00

41 lines
1.3 KiB
HTML

<!DOCTYPE html>
<title>CSS Test: Positions of trailing collapsible spaces</title>
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-phase-2">
<link rel="author" title="Koji Ishii" href="mailto:kojii@chromium.org">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.container > div {
font-family: Ahem;
font-size: 10px;
line-height: 1;
color: gray;
width: 5ch;
outline: 2px solid orange;
margin-bottom: 6px;
position: relative;
}
.pre-wrap {
white-space: pre-wrap;
}
.bg { background: purple; }
.h { outline: 4px red solid; }
</style>
<body>
<section class="container">
<div>1234<span data-line="0" class="h"> </span>567</div>
<div>1234 <span data-line="0" class="h"> </span>567</div>
<div>1234567<span data-line="0" class="h"> </span>567</div>
<div>1234567 <span data-line="0" class="h"> </span>567</div>
<div class="pre-wrap">1234<span data-line="0" class="bg"> </span>567</div>
</section>
<script>
for (let e of document.querySelectorAll('[data-line]')) {
test(() => {
let y = e.offsetTop;
assert_equals(Math.round(y / 10), parseInt(e.dataset.line));
});
}
</script>
</body>