File bad-font-gc00.patch of Package nodejs-electron
Revert the following commit:
commit 59daae50fc3c47f7a8dbcc828446fdaa9f8c12c4
Author: Ian Kilpatrick <ikilpatrick@chromium.org>
Date: Tue Feb 20 18:35:11 2024 +0000
[gc] Make OpenTypeVerticalData gc'd.
There should be no user-visible behaviour change.
Bug: 41490008
Change-Id: Id93c85a7beb710944e07cff614cff2409c818436
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5302893
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1262805}
--- a/third_party/blink/renderer/platform/fonts/font_platform_data.cc
+++ b/third_party/blink/renderer/platform/fonts/font_platform_data.cc
@@ -308,6 +308,11 @@ SkFont FontPlatformData::CreateSkFont(co
}
#endif // !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_IOS)
+scoped_refptr<OpenTypeVerticalData> FontPlatformData::CreateVerticalData()
+ const {
+ return OpenTypeVerticalData::CreateUnscaled(typeface_);
+}
+
IdentifiableToken FontPlatformData::ComputeTypefaceDigest() const {
DCHECK(typeface_);
int table_count = typeface_->countTables();
--- a/third_party/blink/renderer/platform/fonts/font_platform_data.h
+++ b/third_party/blink/renderer/platform/fonts/font_platform_data.h
@@ -59,6 +59,7 @@ typedef const struct __CTFont* CTFontRef
namespace blink {
class HarfBuzzFace;
+class OpenTypeVerticalData;
class PLATFORM_EXPORT FontPlatformData
: public GarbageCollected<FontPlatformData> {
@@ -137,6 +138,8 @@ class PLATFORM_EXPORT FontPlatformData
SkFont CreateSkFont(const FontDescription* = nullptr) const;
+ scoped_refptr<OpenTypeVerticalData> CreateVerticalData() const;
+
// Computes a digest from the typeface. The digest only depends on the
// underlying font itself, and does not vary by the style (size, weight,
// italics, etc). This is aimed at discovering the fingerprinting information
--- a/third_party/blink/renderer/platform/fonts/opentype/open_type_vertical_data.h
+++ b/third_party/blink/renderer/platform/fonts/opentype/open_type_vertical_data.h
@@ -27,10 +27,10 @@
#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/platform/fonts/glyph.h"
-#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/platform_export.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/ref_counted.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkTypeface.h"
@@ -40,11 +40,14 @@ class SkFont;
namespace blink {
class PLATFORM_EXPORT OpenTypeVerticalData
- : public GarbageCollected<OpenTypeVerticalData> {
- public:
- explicit OpenTypeVerticalData(sk_sp<SkTypeface>);
+ : public RefCounted<OpenTypeVerticalData> {
+ USING_FAST_MALLOC(OpenTypeVerticalData);
- void Trace(Visitor*) const {}
+ public:
+ static scoped_refptr<OpenTypeVerticalData> CreateUnscaled(
+ sk_sp<SkTypeface> typeface) {
+ return base::AdoptRef(new OpenTypeVerticalData(typeface));
+ }
void SetScaleAndFallbackMetrics(float size_per_unit,
float ascent,
@@ -60,6 +63,8 @@ class PLATFORM_EXPORT OpenTypeVerticalDa
float* out_xy_array) const;
private:
+ explicit OpenTypeVerticalData(sk_sp<SkTypeface>);
+
void LoadMetrics(sk_sp<SkTypeface>);
bool HasVORG() const { return !vert_origin_y_.empty(); }
--- a/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.cc
+++ b/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.cc
@@ -167,7 +167,8 @@ static hb_bool_t HarfBuzzGetGlyphVertica
void* user_data) {
HarfBuzzFontData* hb_font_data =
reinterpret_cast<HarfBuzzFontData*>(font_data);
- OpenTypeVerticalData* vertical_data = hb_font_data->VerticalData();
+ scoped_refptr<OpenTypeVerticalData> vertical_data =
+ hb_font_data->VerticalData();
if (!vertical_data)
return false;
@@ -186,7 +187,8 @@ static hb_position_t HarfBuzzGetGlyphVer
void* user_data) {
HarfBuzzFontData* hb_font_data =
reinterpret_cast<HarfBuzzFontData*>(font_data);
- OpenTypeVerticalData* vertical_data = hb_font_data->VerticalData();
+ scoped_refptr<OpenTypeVerticalData> vertical_data =
+ hb_font_data->VerticalData();
if (!vertical_data) {
return SkiaScalarToHarfBuzzPosition(hb_font_data->height_fallback_);
}
--- a/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_font_data.h
+++ b/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_font_data.h
@@ -32,10 +32,7 @@ struct HarfBuzzFontData final : public G
HarfBuzzFontData(const HarfBuzzFontData&) = delete;
HarfBuzzFontData& operator=(const HarfBuzzFontData&) = delete;
- void Trace(Visitor* visitor) const {
- visitor->Trace(vertical_data_);
- visitor->Trace(range_set_);
- }
+ void Trace(Visitor* visitor) const { visitor->Trace(range_set_); }
// The vertical origin and vertical advance functions in HarfBuzzFace require
// the ascent and height metrics as fallback in case no specific vertical
@@ -70,18 +67,18 @@ struct HarfBuzzFontData final : public G
}
}
- OpenTypeVerticalData* VerticalData() {
+ scoped_refptr<OpenTypeVerticalData> VerticalData() {
if (!vertical_data_) {
DCHECK_NE(ascent_fallback_, kInvalidFallbackMetricsValue);
DCHECK_NE(height_fallback_, kInvalidFallbackMetricsValue);
DCHECK_NE(size_per_unit_, kInvalidFallbackMetricsValue);
vertical_data_ =
- MakeGarbageCollected<OpenTypeVerticalData>(font_.refTypeface());
+ OpenTypeVerticalData::CreateUnscaled(font_.refTypeface());
}
vertical_data_->SetScaleAndFallbackMetrics(size_per_unit_, ascent_fallback_,
height_fallback_);
- return vertical_data_.Get();
+ return vertical_data_;
}
const hb::unique_ptr<hb_font_t> unscaled_font_;
@@ -100,7 +97,7 @@ struct HarfBuzzFontData final : public G
SpaceGlyphInOpenTypeTables space_in_gsub_ =
SpaceGlyphInOpenTypeTables::kUnknown;
- Member<OpenTypeVerticalData> vertical_data_;
+ scoped_refptr<OpenTypeVerticalData> vertical_data_;
Member<const UnicodeRangeSet> range_set_;
};