-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
bad-font-gc2.patch
3727 lines (3309 loc) · 158 KB
/
bad-font-gc2.patch
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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Chromium 123 was buggy, with tabs regularly hanging/crashing. The culprit
was the GC cleaning up font cache stuff, and deadlocking in a FontCacheKey
destructor:
Thread 54 (Thread 0x7fffc55fe6c0 (LWP 413811) "Chrome_InProcRe"):
#0 0x00007ffff6720719 in syscall () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x000055555c1752d9 in partition_alloc::internal::SpinningMutex::LockSlow() ()
#2 0x000055555c185529 in allocator_shim::internal::PartitionFree(allocator_shim::AllocatorDispatch const*, void*, void*) ()
#3 0x000055555f7db46b in blink::FontCacheKey::~FontCacheKey() ()
#4 0x000055555f7db6f4 in WTF::WeakProcessingHashTableHelper<(WTF::WeakHandlingFlag)1, blink::FontCacheKey, WTF::KeyValuePair<blink::FontCacheKey, cppgc::internal::BasicMember<blink::SegmentedFontData const, cppgc::internal::WeakMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer> >, WTF::KeyValuePairExtractor, WTF::HashMapValueTraits<WTF::HashTraits<blink::FontCacheKey>, WTF::HashTraits<cppgc::internal::BasicMember<blink::SegmentedFontData const, cppgc::internal::WeakMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer> > >, WTF::HashTraits<blink::FontCacheKey>, blink::HeapAllocator>::Process(cppgc::LivenessBroker const&, void const*) ()
#5 0x0000555559544bef in cppgc::internal::MarkerBase::ProcessWeakness() ()
#6 0x000055555954487e in cppgc::internal::MarkerBase::LeaveAtomicPause() ()
#7 0x0000555558e8115a in v8::internal::CppHeap::FinishMarkingAndStartSweeping() ()
#8 0x0000555558ebcdc0 in v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) ()
#9 0x0000555558ecfe14 in v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)::$_0::operator()() const ()
#10 0x0000555558ecfb65 in void heap::base::Stack::SetMarkerAndCallbackImpl<v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)::$_0>(heap::base::Stack*, void*, void const*) ()
--Type <RET> for more, q to quit, c to continue without paging--
#11 0x000055555955216b in PushAllRegistersAndIterateStack ()
#12 0x0000555558eb8c19 in v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) ()
#13 0x0000555558eba3eb in v8::internal::Heap::FinalizeIncrementalMarkingAtomically(v8::internal::GarbageCollectionReason) ()
#14 0x0000555558ed20db in v8::internal::IncrementalMarkingJob::Task::RunInternal() ()
#15 0x000055555c0c49d6 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) ()
#16 0x000055555c0daf88 in base::sequence_manager::internal::ThreadControllerImpl::DoWork(base::sequence_manager::internal::ThreadControllerImpl::WorkType) ()
#17 0x000055555c0c49d6 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) ()
#18 0x000055555c0dd8f9 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*) ()
#19 0x000055555c0dd3bf in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ()
#20 0x000055555c0ddd75 in non-virtual thunk to base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ()
#21 0x000055555c07eb4f in base::MessagePumpDefault::Run(base::MessagePump::Delegate*) ()
#22 0x000055555c0de110 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) ()
#23 0x000055555c0a4c26 in base::RunLoop::Run(base::Location const&) ()
#24 0x000055555c100155 in base::Thread::Run(base::RunLoop*) ()
#25 0x000055555c100342 in base::Thread::ThreadMain() ()
The commit below modified font stuff to go from using scoped_refptrs to
getting cleaned up via GC. Reverting it fixes chromium's behavior for us.
It would be good to get a proper fix for this, but reverting this will
have to do for now.
commit bff9ec6754f7bf97c61d84663ee2ccc5055e9eb3
Author: Ian Kilpatrick <[email protected]>
Date: Tue Feb 13 19:15:19 2024 +0000
[gc] Make SimpleFontData & FontPlatformData & friends gc'd.
The largest change is making the associated caches for these objects
weak collections instead of relying on the relatively complex purging
logic.
https://variable-lizards.glitch.me/ appears not to leak.
There should be no user-visible behaviour change.
Bug: 41490008
Change-Id: Iba581842459cf31f7f4fe60d83665f393a7d06a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5262982
Reviewed-by: Caleb Raitto <[email protected]>
Reviewed-by: Dominik Röttsches <[email protected]>
Commit-Queue: Ian Kilpatrick <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1259965}
--- a/third_party/blink/renderer/core/css/binary_data_font_face_source.cc
+++ b/third_party/blink/renderer/core/css/binary_data_font_face_source.cc
@@ -36,10 +36,10 @@ bool BinaryDataFontFaceSource::IsValid()
return custom_platform_data_.get();
}
-SimpleFontData* BinaryDataFontFaceSource::CreateFontData(
+scoped_refptr<SimpleFontData> BinaryDataFontFaceSource::CreateFontData(
const FontDescription& font_description,
const FontSelectionCapabilities& font_selection_capabilities) {
- return MakeGarbageCollected<SimpleFontData>(
+ return SimpleFontData::Create(
custom_platform_data_->GetFontPlatformData(
font_description.EffectiveFontSize(),
font_description.AdjustedSpecifiedSize(),
@@ -56,7 +56,7 @@ SimpleFontData* BinaryDataFontFaceSource
: ResolvedFontFeatures(),
font_description.Orientation(), font_description.VariationSettings(),
font_description.GetFontPalette()),
- MakeGarbageCollected<CustomFontData>());
+ CustomFontData::Create());
}
} // namespace blink
--- a/third_party/blink/renderer/core/css/binary_data_font_face_source.h
+++ b/third_party/blink/renderer/core/css/binary_data_font_face_source.h
@@ -20,8 +20,9 @@ class BinaryDataFontFaceSource final : p
bool IsValid() const override;
private:
- SimpleFontData* CreateFontData(const FontDescription&,
- const FontSelectionCapabilities&) override;
+ scoped_refptr<SimpleFontData> CreateFontData(
+ const FontDescription&,
+ const FontSelectionCapabilities&) override;
scoped_refptr<FontCustomPlatformData> custom_platform_data_;
};
--- a/third_party/blink/renderer/core/css/css_custom_font_data.h
+++ b/third_party/blink/renderer/core/css/css_custom_font_data.h
@@ -31,18 +31,13 @@ class CSSCustomFontData final : public C
public:
enum FallbackVisibility { kInvisibleFallback, kVisibleFallback };
- CSSCustomFontData(CSSFontFaceSource* source, FallbackVisibility visibility)
- : font_face_source_(source), fallback_visibility_(visibility) {
- if (source) {
- is_loading_ = source->IsLoading();
- }
+ static scoped_refptr<CSSCustomFontData> Create(
+ CSSFontFaceSource* source,
+ FallbackVisibility visibility) {
+ return base::AdoptRef(new CSSCustomFontData(source, visibility));
}
- ~CSSCustomFontData() override = default;
- void Trace(Visitor* visitor) const override {
- visitor->Trace(font_face_source_);
- CustomFontData::Trace(visitor);
- }
+ ~CSSCustomFontData() override = default;
bool ShouldSkipDrawing() const override {
if (font_face_source_) {
@@ -66,7 +61,16 @@ class CSSCustomFontData final : public C
}
private:
- Member<CSSFontFaceSource> font_face_source_;
+ CSSCustomFontData(CSSFontFaceSource* source, FallbackVisibility visibility)
+ : font_face_source_(source), fallback_visibility_(visibility) {
+ if (source) {
+ is_loading_ = source->IsLoading();
+ }
+ }
+
+ // TODO(Oilpan): consider moving (Custom)FontFace hierarchy to the heap,
+ // thereby making this reference a Member<>.
+ WeakPersistent<CSSFontFaceSource> font_face_source_;
FallbackVisibility fallback_visibility_;
mutable bool is_loading_ = false;
};
--- a/third_party/blink/renderer/core/css/css_font_face.cc
+++ b/third_party/blink/renderer/core/css/css_font_face.cc
@@ -114,7 +114,7 @@ bool CSSFontFace::FallbackVisibilityChan
return true;
}
-const SimpleFontData* CSSFontFace::GetFontData(
+scoped_refptr<SimpleFontData> CSSFontFace::GetFontData(
const FontDescription& font_description) {
if (!IsValid()) {
return nullptr;
@@ -140,7 +140,7 @@ const SimpleFontData* CSSFontFace::GetFo
return nullptr;
}
- if (const SimpleFontData* result =
+ if (scoped_refptr<SimpleFontData> result =
source->GetFontData(size_adjusted_description,
font_face_->GetFontSelectionCapabilities())) {
// The font data here is created using the primary font's description.
@@ -149,7 +149,7 @@ const SimpleFontData* CSSFontFace::GetFo
if (size_adjusted_description.HasSizeAdjust()) {
if (auto adjusted_size =
FontSizeFunctions::MetricsMultiplierAdjustedFontSize(
- result, size_adjusted_description)) {
+ result.get(), size_adjusted_description)) {
size_adjusted_description.SetAdjustedSize(adjusted_size.value());
result =
source->GetFontData(size_adjusted_description,
--- a/third_party/blink/renderer/core/css/css_font_face.h
+++ b/third_party/blink/renderer/core/css/css_font_face.h
@@ -76,7 +76,7 @@ class CORE_EXPORT CSSFontFace final : pu
bool FontLoaded(CSSFontFaceSource*);
bool FallbackVisibilityChanged(RemoteFontFaceSource*);
- const SimpleFontData* GetFontData(const FontDescription&);
+ scoped_refptr<SimpleFontData> GetFontData(const FontDescription&);
FontFace::LoadStatusType LoadStatus() const {
return font_face_->LoadStatus();
--- a/third_party/blink/renderer/core/css/css_font_face_source.cc
+++ b/third_party/blink/renderer/core/css/css_font_face_source.cc
@@ -31,11 +31,22 @@
#include "third_party/blink/renderer/platform/fonts/font_face_creation_params.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
+namespace {
+// An excessive amount of SimpleFontData objects is generated from
+// CSSFontFaceSource if a lot of varying FontDescriptions point to a web
+// font. These FontDescriptions can vary in size, font-feature-settings or
+// font-variation settings. Well known cases are animations of font-variation
+// settings, compare crbug.com/778352. For a start, let's reduce this number to
+// 1024, which is still a large number and should have enough steps for font
+// animations from the same font face source, but avoids unbounded growth.
+const size_t kMaxCachedFontData = 1024;
+} // namespace
+
namespace blink {
CSSFontFaceSource::~CSSFontFaceSource() = default;
-const SimpleFontData* CSSFontFaceSource::GetFontData(
+scoped_refptr<SimpleFontData> CSSFontFaceSource::GetFontData(
const FontDescription& font_description,
const FontSelectionCapabilities& font_selection_capabilities) {
// If the font hasn't loaded or an error occurred, then we've got nothing.
@@ -53,12 +64,52 @@ const SimpleFontData* CSSFontFaceSource:
FontCacheKey key =
font_description.CacheKey(FontFaceCreationParams(), is_unique_match);
- auto result = font_data_table_.insert(key, nullptr);
- if (result.is_new_entry) {
- result.stored_value->value =
- CreateFontData(font_description, font_selection_capabilities);
+ // Get or create the font data. Take care to avoid dangling references into
+ // font_data_table_, because it is modified below during pruning.
+ scoped_refptr<SimpleFontData> font_data;
+ {
+ auto* it = font_data_table_.insert(key, nullptr).stored_value;
+ if (!it->value) {
+ it->value = CreateFontData(font_description, font_selection_capabilities);
+ }
+ font_data = it->value;
+ }
+
+ font_cache_key_age.PrependOrMoveToFirst(key);
+ PruneOldestIfNeeded();
+
+ DCHECK_LE(font_data_table_.size(), kMaxCachedFontData);
+ // No release, because fontData is a reference to a RefPtr that is held in the
+ // font_data_table_.
+ return font_data;
+}
+
+void CSSFontFaceSource::PruneOldestIfNeeded() {
+ if (font_cache_key_age.size() > kMaxCachedFontData) {
+ DCHECK_EQ(font_cache_key_age.size() - 1, kMaxCachedFontData);
+ const FontCacheKey& key = font_cache_key_age.back();
+ auto font_data_entry = font_data_table_.Take(key);
+ font_cache_key_age.pop_back();
+ DCHECK_EQ(font_cache_key_age.size(), kMaxCachedFontData);
+ if (font_data_entry && font_data_entry->GetCustomFontData()) {
+ font_data_entry->GetCustomFontData()->ClearFontFaceSource();
+ }
+ }
+}
+
+void CSSFontFaceSource::PruneTable() {
+ if (font_data_table_.empty()) {
+ return;
+ }
+
+ for (const auto& item : font_data_table_) {
+ SimpleFontData* font_data = item.value.get();
+ if (font_data && font_data->GetCustomFontData()) {
+ font_data->GetCustomFontData()->ClearFontFaceSource();
+ }
}
- return result.stored_value->value.Get();
+ font_cache_key_age.clear();
+ font_data_table_.clear();
}
} // namespace blink
--- a/third_party/blink/renderer/core/css/css_font_face_source.h
+++ b/third_party/blink/renderer/core/css/css_font_face_source.h
@@ -30,9 +30,7 @@
#include "third_party/blink/renderer/core/css/font_display.h"
#include "third_party/blink/renderer/platform/fonts/font_cache_key.h"
#include "third_party/blink/renderer/platform/fonts/font_selection_types.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
-#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/linked_hash_set.h"
@@ -71,8 +69,8 @@ class CORE_EXPORT CSSFontFaceSource
return nullptr;
}
- const SimpleFontData* GetFontData(const FontDescription&,
- const FontSelectionCapabilities&);
+ scoped_refptr<SimpleFontData> GetFontData(const FontDescription&,
+ const FontSelectionCapabilities&);
// TODO(https://crbug.com/947461): IsLocalFontAvailable must not have a
// FontDescription argument.
@@ -93,29 +91,28 @@ class CORE_EXPORT CSSFontFaceSource
virtual bool HadBlankText() { return false; }
virtual void PaintRequested() {}
- virtual void Trace(Visitor* visitor) const {
- visitor->Trace(font_data_table_);
- }
+ virtual void Trace(Visitor* visitor) const {}
protected:
CSSFontFaceSource() = default;
- virtual const SimpleFontData* CreateFontData(
+ virtual scoped_refptr<SimpleFontData> CreateFontData(
const FontDescription&,
const FontSelectionCapabilities&) = 0;
-
- void ClearTable() { font_data_table_.clear(); }
+ void PruneTable();
// Report the font lookup for metrics collection. Only used for local font
// face sources currently.
virtual void ReportFontLookup(const FontDescription& font_description,
- const SimpleFontData* font_data,
+ SimpleFontData* font_data,
bool is_loading_fallback = false) {}
private:
- using FontDataTable =
- HeapHashMap<FontCacheKey, WeakMember<const SimpleFontData>>;
+ void PruneOldestIfNeeded();
+ using FontDataTable = HashMap<FontCacheKey, scoped_refptr<SimpleFontData>>;
+ using FontCacheKeyAgeList = LinkedHashSet<FontCacheKey>;
FontDataTable font_data_table_;
+ FontCacheKeyAgeList font_cache_key_age;
};
} // namespace blink
--- a/third_party/blink/renderer/core/css/css_font_selector.cc
+++ b/third_party/blink/renderer/core/css/css_font_selector.cc
@@ -162,7 +162,7 @@ void CSSFontSelector::FontCacheInvalidat
DispatchInvalidationCallbacks(FontInvalidationReason::kGeneralInvalidation);
}
-const FontData* CSSFontSelector::GetFontData(
+scoped_refptr<FontData> CSSFontSelector::GetFontData(
const FontDescription& font_description,
const FontFamily& font_family) {
const auto& family_name = font_family.FamilyName();
@@ -252,13 +252,13 @@ const FontData* CSSFontSelector::GetFont
family_name, request_description.GetScript(),
request_description.GenericFamily(), settings_family_name);
- const SimpleFontData* font_data =
+ scoped_refptr<SimpleFontData> font_data =
FontCache::Get().GetFontData(request_description, settings_family_name);
if (font_data && request_description.HasSizeAdjust()) {
DCHECK(RuntimeEnabledFeatures::CSSFontSizeAdjustEnabled());
if (auto adjusted_size =
FontSizeFunctions::MetricsMultiplierAdjustedFontSize(
- font_data, request_description)) {
+ font_data.get(), request_description)) {
FontDescription size_adjusted_description(request_description);
size_adjusted_description.SetAdjustedSize(adjusted_size.value());
font_data = FontCache::Get().GetFontData(size_adjusted_description,
--- a/third_party/blink/renderer/core/css/css_font_selector.h
+++ b/third_party/blink/renderer/core/css/css_font_selector.h
@@ -49,8 +49,8 @@ class CORE_EXPORT CSSFontSelector : publ
unsigned Version() const override { return font_face_cache_->Version(); }
- const FontData* GetFontData(const FontDescription&,
- const FontFamily&) override;
+ scoped_refptr<FontData> GetFontData(const FontDescription&,
+ const FontFamily&) override;
void FontFaceInvalidated(FontInvalidationReason) override;
--- a/third_party/blink/renderer/core/css/css_font_selector_base.cc
+++ b/third_party/blink/renderer/core/css/css_font_selector_base.cc
@@ -87,21 +87,21 @@ void CSSFontSelectorBase::ReportFailedLo
void CSSFontSelectorBase::ReportFontLookupByUniqueOrFamilyName(
const AtomicString& name,
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data) {
+ scoped_refptr<SimpleFontData> resulting_font_data) {
if (FontMatchingMetrics* font_matching_metrics = GetFontMatchingMetrics()) {
font_matching_metrics->ReportFontLookupByUniqueOrFamilyName(
- name, font_description, resulting_font_data);
+ name, font_description, resulting_font_data.get());
}
}
void CSSFontSelectorBase::ReportFontLookupByUniqueNameOnly(
const AtomicString& name,
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data,
+ scoped_refptr<SimpleFontData> resulting_font_data,
bool is_loading_fallback) {
if (FontMatchingMetrics* font_matching_metrics = GetFontMatchingMetrics()) {
font_matching_metrics->ReportFontLookupByUniqueNameOnly(
- name, font_description, resulting_font_data, is_loading_fallback);
+ name, font_description, resulting_font_data.get(), is_loading_fallback);
}
}
@@ -109,20 +109,20 @@ void CSSFontSelectorBase::ReportFontLook
UChar32 fallback_character,
FontFallbackPriority fallback_priority,
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data) {
+ scoped_refptr<SimpleFontData> resulting_font_data) {
if (FontMatchingMetrics* font_matching_metrics = GetFontMatchingMetrics()) {
font_matching_metrics->ReportFontLookupByFallbackCharacter(
fallback_character, fallback_priority, font_description,
- resulting_font_data);
+ resulting_font_data.get());
}
}
void CSSFontSelectorBase::ReportLastResortFallbackFontLookup(
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data) {
+ scoped_refptr<SimpleFontData> resulting_font_data) {
if (FontMatchingMetrics* font_matching_metrics = GetFontMatchingMetrics()) {
font_matching_metrics->ReportLastResortFallbackFontLookup(
- font_description, resulting_font_data);
+ font_description, resulting_font_data.get());
}
}
--- a/third_party/blink/renderer/core/css/css_font_selector_base.h
+++ b/third_party/blink/renderer/core/css/css_font_selector_base.h
@@ -46,23 +46,23 @@ class CORE_EXPORT CSSFontSelectorBase :
void ReportFontLookupByUniqueOrFamilyName(
const AtomicString& name,
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data) override;
+ scoped_refptr<SimpleFontData> resulting_font_data) override;
void ReportFontLookupByUniqueNameOnly(
const AtomicString& name,
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data,
+ scoped_refptr<SimpleFontData> resulting_font_data,
bool is_loading_fallback = false) override;
void ReportFontLookupByFallbackCharacter(
UChar32 fallback_character,
FontFallbackPriority fallback_priority,
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data) override;
+ scoped_refptr<SimpleFontData> resulting_font_data) override;
void ReportLastResortFallbackFontLookup(
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data) override;
+ scoped_refptr<SimpleFontData> resulting_font_data) override;
void ReportFontFamilyLookupByGenericFamily(
const AtomicString& generic_font_family_name,
--- a/third_party/blink/renderer/core/css/css_segmented_font_face.cc
+++ b/third_party/blink/renderer/core/css/css_segmented_font_face.cc
@@ -38,16 +38,42 @@
#include "third_party/blink/renderer/platform/fonts/segmented_font_data.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
+// See comment below in CSSSegmentedFontFace::GetFontData - the cache from
+// CSSSegmentedFontFace (which represents a group of @font-face declarations
+// with identical FontSelectionCapabilities but differing by unicode-range) to
+// FontData/SegmentedFontData, (i.e. the actual font blobs that can be used for
+// shaping and painting retrieved from a CSSFontFaceSource) is usually small
+// (less than a dozen, up to tens) for non-animation-cases, but grows fast to
+// thousands when animating variable font parameters. Set a limit until we start
+// dropping cache entries in animation scenarios.
+static constexpr size_t kFontDataTableMaxSize = 250;
+
namespace blink {
+// static
+CSSSegmentedFontFace* CSSSegmentedFontFace::Create(
+ FontSelectionCapabilities capabilities) {
+ return MakeGarbageCollected<CSSSegmentedFontFace>(capabilities);
+}
+
CSSSegmentedFontFace::CSSSegmentedFontFace(
FontSelectionCapabilities font_selection_capabilities)
: font_selection_capabilities_(font_selection_capabilities),
+ font_data_table_(kFontDataTableMaxSize),
font_faces_(MakeGarbageCollected<FontFaceList>()),
approximate_character_count_(0) {}
CSSSegmentedFontFace::~CSSSegmentedFontFace() = default;
+void CSSSegmentedFontFace::PruneTable() {
+ // Make sure the glyph page tree prunes out all uses of this custom font.
+ if (!font_data_table_.size()) {
+ return;
+ }
+
+ font_data_table_.Clear();
+}
+
bool CSSSegmentedFontFace::IsValid() const {
// Valid if at least one font face is valid.
return font_faces_->ForEachUntilTrue(
@@ -57,12 +83,12 @@ bool CSSSegmentedFontFace::IsValid() con
}
void CSSSegmentedFontFace::FontFaceInvalidated() {
- font_data_table_.clear();
+ PruneTable();
}
void CSSSegmentedFontFace::AddFontFace(FontFace* font_face,
bool css_connected) {
- font_data_table_.clear();
+ PruneTable();
font_face->CssFontFace()->AddSegmentedFontFace(this);
font_faces_->Insert(font_face, css_connected);
}
@@ -72,11 +98,11 @@ void CSSSegmentedFontFace::RemoveFontFac
return;
}
- font_data_table_.clear();
+ PruneTable();
font_face->CssFontFace()->RemoveSegmentedFontFace(this);
}
-const FontData* CSSSegmentedFontFace::GetFontData(
+scoped_refptr<FontData> CSSSegmentedFontFace::GetFontData(
const FontDescription& font_description) {
if (!IsValid()) {
return nullptr;
@@ -98,16 +124,16 @@ const FontData* CSSSegmentedFontFace::Ge
// usually only a small number of FontData/SegmentedFontData instances created
// per CSSSegmentedFontFace. Whereas in variable font animations, this number
// grows rapidly.
- auto it = font_data_table_.find(key);
+ auto it = font_data_table_.Get(key);
if (it != font_data_table_.end()) {
- const SegmentedFontData* cached_font_data = it->value.Get();
+ scoped_refptr<SegmentedFontData> cached_font_data = it->second;
if (cached_font_data && cached_font_data->NumFaces()) {
return cached_font_data;
}
}
- SegmentedFontData* created_font_data =
- MakeGarbageCollected<SegmentedFontData>();
+ scoped_refptr<SegmentedFontData> created_font_data =
+ SegmentedFontData::Create();
FontDescription requested_font_description(font_description);
const FontSelectionRequest& font_selection_request =
@@ -126,16 +152,26 @@ const FontData* CSSSegmentedFontFace::Ge
if (!font_face->CssFontFace()->IsValid()) {
return;
}
- if (const SimpleFontData* face_font_data =
+ if (scoped_refptr<SimpleFontData> face_font_data =
font_face->CssFontFace()->GetFontData(requested_font_description)) {
DCHECK(!face_font_data->IsSegmented());
- created_font_data->AppendFace(MakeGarbageCollected<FontDataForRangeSet>(
- std::move(face_font_data), font_face->CssFontFace()->Ranges()));
+ if (face_font_data->IsCustomFont()) {
+ created_font_data->AppendFace(base::AdoptRef(new FontDataForRangeSet(
+ std::move(face_font_data), font_face->CssFontFace()->Ranges())));
+ } else {
+ created_font_data->AppendFace(
+ base::AdoptRef(new FontDataForRangeSetFromCache(
+ std::move(face_font_data),
+ font_face->CssFontFace()->Ranges())));
+ }
}
});
if (created_font_data->NumFaces()) {
- font_data_table_.insert(std::move(key), created_font_data);
+ scoped_refptr<SegmentedFontData> put_to_cache(created_font_data);
+ font_data_table_.Put(std::move(key), std::move(put_to_cache));
+ // No release, we have a reference to an object in the cache which should
+ // retain the ref count it has.
return created_font_data;
}
@@ -186,7 +222,6 @@ void CSSSegmentedFontFace::Match(const S
}
void CSSSegmentedFontFace::Trace(Visitor* visitor) const {
- visitor->Trace(font_data_table_);
visitor->Trace(font_faces_);
}
--- a/third_party/blink/renderer/core/css/css_segmented_font_face.h
+++ b/third_party/blink/renderer/core/css/css_segmented_font_face.h
@@ -32,7 +32,6 @@
#include "third_party/blink/renderer/platform/fonts/font_cache_key.h"
#include "third_party/blink/renderer/platform/fonts/font_selection_types.h"
#include "third_party/blink/renderer/platform/fonts/segmented_font_data.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_linked_hash_set.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
@@ -84,6 +83,8 @@ class FontFaceList : public GarbageColle
class CSSSegmentedFontFace final
: public GarbageCollected<CSSSegmentedFontFace> {
public:
+ static CSSSegmentedFontFace* Create(FontSelectionCapabilities);
+
explicit CSSSegmentedFontFace(FontSelectionCapabilities);
~CSSSegmentedFontFace();
@@ -99,7 +100,7 @@ class CSSSegmentedFontFace final
void RemoveFontFace(FontFace*);
bool IsEmpty() const { return font_faces_->IsEmpty(); }
- const FontData* GetFontData(const FontDescription&);
+ scoped_refptr<FontData> GetFontData(const FontDescription&);
bool CheckFont(UChar32) const;
void Match(const String&, HeapVector<Member<FontFace>>*) const;
@@ -112,11 +113,12 @@ class CSSSegmentedFontFace final
void Trace(Visitor*) const;
private:
+ void PruneTable();
bool IsValid() const;
FontSelectionCapabilities font_selection_capabilities_;
- HeapHashMap<FontCacheKey, WeakMember<const SegmentedFontData>>
+ base::HashingLRUCache<FontCacheKey, scoped_refptr<SegmentedFontData>>
font_data_table_;
// All non-CSS-connected FontFaces are stored after the CSS-connected ones.
--- a/third_party/blink/renderer/core/css/font_face_cache.cc
+++ b/third_party/blink/renderer/core/css/font_face_cache.cc
@@ -85,8 +85,8 @@ void FontFaceCache::CapabilitiesSet::Add
const auto result =
map_.insert(font_face->GetFontSelectionCapabilities(), nullptr);
if (result.is_new_entry) {
- result.stored_value->value = MakeGarbageCollected<CSSSegmentedFontFace>(
- font_face->GetFontSelectionCapabilities());
+ result.stored_value->value =
+ CSSSegmentedFontFace::Create(font_face->GetFontSelectionCapabilities());
}
result.stored_value->value->AddFontFace(font_face, css_connected);
--- a/third_party/blink/renderer/core/css/local_font_face_source.cc
+++ b/third_party/blink/renderer/core/css/local_font_face_source.cc
@@ -52,22 +52,23 @@ bool LocalFontFaceSource::IsLocalFontAva
return font_available;
}
-const SimpleFontData* LocalFontFaceSource::CreateLoadingFallbackFontData(
+scoped_refptr<SimpleFontData>
+LocalFontFaceSource::CreateLoadingFallbackFontData(
const FontDescription& font_description) {
FontCachePurgePreventer font_cache_purge_preventer;
- const SimpleFontData* temporary_font =
- FontCache::Get().GetLastResortFallbackFont(font_description);
+ scoped_refptr<SimpleFontData> temporary_font =
+ FontCache::Get().GetLastResortFallbackFont(font_description,
+ kDoNotRetain);
if (!temporary_font) {
NOTREACHED();
return nullptr;
}
- CSSCustomFontData* css_font_data = MakeGarbageCollected<CSSCustomFontData>(
- this, CSSCustomFontData::kVisibleFallback);
- return MakeGarbageCollected<SimpleFontData>(&temporary_font->PlatformData(),
- css_font_data);
+ scoped_refptr<CSSCustomFontData> css_font_data =
+ CSSCustomFontData::Create(this, CSSCustomFontData::kVisibleFallback);
+ return SimpleFontData::Create(temporary_font->PlatformData(), css_font_data);
}
-const SimpleFontData* LocalFontFaceSource::CreateFontData(
+scoped_refptr<SimpleFontData> LocalFontFaceSource::CreateFontData(
const FontDescription& font_description,
const FontSelectionCapabilities&) {
if (!IsValid()) {
@@ -84,9 +85,9 @@ const SimpleFontData* LocalFontFaceSourc
}
if (IsValid() && IsLoading()) {
- const SimpleFontData* fallback_font_data =
+ scoped_refptr<SimpleFontData> fallback_font_data =
CreateLoadingFallbackFontData(font_description);
- ReportFontLookup(font_description, fallback_font_data,
+ ReportFontLookup(font_description, fallback_font_data.get(),
true /* is_loading_fallback */);
return fallback_font_data;
}
@@ -110,10 +111,10 @@ const SimpleFontData* LocalFontFaceSourc
#endif
// TODO(https://crbug.com/1302264): Enable passing down of font-palette
// information here (font_description.GetFontPalette()).
- const SimpleFontData* font_data = FontCache::Get().GetFontData(
+ scoped_refptr<SimpleFontData> font_data = FontCache::Get().GetFontData(
unstyled_description, font_name_, AlternateFontName::kLocalUniqueFace);
- histograms_.Record(font_data);
- ReportFontLookup(unstyled_description, font_data);
+ histograms_.Record(font_data.get());
+ ReportFontLookup(unstyled_description, font_data.get());
return font_data;
}
@@ -132,7 +133,7 @@ void LocalFontFaceSource::BeginLoadIfNee
}
void LocalFontFaceSource::NotifyFontUniqueNameLookupReady() {
- ClearTable();
+ PruneTable();
if (face_->FontLoaded(this)) {
font_selector_->FontFaceInvalidated(
@@ -168,7 +169,7 @@ void LocalFontFaceSource::Trace(Visitor*
void LocalFontFaceSource::ReportFontLookup(
const FontDescription& font_description,
- const SimpleFontData* font_data,
+ SimpleFontData* font_data,
bool is_loading_fallback) {
font_selector_->ReportFontLookupByUniqueNameOnly(
font_name_, font_description, font_data, is_loading_fallback);
--- a/third_party/blink/renderer/core/css/local_font_face_source.h
+++ b/third_party/blink/renderer/core/css/local_font_face_source.h
@@ -48,15 +48,16 @@ class LocalFontFaceSource final : public
void NotifyFontUniqueNameLookupReady();
protected:
- const SimpleFontData* CreateLoadingFallbackFontData(const FontDescription&);
+ scoped_refptr<SimpleFontData> CreateLoadingFallbackFontData(
+ const FontDescription&);
private:
- const SimpleFontData* CreateFontData(
+ scoped_refptr<SimpleFontData> CreateFontData(
const FontDescription&,
const FontSelectionCapabilities&) override;
void ReportFontLookup(const FontDescription& font_description,
- const SimpleFontData* font_data,
+ SimpleFontData* font_data,
bool is_loading_fallback = false) override;
class LocalFontHistograms {
--- a/third_party/blink/renderer/core/css/offscreen_font_selector.cc
+++ b/third_party/blink/renderer/core/css/offscreen_font_selector.cc
@@ -39,7 +39,7 @@ void OffscreenFontSelector::RegisterForI
void OffscreenFontSelector::UnregisterForInvalidationCallbacks(
FontSelectorClient* client) {}
-const FontData* OffscreenFontSelector::GetFontData(
+scoped_refptr<FontData> OffscreenFontSelector::GetFontData(
const FontDescription& font_description,
const FontFamily& font_family) {
const auto& family_name = font_family.FamilyName();
@@ -60,11 +60,11 @@ const FontData* OffscreenFontSelector::G
family_name, font_description.GetScript(),
font_description.GenericFamily(), settings_family_name);
- const auto* font_data =
+ auto font_data =
FontCache::Get().GetFontData(font_description, settings_family_name);
ReportFontLookupByUniqueOrFamilyName(settings_family_name, font_description,
- font_data);
+ font_data.get());
return font_data;
}
--- a/third_party/blink/renderer/core/css/offscreen_font_selector.h
+++ b/third_party/blink/renderer/core/css/offscreen_font_selector.h
@@ -26,8 +26,8 @@ class CORE_EXPORT OffscreenFontSelector
unsigned Version() const override { return 1; }
- const FontData* GetFontData(const FontDescription&,
- const FontFamily&) override;
+ scoped_refptr<FontData> GetFontData(const FontDescription&,
+ const FontFamily&) override;
void RegisterForInvalidationCallbacks(FontSelectorClient*) override;
void UnregisterForInvalidationCallbacks(FontSelectorClient*) override;
--- a/third_party/blink/renderer/core/css/remote_font_face_source.cc
+++ b/third_party/blink/renderer/core/css/remote_font_face_source.cc
@@ -240,7 +240,8 @@ void RemoteFontFaceSource::NotifyFinishe
}
ClearResource();
- ClearTable();
+
+ PruneTable();
if (GetDocument()) {
if (!GetDocument()->RenderingHasBegun()) {
@@ -305,7 +306,7 @@ bool RemoteFontFaceSource::UpdatePeriod(
// Invalidate the font if its fallback visibility has changed.
if (IsLoading() && period_ != new_period &&
(period_ == kBlockPeriod || new_period == kBlockPeriod)) {
- ClearTable();
+ PruneTable();
if (face_->FallbackVisibilityChanged(this)) {
font_selector_->FontFaceInvalidated(
FontInvalidationReason::kGeneralInvalidation);
@@ -349,7 +350,7 @@ bool RemoteFontFaceSource::IsLowPriority
return is_intervention_triggered_;
}
-const SimpleFontData* RemoteFontFaceSource::CreateFontData(
+scoped_refptr<SimpleFontData> RemoteFontFaceSource::CreateFontData(
const FontDescription& font_description,
const FontSelectionCapabilities& font_selection_capabilities) {
if (period_ == kFailurePeriod || !IsValid()) {
@@ -362,7 +363,7 @@ const SimpleFontData* RemoteFontFaceSour
histograms_.RecordFallbackTime();
- return MakeGarbageCollected<SimpleFontData>(
+ return SimpleFontData::Create(
custom_font_data_->GetFontPlatformData(
font_description.EffectiveFontSize(),
font_description.AdjustedSpecifiedSize(),
@@ -379,24 +380,25 @@ const SimpleFontData* RemoteFontFaceSour
: ResolvedFontFeatures(),
font_description.Orientation(), font_description.VariationSettings(),
font_description.GetFontPalette()),
- MakeGarbageCollected<CustomFontData>());
+ CustomFontData::Create());
}
-const SimpleFontData* RemoteFontFaceSource::CreateLoadingFallbackFontData(
+scoped_refptr<SimpleFontData>
+RemoteFontFaceSource::CreateLoadingFallbackFontData(
const FontDescription& font_description) {
// This temporary font is not retained and should not be returned.
FontCachePurgePreventer font_cache_purge_preventer;
- const SimpleFontData* temporary_font =
- FontCache::Get().GetLastResortFallbackFont(font_description);
+ scoped_refptr<SimpleFontData> temporary_font =
+ FontCache::Get().GetLastResortFallbackFont(font_description,
+ kDoNotRetain);
if (!temporary_font) {
DUMP_WILL_BE_NOTREACHED_NORETURN();
return nullptr;
}
- CSSCustomFontData* css_font_data = MakeGarbageCollected<CSSCustomFontData>(
+ scoped_refptr<CSSCustomFontData> css_font_data = CSSCustomFontData::Create(
this, period_ == kBlockPeriod ? CSSCustomFontData::kInvisibleFallback
: CSSCustomFontData::kVisibleFallback);
- return MakeGarbageCollected<SimpleFontData>(&temporary_font->PlatformData(),
- css_font_data);
+ return SimpleFontData::Create(temporary_font->PlatformData(), css_font_data);
}
void RemoteFontFaceSource::BeginLoadIfNeeded() {
--- a/third_party/blink/renderer/core/css/remote_font_face_source.h
+++ b/third_party/blink/renderer/core/css/remote_font_face_source.h
@@ -66,10 +66,11 @@ class RemoteFontFaceSource final : publi
void Trace(Visitor*) const override;
protected:
- const SimpleFontData* CreateFontData(
+ scoped_refptr<SimpleFontData> CreateFontData(
const FontDescription&,
const FontSelectionCapabilities&) override;
- const SimpleFontData* CreateLoadingFallbackFontData(const FontDescription&);
+ scoped_refptr<SimpleFontData> CreateLoadingFallbackFontData(
+ const FontDescription&);
private:
// Periods of the Font Display Timeline.
--- a/third_party/blink/renderer/core/frame/font_matching_metrics.cc
+++ b/third_party/blink/renderer/core/frame/font_matching_metrics.cc
@@ -127,7 +127,7 @@ void FontMatchingMetrics::ReportLocalFon
}
void FontMatchingMetrics::InsertFontHashIntoMap(IdentifiableTokenKey input_key,
- const SimpleFontData* font_data,
+ SimpleFontData* font_data,
TokenToTokenHashMap& hash_map) {
DCHECK(IdentifiabilityStudyShouldSampleFonts());
if (hash_map.Contains(input_key)) {
@@ -160,7 +160,7 @@ FontMatchingMetrics::GetTokenBuilderWith
void FontMatchingMetrics::ReportFontLookupByUniqueOrFamilyName(
const AtomicString& name,
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data) {
+ SimpleFontData* resulting_font_data) {
Dactyloscoper::TraceFontLookup(
execution_context_, name, font_description,
Dactyloscoper::FontLookupType::kUniqueOrFamilyName);
@@ -184,7 +184,7 @@ void FontMatchingMetrics::ReportFontLook
void FontMatchingMetrics::ReportFontLookupByUniqueNameOnly(
const AtomicString& name,
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data,
+ SimpleFontData* resulting_font_data,
bool is_loading_fallback) {
// We ignore lookups that result in loading fallbacks for now as they should
// only be temporary.
@@ -217,7 +217,7 @@ void FontMatchingMetrics::ReportFontLook
UChar32 fallback_character,
FontFallbackPriority fallback_priority,
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data) {
+ SimpleFontData* resulting_font_data) {
if (!IdentifiabilityStudySettings::Get()->ShouldSampleType(
IdentifiableSurface::Type::kLocalFontLookupByFallbackCharacter)) {
return;
@@ -236,7 +236,7 @@ void FontMatchingMetrics::ReportFontLook
void FontMatchingMetrics::ReportLastResortFallbackFontLookup(
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data) {
+ SimpleFontData* resulting_font_data) {
if (!IdentifiabilityStudySettings::Get()->ShouldSampleType(
IdentifiableSurface::Type::kLocalFontLookupAsLastResort)) {
return;
@@ -361,8 +361,7 @@ void FontMatchingMetrics::PublishAllMetr
PublishEmojiGlyphMetrics();
}
-int64_t FontMatchingMetrics::GetHashForFontData(
- const SimpleFontData* font_data) {
+int64_t FontMatchingMetrics::GetHashForFontData(SimpleFontData* font_data) {
return font_data ? FontGlobalContext::Get()
.GetOrComputeTypefaceDigest(font_data->PlatformData())
.ToUkmMetricValue()
@@ -370,7 +369,7 @@ int64_t FontMatchingMetrics::GetHashForF
}
IdentifiableToken FontMatchingMetrics::GetPostScriptNameTokenForFontData(
- const SimpleFontData* font_data) {
+ SimpleFontData* font_data) {
DCHECK(font_data);
return FontGlobalContext::Get().GetOrComputePostScriptNameDigest(
font_data->PlatformData());
--- a/third_party/blink/renderer/core/frame/font_matching_metrics.h
+++ b/third_party/blink/renderer/core/frame/font_matching_metrics.h
@@ -100,16 +100,15 @@ class FontMatchingMetrics {
void ReportFontLookupByUniqueOrFamilyName(
const AtomicString& name,
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data);
+ SimpleFontData* resulting_font_data);
// Reports a local font was looked up by a name and font description. This
// only includes lookups where the name is allowed to match PostScript names
// and full font names, but not family names.
- void ReportFontLookupByUniqueNameOnly(
- const AtomicString& name,
- const FontDescription& font_description,
- const SimpleFontData* resulting_font_data,
- bool is_loading_fallback = false);
+ void ReportFontLookupByUniqueNameOnly(const AtomicString& name,
+ const FontDescription& font_description,
+ SimpleFontData* resulting_font_data,
+ bool is_loading_fallback = false);
// Reports a font was looked up by a fallback character, fallback priority,
// and a font description.
@@ -117,12 +116,12 @@ class FontMatchingMetrics {
UChar32 fallback_character,
FontFallbackPriority fallback_priority,
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data);
+ SimpleFontData* resulting_font_data);
// Reports a last-resort fallback font was looked up by a font description.
void ReportLastResortFallbackFontLookup(
const FontDescription& font_description,
- const SimpleFontData* resulting_font_data);
+ SimpleFontData* resulting_font_data);
// Reports a generic font family name was matched according to the script and
// the user's preferences to a font family name.
@@ -171,7 +170,7 @@ class FontMatchingMetrics {
// nullptr, then the typeface digest will also be saved with its PostScript
// name in |font_load_postscript_name_|.
void InsertFontHashIntoMap(IdentifiableTokenKey input_key,
- const SimpleFontData* font_data,
+ SimpleFontData* font_data,
TokenToTokenHashMap& hash_map);
// Reports a local font's existence was looked up by a name, but its actual
@@ -194,14 +193,14 @@ class FontMatchingMetrics {
// Get a hash that uniquely represents the font data. Returns 0 if |font_data|
// is nullptr.
- int64_t GetHashForFontData(const SimpleFontData* font_data);
+ int64_t GetHashForFontData(SimpleFontData* font_data);
void Initialize();
// Get a token that uniquely represents the typeface's PostScript name. May
// represent the empty string if no PostScript name was found.
IdentifiableToken GetPostScriptNameTokenForFontData(
- const SimpleFontData* font_data);
+ SimpleFontData* font_data);
TokenToTokenHashMap font_lookups_by_unique_or_family_name_;
TokenToTokenHashMap font_lookups_by_unique_name_only_;
--- a/third_party/blink/renderer/core/html/forms/internal_popup_menu.cc
+++ b/third_party/blink/renderer/core/html/forms/internal_popup_menu.cc