testing/web-platform/tests/css/css-grid/alignment/grid-alignment-style-changes-005.html
author Javier Fernandez <jfernandez@igalia.com>
Fri, 28 Sep 2018 09:54:07 +0000
changeset 487042 557a989b9ef788d50008720c20e5423086fe3ac9
permissions -rw-r--r--
Bug 1488291 [wpt PR 12816] - [css-grid] Performance optimizations in the Baseline alignment code, a=testonly Automatic update from web-platform-tests[css-grid] Performance optimizations in the Baseline alignment code Since we integrated the baseline alignment logic in the grid tracks sizing algorithm, its impact on performance has grown considerably. The analysis of the new logic added and its overhead, due to different operations, shows that evaluating the item's participation in the baseline alignment context is the most expensive one. It's specially demanding the evaluation of the grid item's alignment properties. Considering that currently we are doing this for every grid item, this CL propose to reuse the loop we already have to clear the grid item's override size to cache the items with a baseline value in their alignment CSS properties. Thanks to this cache we can determine the item's participation in a baseline alignment context in the different phases of the track sizing algorithm, with almost no cost (compared to the current logic). It may be possible to share the cache with the algorithm run for computing the grid's intrinsic size; however, if the intrinsic size logic is run before the grid's layout, we'll end up duplicating the cache. Additionally, this cache is also used in the alignment phase of the grid layout logic; this change helps to avoid the various issues we have been suffering related to the different evaluations of the item's participation in baseline during the different phases of the grid layout algorithm. BUG = 873452 Change-Id: Ida27be11ae0f5c455e6077367a277981ab35cec1 Reviewed-on: https://chromium-review.googlesource.com/1179897 Commit-Queue: Javier Fernandez <jfernandez@igalia.com> Reviewed-by: Manuel Rego <rego@igalia.com> Cr-Commit-Position: refs/heads/master@{#593552} -- wpt-commits: f6de5f7d5d50b1ad30a1e17922e183868fd3e935 wpt-pr: 12816

<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Grid Layout Test: Changing Self-Alignment properties to interfere in Baseline Alignment</title>
<link rel="author" title="Javier Fernandez Garcia-Boente" href="mailto:jfernandez@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-grid-1/#grid-align">
<link rel="help" href="https://drafts.csswg.org/css-align-3/#self-alignment">
<link rel="help" href="https://drafts.csswg.org/css-align-3/#align-self-property">
<link rel="help" href="https://drafts.csswg.org/css-align-3/#typedef-baseline-position">
<meta name="assert" content="Changing the 'align-self' property's value of a grid item from 'baseline' will exclude such item from its baseline context, which implies recomputing all the baseline offsets and aligning the items left in such context.">
<style>
#container {
  position: relative;
  display: inline-grid;
  grid: 100px / 50px 50px 50px;
  background: grey;
  align-items: baseline;
  font-family: Ahem;
}
#item1 {
  font-size: 20px;
  background: blue;
}
#item2 {
  font-size: 40px;
  background: green;
}
#item3 {
  font-size: 30px;
  background: red;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script src="support/style-change.js"></script>
<script>
function runTest() {
    let before = {
        item1: {"data-offset-y": 16 },
        item2: {"data-offset-y": 0  },
        item3: {"data-offset-y": 8  }
    }

    let after = {
        item1: {"data-offset-y": 8  },
        item2: {"data-offset-y": 60 },
        item3: {"data-offset-y": 0  }
    }

    evaluateStyleChangeMultiple("before", before);
    item2.style.alignSelf = "end";
    evaluateStyleChangeMultiple("after", after);
    done();
}
</script>
<body onload="runTest()">
    <div id="container">
        <div id="item1" data-expected-width="50" data-expected-height="20" data-offset-x="0">É</div>
        <div id="item2" data-expected-width="50" data-expected-height="40" data-offset-x="50">É</div>
        <div id="item3" data-expected-width="50" data-expected-height="30" data-offset-x="100">É</div>
    </div>
    <div id="log"></div>
</body>