Commit 04ddd2bc authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Propagate ShapeResult::is_applied_spacing_ to copied ranges

This patch changes |ShapeResult::CopyRangeInternal()| to copy
|is_applied_spacing_| flag to source to copied |ShapeResult| to prevent
reusing them.

Background:
In |NGInlineNode::ShapeText()|, we shape text as much as possible, eg.
using same font like "abc <u>def</u>", then split |ShapeResult| for
each DOM node, e.g. "abc " and "<u>def</u>" by using |ShapeResult::
CopyRange()|, uses |CopyRangeInternal()|.

Before this patch, each copied |ShapeResult::is_applied_spacing_| is
false because we forgot to mark it.

Bug: 1124446
Change-Id: Ibc0601f214a166c6cfd0a713d79ffa60fafb66ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2507244
Commit-Queue: Kent Tamura <tkent@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822542}
parent eb496531
......@@ -904,6 +904,9 @@ void ShapeResult::ApplySpacingImpl(
void ShapeResult::ApplySpacing(ShapeResultSpacing<String>& spacing,
int text_start_offset) {
// For simplicity, we apply spacing once only. If you want to do multiple
// time, please get rid of below |DCHECK()|.
DCHECK(!is_applied_spacing_) << this;
is_applied_spacing_ = true;
ApplySpacingImpl(spacing, text_start_offset);
}
......@@ -1255,6 +1258,8 @@ unsigned ShapeResult::CopyRangeInternal(unsigned run_index,
unsigned target_num_characters_before = target->num_characters_;
#endif
target->is_applied_spacing_ |= is_applied_spacing_;
// When |target| is empty, its character indexes are the specified sub range
// of |this|. Otherwise the character indexes are renumbered to be continuous.
//
......
<!doctype html>
<script src="../../resources/ahem.js"></script>
<style>
.sample {
font: 10px/15px Ahem;
letter-spacing: 20px;
}
</style>
<div class="sample" id="sample1"><span href="#">abcXX</span> def</div>
<div class="sample" id="sample2"><span href="#">abc</span> dXXef</div>
<!doctype html>
<script src="../../resources/ahem.js"></script>
<style>
.sample {
font: 10px/15px Ahem;
letter-spacing: 20px;
}
</style>
<div class="sample" id="target1"><span href="#">abc</span> def</div>
<div class="sample" id="target2"><span href="#">abc</span> def</div>
<script>
for (let i = 0; i < 2; ++i) {
document.body.offsetHeight;
target1.firstChild.firstChild.appendData('X');
target2.lastChild.insertData(2, 'X');
}
</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