summaryrefslogtreecommitdiff
path: root/chromium-125-debian-bad-font-gc0000.patch
blob: 7eaa721d8d3e7d0ffdba89d25b2ce0a07d6d9675 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
Revert the following commit:


commit cc6c0b2a9e1dbc96f3ebed713dc71960a29dc4f1
Author: Ian Kilpatrick <ikilpatrick@chromium.org>
Date:   Tue Mar 5 20:27:13 2024 +0000

    Reland "[gc] Make FontFamily immutable."
    
    This reverts commit 748ed11510ec5bb09cc8b92f67f1f62964f023fa.
    
    Reason for revert: Previous patch which caused MSAN issue was reapplied.
    
    Original change's description:
    > Revert "[gc] Make FontFamily immutable."
    >
    > This reverts commit ca3d3085d8b01fc74623d639c615fc57842cd26d.
    >
    > Reason for revert: crrev.com/c/5328767 is the reason for failure on some tests on MSAN. Please see crbug.com/327969288 for more details.
    >
    > Original change's description:
    > > [gc] Make FontFamily immutable.
    > >
    > > Previously we'd build up font-family lists front to back, but would
    > > need to mutate them to do so. Instead just build them backwards.
    > >
    > > This removes a bunch of problematic APIs (like AppendFamily - which
    > > doesn't append), and simplifies the code.
    > >
    > > This will help avoid atomic write barriers once converted to oilpan.
    > >
    > > Bug: 41490008
    > > Change-Id: Icfcec2d0a1716585cf42985616c02b42b6647943
    > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5322929
    > > Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
    > > Reviewed-by: Dominik Röttsches <drott@chromium.org>
    > > Cr-Commit-Position: refs/heads/main@{#1267168}
    >
    > Bug: 41490008, 327969288
    > Change-Id: Ic69a5707d00cc98b97dcae3f4b8207b452ce5cbd
    > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5333950
    > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
    > Commit-Queue: Taiyo Mizuhashi <taiyo@chromium.org>
    > Owners-Override: Taiyo Mizuhashi <taiyo@chromium.org>
    > Cr-Commit-Position: refs/heads/main@{#1267674}
    
    Bug: 41490008, 327969288
    Change-Id: If1d395e324b0be15488ef5410e9bcdb219bb19c6
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5344844
    Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
    Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
    Cr-Commit-Position: refs/heads/main@{#1268654}

--- a/third_party/blink/renderer/core/css/css_font_face.cc
+++ b/third_party/blink/renderer/core/css/css_font_face.cc
@@ -216,8 +216,9 @@ bool CSSFontFace::MaybeLoadFont(const Fo
 
 void CSSFontFace::Load() {
   FontDescription font_description;
-  font_description.SetFamily(
-      FontFamily(font_face_->family(), FontFamily::Type::kFamilyName));
+  FontFamily font_family;
+  font_family.SetFamily(font_face_->family(), FontFamily::Type::kFamilyName);
+  font_description.SetFamily(font_family);
   Load(font_description);
 }
 
--- a/third_party/blink/renderer/core/css/font_face_set_document.cc
+++ b/third_party/blink/renderer/core/css/font_face_set_document.cc
@@ -195,10 +195,13 @@ bool FontFaceSetDocument::ResolveFontSty
   ComputedStyleBuilder builder =
       GetDocument()->GetStyleResolver().CreateComputedStyleBuilder();
 
-  FontDescription default_font_description;
-  default_font_description.SetFamily(FontFamily(
+  FontFamily font_family;
+  font_family.SetFamily(
       FontFaceSet::DefaultFontFamily(),
-      FontFamily::InferredTypeFor(FontFaceSet::DefaultFontFamily())));
+      FontFamily::InferredTypeFor(FontFaceSet::DefaultFontFamily()));
+
+  FontDescription default_font_description;
+  default_font_description.SetFamily(font_family);
   default_font_description.SetSpecifiedSize(FontFaceSet::kDefaultFontSize);
   default_font_description.SetComputedSize(FontFaceSet::kDefaultFontSize);
 
--- a/third_party/blink/renderer/core/css/font_face_set_worker.cc
+++ b/third_party/blink/renderer/core/css/font_face_set_worker.cc
@@ -84,10 +84,13 @@ bool FontFaceSetWorker::ResolveFontStyle
     return false;
   }
 
-  FontDescription default_font_description;
-  default_font_description.SetFamily(FontFamily(
+  FontFamily font_family;
+  font_family.SetFamily(
       FontFaceSet::DefaultFontFamily(),
-      FontFamily::InferredTypeFor(FontFaceSet::DefaultFontFamily())));
+      FontFamily::InferredTypeFor(FontFaceSet::DefaultFontFamily()));
+
+  FontDescription default_font_description;
+  default_font_description.SetFamily(font_family);
   default_font_description.SetSpecifiedSize(FontFaceSet::kDefaultFontSize);
   default_font_description.SetComputedSize(FontFaceSet::kDefaultFontSize);
 
--- a/third_party/blink/renderer/core/css/resolver/font_builder.cc
+++ b/third_party/blink/renderer/core/css/resolver/font_builder.cc
@@ -54,9 +54,11 @@ void FontBuilder::DidChangeWritingMode()
 }
 
 FontFamily FontBuilder::StandardFontFamily() const {
+  FontFamily family;
   const AtomicString& standard_font_family = StandardFontFamilyName();
-  return FontFamily(standard_font_family,
-                    FontFamily::InferredTypeFor(standard_font_family));
+  family.SetFamily(standard_font_family,
+                   FontFamily::InferredTypeFor(standard_font_family));
+  return family;
 }
 
 AtomicString FontBuilder::StandardFontFamilyName() const {
--- a/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
+++ b/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
@@ -379,8 +379,8 @@ FontDescription::FamilyDescription Style
 
   if (const auto* system_font =
           DynamicTo<cssvalue::CSSPendingSystemFontValue>(value)) {
-    desc.family = FontFamily(system_font->ResolveFontFamily(),
-                             FontFamily::Type::kFamilyName);
+    desc.family.SetFamily(system_font->ResolveFontFamily(),
+                          FontFamily::Type::kFamilyName);
     return desc;
   }
 
@@ -410,8 +410,10 @@ FontDescription::FamilyDescription Style
     // Take the previous value and wrap it in a `SharedFontFamily` adding to
     // the linked list.
     if (has_value) {
-      next =
-          SharedFontFamily::Create(family_name, family_type, std::move(next));
+      scoped_refptr<SharedFontFamily> shared = SharedFontFamily::Create();
+      shared->SetFamily(family_name, family_type);
+      shared->AppendFamily(next);
+      next = shared;
     }
     family_name = next_family_name;
     family_type = is_generic ? FontFamily::Type::kGenericFamily
@@ -442,7 +444,8 @@ FontDescription::FamilyDescription Style
   }
 #endif
 
-  desc.family = FontFamily(family_name, family_type, std::move(next));
+  desc.family.SetFamily(family_name, family_type);
+  desc.family.AppendFamily(next);
   return desc;
 }
 
--- a/third_party/blink/renderer/core/html/canvas/canvas_font_cache.cc
+++ b/third_party/blink/renderer/core/html/canvas/canvas_font_cache.cc
@@ -29,9 +29,11 @@ const int defaultFontSize = 10;
 
 const ComputedStyle* CreateDefaultFontStyle(const Document& document) {
   const AtomicString& default_font_family = font_family_names::kSansSerif;
+  FontFamily font_family;
+  font_family.SetFamily(default_font_family,
+                        FontFamily::InferredTypeFor(default_font_family));
   FontDescription default_font_description;
-  default_font_description.SetFamily(FontFamily(
-      default_font_family, FontFamily::InferredTypeFor(default_font_family)));
+  default_font_description.SetFamily(font_family);
   default_font_description.SetSpecifiedSize(defaultFontSize);
   default_font_description.SetComputedSize(defaultFontSize);
   ComputedStyleBuilder builder =
--- a/third_party/blink/renderer/core/page/drag_image.cc
+++ b/third_party/blink/renderer/core/page/drag_image.cc
@@ -127,9 +127,11 @@ static Font DeriveDragLabelFont(int size
   const AtomicString& family =
       LayoutThemeFontProvider::SystemFontFamily(CSSValueID::kNone);
 
+  FontFamily font_family;
+  font_family.SetFamily(family, FontFamily::InferredTypeFor(family));
+
   FontDescription description;
-  description.SetFamily(
-      FontFamily(family, FontFamily::InferredTypeFor(family)));
+  description.SetFamily(font_family);
   description.SetWeight(font_weight);
   description.SetSpecifiedSize(size);
   description.SetComputedSize(size);
--- a/third_party/blink/renderer/core/paint/embedded_object_painter.cc
+++ b/third_party/blink/renderer/core/paint/embedded_object_painter.cc
@@ -32,9 +32,11 @@ static Font ReplacementTextFont(const Do
   const float size = LayoutThemeFontProvider::SystemFontSize(
       CSSValueID::kWebkitSmallControl, document);
 
+  FontFamily font_family;
+  font_family.SetFamily(family, FontFamily::InferredTypeFor(family));
+
   FontDescription font_description;
-  font_description.SetFamily(
-      FontFamily(family, FontFamily::InferredTypeFor(family)));
+  font_description.SetFamily(font_family);
   font_description.SetWeight(kBoldWeightValue);
   font_description.SetSpecifiedSize(size);
   font_description.SetComputedSize(size);
--- a/third_party/blink/renderer/platform/exported/web_font_description.cc
+++ b/third_party/blink/renderer/platform/exported/web_font_description.cc
@@ -49,10 +49,13 @@ WebFontDescription::WebFontDescription(c
 }
 
 WebFontDescription::operator FontDescription() const {
+  FontFamily font_family;
+  font_family.SetFamily(family, family_is_generic
+                                    ? FontFamily::Type::kGenericFamily
+                                    : FontFamily::Type::kFamilyName);
+
   FontDescription desc;
-  desc.SetFamily(FontFamily(family, family_is_generic
-                                        ? FontFamily::Type::kGenericFamily
-                                        : FontFamily::Type::kFamilyName));
+  desc.SetFamily(font_family);
   desc.SetGenericFamily(
       static_cast<FontDescription::GenericFamilyType>(generic_family));
   desc.SetSpecifiedSize(size);
--- a/third_party/blink/renderer/platform/fonts/font_description.h
+++ b/third_party/blink/renderer/platform/fonts/font_description.h
@@ -195,6 +195,7 @@ class PLATFORM_EXPORT FontDescription {
   FamilyDescription GetFamilyDescription() const {
     return FamilyDescription(GenericFamily(), Family());
   }
+  FontFamily& FirstFamily() { return family_list_; }
   const FontFamily& FirstFamily() const { return family_list_; }
   Size GetSize() const {
     return Size(KeywordSize(), SpecifiedSize(), IsAbsoluteSize());
@@ -450,6 +451,10 @@ class PLATFORM_EXPORT FontDescription {
     return fields_.subpixel_ascent_descent_;
   }
 
+  void SetHashCategory(HashCategory category) {
+    fields_.hash_category_ = category;
+  }
+
   HashCategory GetHashCategory() const {
     return static_cast<HashCategory>(fields_.hash_category_);
   }
--- a/third_party/blink/renderer/platform/fonts/font_fallback_list.cc
+++ b/third_party/blink/renderer/platform/fonts/font_fallback_list.cc
@@ -178,8 +178,9 @@ const FontData* FontFallbackList::GetFon
 
   if (font_selector_) {
     // Try the user's preferred standard font.
-    FontFamily font_family(font_family_names::kWebkitStandard,
-                           FontFamily::Type::kGenericFamily);
+    FontFamily font_family;
+    font_family.SetFamily(font_family_names::kWebkitStandard,
+                          FontFamily::Type::kGenericFamily);
     if (const FontData* data =
             font_selector_->GetFontData(font_description, font_family)) {
       return data;
--- a/third_party/blink/renderer/platform/fonts/font_family.cc
+++ b/third_party/blink/renderer/platform/fonts/font_family.cc
@@ -49,6 +49,20 @@ bool operator==(const FontFamily& a, con
   return true;
 }
 
+wtf_size_t FontFamily::CountNames() const {
+  wtf_size_t count = 0;
+  for (const FontFamily* font_family = this; font_family;
+       font_family = font_family->Next())
+    ++count;
+  return count;
+}
+
+void FontFamily::AppendFamily(AtomicString family_name, Type family_type) {
+  scoped_refptr<SharedFontFamily> appended_family = SharedFontFamily::Create();
+  appended_family->SetFamily(family_name, family_type);
+  AppendFamily(appended_family);
+}
+
 String FontFamily::ToString() const {
   StringBuilder builder;
   builder.Append(family_name_);
--- a/third_party/blink/renderer/platform/fonts/font_family.h
+++ b/third_party/blink/renderer/platform/fonts/font_family.h
@@ -39,18 +39,16 @@ class PLATFORM_EXPORT FontFamily {
   DISALLOW_NEW();
 
  public:
-  // https://drafts.csswg.org/css-fonts/#font-family-prop
-  enum class Type : uint8_t { kFamilyName, kGenericFamily };
-
-  FontFamily(const AtomicString& family_name,
-             Type family_type,
-             scoped_refptr<SharedFontFamily> next = nullptr)
-      : family_name_(family_name),
-        next_(std::move(next)),
-        family_type_(family_type) {}
   FontFamily() = default;
   ~FontFamily();
 
+  // https://drafts.csswg.org/css-fonts/#font-family-prop
+  enum class Type : uint8_t { kFamilyName, kGenericFamily };
+
+  void SetFamily(const AtomicString& family_name, Type family_type) {
+    family_name_ = family_name;
+    family_type_ = family_type;
+  }
   // Return this font family's name. Note that it is never quoted nor escaped.
   // For web-exposed serialization, please rely instead on the functions
   // ComputedStyleUtils::ValueForFontFamily(const FontFamily&) and
@@ -59,8 +57,13 @@ class PLATFORM_EXPORT FontFamily {
   const AtomicString& FamilyName() const { return family_name_; }
   bool FamilyIsGeneric() const { return family_type_ == Type::kGenericFamily; }
 
+  // Returns number of linked `FontFamily` including `this`, so return value is
+  // greater than or equal to 1. When `Next()` is `nullptr`, return value is 1.
+  wtf_size_t CountNames() const;
   const FontFamily* Next() const;
 
+  void AppendFamily(scoped_refptr<SharedFontFamily>);
+  void AppendFamily(AtomicString family_name, Type family_type);
   scoped_refptr<SharedFontFamily> ReleaseNext();
 
   bool IsPrewarmed() const { return is_prewarmed_; }
@@ -93,19 +96,12 @@ class PLATFORM_EXPORT SharedFontFamily :
   SharedFontFamily(const SharedFontFamily&) = delete;
   SharedFontFamily& operator=(const SharedFontFamily&) = delete;
 
-  static scoped_refptr<SharedFontFamily> Create(
-      const AtomicString& family_name,
-      Type family_type,
-      scoped_refptr<SharedFontFamily> next = nullptr) {
-    return base::AdoptRef(
-        new SharedFontFamily(family_name, family_type, std::move(next)));
+  static scoped_refptr<SharedFontFamily> Create() {
+    return base::AdoptRef(new SharedFontFamily);
   }
 
  private:
-  SharedFontFamily(const AtomicString& family_name,
-                   Type family_type,
-                   scoped_refptr<SharedFontFamily> next)
-      : FontFamily(family_name, family_type, std::move(next)) {}
+  SharedFontFamily() = default;
 };
 
 PLATFORM_EXPORT bool operator==(const FontFamily&, const FontFamily&);
@@ -125,6 +121,10 @@ inline const FontFamily* FontFamily::Nex
   return next_.get();
 }
 
+inline void FontFamily::AppendFamily(scoped_refptr<SharedFontFamily> family) {
+  next_ = std::move(family);
+}
+
 inline scoped_refptr<SharedFontFamily> FontFamily::ReleaseNext() {
   return std::move(next_);
 }
--- a/third_party/blink/renderer/platform/graphics/placeholder_image.cc
+++ b/third_party/blink/renderer/platform/graphics/placeholder_image.cc
@@ -85,18 +85,23 @@ void DrawCenteredIcon(cc::PaintCanvas* c
 }
 
 FontDescription CreatePlaceholderFontDescription(float scale_factor) {
-  scoped_refptr<SharedFontFamily> arial = SharedFontFamily::Create(
-      font_family_names::kArial, FontFamily::Type::kFamilyName);
-  scoped_refptr<SharedFontFamily> helvetica = SharedFontFamily::Create(
-      font_family_names::kHelvetica, FontFamily::Type::kFamilyName, arial);
-  scoped_refptr<SharedFontFamily> helvetica_neue =
-      SharedFontFamily::Create(font_family_names::kHelveticaNeue,
-                               FontFamily::Type::kFamilyName, helvetica);
-  FontFamily roboto(font_family_names::kRoboto, FontFamily::Type::kFamilyName,
-                    helvetica_neue);
-
   FontDescription description;
-  description.SetFamily(roboto);
+  description.FirstFamily().SetFamily(font_family_names::kRoboto,
+                                      FontFamily::Type::kFamilyName);
+
+  scoped_refptr<SharedFontFamily> helvetica_neue = SharedFontFamily::Create();
+  helvetica_neue->SetFamily(font_family_names::kHelveticaNeue,
+                            FontFamily::Type::kFamilyName);
+  scoped_refptr<SharedFontFamily> helvetica = SharedFontFamily::Create();
+  helvetica->SetFamily(font_family_names::kHelvetica,
+                       FontFamily::Type::kFamilyName);
+  scoped_refptr<SharedFontFamily> arial = SharedFontFamily::Create();
+  arial->SetFamily(font_family_names::kArial, FontFamily::Type::kFamilyName);
+
+  helvetica->AppendFamily(std::move(arial));
+  helvetica_neue->AppendFamily(std::move(helvetica));
+  description.FirstFamily().AppendFamily(std::move(helvetica_neue));
+
   description.SetGenericFamily(FontDescription::kSansSerifFamily);
   description.SetComputedSize(scale_factor * kFontSize);
   description.SetWeight(FontSelectionValue(500));
--- a/third_party/blink/renderer/platform/testing/font_test_helpers.cc
+++ b/third_party/blink/renderer/platform/testing/font_test_helpers.cc
@@ -127,9 +127,11 @@ Font CreateTestFont(const AtomicString&
                     size_t data_size,
                     float size,
                     const FontDescription::VariantLigatures* ligatures) {
+  FontFamily family;
+  family.SetFamily(family_name, FontFamily::Type::kFamilyName);
+
   FontDescription font_description;
-  font_description.SetFamily(
-      FontFamily(family_name, FontFamily::Type::kFamilyName));
+  font_description.SetFamily(family);
   font_description.SetSpecifiedSize(size);
   font_description.SetComputedSize(size);
   if (ligatures)
@@ -143,9 +145,11 @@ Font CreateTestFont(const AtomicString&
                     float size,
                     const FontDescription::VariantLigatures* ligatures,
                     void (*init_font_description)(FontDescription*)) {
+  FontFamily family;
+  family.SetFamily(family_name, FontFamily::Type::kFamilyName);
+
   FontDescription font_description;
-  font_description.SetFamily(
-      FontFamily(family_name, FontFamily::Type::kFamilyName));
+  font_description.SetFamily(family);
   font_description.SetSpecifiedSize(size);
   font_description.SetComputedSize(size);
   if (ligatures)