Commit 109f6e33 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make NGInlineNode::ShapeText() not to reuse partial ShapeResult with letter-spacing

This patch makes |NGInlineNode::ShapeText()| not to reuse partial
|ShapeResult| with letter-spacing to avoid applying letter spacing
multiple times.

In the CL[1], we stop reusing full |ShapeResult| with letter spacing
but we reuse partial |ShapeResult|, e.g. before/after replaced text.

[1] http://crrev.com/c/2397105 Make NGInlineNode::ShapeText() not to reuse
ShapeResult for letter-spacing

Bug: 1124446, 1130611
Change-Id: I6132d0106038cb7d8ba8cf6ac02493e903804f5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2423648
Commit-Queue: Koji Ishii <kojii@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809788}
parent 64c520f4
......@@ -677,11 +677,11 @@ class NGInlineNodeDataEditor final {
unsigned start_offset) const {
DCHECK_LE(item.start_offset_, start_offset);
DCHECK_LT(start_offset, item.end_offset_);
if (item.start_offset_ == start_offset)
return item;
const unsigned end_offset = item.end_offset_;
if (!item.shape_result_)
if (!item.shape_result_ || item.shape_result_->IsAppliedSpacing())
return NGInlineItem(item, start_offset, end_offset, nullptr);
if (item.start_offset_ == start_offset)
return item;
// TODO(yosin): We should handle |shape_result| doesn't have safe-to-break
// at start and end, because of |ShapeText()| splits |ShapeResult| ignoring
// safe-to-break offset.
......@@ -701,11 +701,11 @@ class NGInlineNodeDataEditor final {
DCHECK_LT(item.start_offset_, end_offset);
DCHECK_LE(end_offset, item.end_offset_);
DCHECK_EQ(item.layout_object_, layout_text_);
if (item.end_offset_ == end_offset)
return item;
const unsigned start_offset = item.start_offset_;
if (!item.shape_result_)
if (!item.shape_result_ || item.shape_result_->IsAppliedSpacing())
return NGInlineItem(item, start_offset, end_offset, nullptr);
if (item.end_offset_ == end_offset)
return item;
// TODO(yosin): We should handle |shape_result| doesn't have safe-to-break
// at start and end, because of |ShapeText()| splits |ShapeResult| ignoring
// safe-to-break offset.
......
<!doctype html>
<script src="../../resources/ahem.js"></script>
<style>
.sample {
font: 10px/15px Ahem;
letter-spacing: 20px;
}
</style>
<div class="sample" id="target">abcdefg</div>
<div class="sample" id="expected">abcdefg</div>
<!doctype html>
<script src="../../resources/ahem.js"></script>
<style>
.sample {
font: 10px/15px Ahem;
letter-spacing: 20px;
}
</style>
<div class="sample" id="target">abcDEfg</div>
<div class="sample" id="expected">abcdefg</div>
<script>
document.body.offsetHeight;
const text = target.firstChild;
text.replaceData(3, 2, 'de');
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment