Skip to content

Commit 4b03f56

Browse files
committed
two nested positioned inlines could paint incorrectly
The parent could have hasText but _not_ have hasForegroundInLayer due to a layer boundary from one of its children
1 parent 3261114 commit 4b03f56

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/layout-text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class Run extends RenderItem {
139139
parent.bitfield |= Box.BITS.hasNewlines;
140140
}
141141

142-
if (!parent.hasText() && !isSpaceOrTabOrNewline(paragraph[i])) {
142+
if (!isSpaceOrTabOrNewline(paragraph[i])) {
143143
parent.bitfield |= Run.TEXT_BITS;
144144
}
145145
}

test/paint.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,23 @@ describe('Painting', function () {
697697
]);
698698
});
699699

700+
it('paints backgrounds below positioned inlines in relative order', function () {
701+
this.layout(`
702+
Get a
703+
<span style="position: relative;">
704+
<span style="background-color: #fca; position: relative;">wool</span>
705+
blanket
706+
</span>
707+
`);
708+
709+
expect(this.paint().getCalls()).to.deep.equal([
710+
{t: 'text', x: 0, y: 12.8, text: 'Get a ', fillColor: '#000'},
711+
{t: 'text', x: 160, y: 12.8, text: ' blanket', fillColor: '#000'},
712+
{t: 'rect', x: 96, y: 0, width: 64, height: 16, fillColor: '#fca'},
713+
{t: 'text', x: 96, y: 12.8, text: 'wool', fillColor: '#000'}
714+
]);
715+
});
716+
700717
// TODO: would go better in a general box.spec.js
701718
describe('Pixel snapping', function () {
702719
it('snaps the border box', function () {

0 commit comments

Comments
 (0)