aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/display_list/builder.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-12-13 23:41:00 -0500
committerGitHub <noreply@github.com>2019-12-13 23:41:00 -0500
commit3f663d7ab216a841e6250b5b10ce64d34caff97c (patch)
tree4ca31af04203451dbb8fea1198415f319d18de1f /components/layout/display_list/builder.rs
parentecaf65408cd9a555cb36ace00b005fc6eec453c9 (diff)
parent6e67349d8c439050eeca49bfbe4feb74c2d4da4d (diff)
downloadservo-3f663d7ab216a841e6250b5b10ce64d34caff97c.tar.gz
servo-3f663d7ab216a841e6250b5b10ce64d34caff97c.zip
Auto merge of #25289 - pcwalton:glyph-cap, r=jdm
Cap the number of glyphs per WebRender text run to avoid overflowing WR's limit. Closes #17230. r? @jdm --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/layout/display_list/builder.rs')
-rw-r--r--components/layout/display_list/builder.rs31
1 files changed, 23 insertions, 8 deletions
diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs
index 0eceb02abdb..258c4f5490c 100644
--- a/components/layout/display_list/builder.rs
+++ b/components/layout/display_list/builder.rs
@@ -124,6 +124,11 @@ static THREAD_TINT_COLORS: [ColorF; 8] = [
},
];
+// An internal WebRender limit.
+//
+// See: https://github.com/servo/servo/issues/17230#issuecomment-564307277
+const MAX_GLYPHS_PER_TEXT_RUN: usize = 2000;
+
pub struct InlineNodeBorderInfo {
is_first_fragment_of_element: bool,
is_last_fragment_of_element: bool,
@@ -2069,19 +2074,27 @@ impl Fragment {
}
// Text
- let glyphs = convert_text_run_to_glyphs(
+ let mut glyphs = convert_text_run_to_glyphs(
text_fragment.run.clone(),
text_fragment.range,
baseline_origin,
);
- if !glyphs.is_empty() {
- let indexable_text = IndexableTextItem {
- origin: stacking_relative_content_box.origin,
- text_run: text_fragment.run.clone(),
- range: text_fragment.range,
- baseline_origin,
+
+ let indexable_text = IndexableTextItem {
+ origin: stacking_relative_content_box.origin,
+ text_run: text_fragment.run.clone(),
+ range: text_fragment.range,
+ baseline_origin,
+ };
+ state.indexable_text.insert(self.node, indexable_text);
+
+ // Process glyphs in chunks to avoid overflowing WebRender's internal limits (#17230).
+ while !glyphs.is_empty() {
+ let mut rest_of_glyphs = vec![];
+ if glyphs.len() > MAX_GLYPHS_PER_TEXT_RUN {
+ rest_of_glyphs = glyphs[MAX_GLYPHS_PER_TEXT_RUN..].to_vec();
+ glyphs.truncate(MAX_GLYPHS_PER_TEXT_RUN);
};
- state.indexable_text.insert(self.node, indexable_text);
state.add_display_item(DisplayItem::Text(CommonDisplayItem::with_data(
base.clone(),
@@ -2094,6 +2107,8 @@ impl Fragment {
},
glyphs,
)));
+
+ glyphs = rest_of_glyphs;
}
// TODO(#17715): emit text-emphasis marks here.