summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h')
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h51
1 files changed, 45 insertions, 6 deletions
diff --git a/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h b/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h
index 75933f47f7c..84da73e58f2 100644
--- a/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h
+++ b/chromium/third_party/blink/renderer/core/css/css_segmented_font_face.h
@@ -26,6 +26,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_SEGMENTED_FONT_FACE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_SEGMENTED_FONT_FACE_H_
+#include "base/callback.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/fonts/segmented_font_data.h"
@@ -42,6 +43,47 @@ class FontDescription;
class FontFace;
class SegmentedFontData;
+// CSSSegmentedFontFace stores two FontFace list-sets, CSS-connected and
+// non-CSS-connected. This class combines the two such that they can be
+// conveniently operated as one.
+// Note however, |Insert| has to be instructed which sub-list to insert it to.
+// Iterating over the combined set, behaves as if all non-CSS-connected
+// FontFaces were stored after the CSS-connected ones.
+class FontFaceList : public GarbageCollected<FontFaceList> {
+ using FontFaceListPart = HeapListHashSet<Member<FontFace>>;
+
+ public:
+ bool IsEmpty() const;
+ void Insert(FontFace* font_face, bool css_connected);
+ bool Erase(FontFace* font_face);
+
+ // Iterate over CSS-connected FontFaces first, and then non-CSS-connected
+ // ones.
+ // Modifying the collection is not allowed during iteration.
+ bool ForEachUntilTrue(
+ const base::RepeatingCallback<bool(Member<FontFace>)>& callback) const;
+ bool ForEachUntilFalse(
+ const base::RepeatingCallback<bool(Member<FontFace>)>& callback) const;
+ void ForEach(
+ const base::RepeatingCallback<void(Member<FontFace>)>& callback) const;
+
+ // Iterate (in reverse order) over non-CSS-connected FontFaces first, and
+ // then CSS-connected ones.
+ // Modifying the collection is not allowed during iteration.
+ bool ForEachReverseUntilTrue(
+ const base::RepeatingCallback<bool(Member<FontFace>)>& callback) const;
+ bool ForEachReverseUntilFalse(
+ const base::RepeatingCallback<bool(Member<FontFace>)>& callback) const;
+ void ForEachReverse(
+ const base::RepeatingCallback<void(Member<FontFace>)>& callback) const;
+
+ void Trace(Visitor* visitor);
+
+ private:
+ FontFaceListPart css_connected_face_;
+ FontFaceListPart non_css_connected_face_;
+};
+
class CSSSegmentedFontFace final
: public GarbageCollected<CSSSegmentedFontFace> {
public:
@@ -58,12 +100,12 @@ class CSSSegmentedFontFace final
void AddFontFace(FontFace*, bool css_connected);
void RemoveFontFace(FontFace*);
- bool IsEmpty() const { return font_faces_.IsEmpty(); }
+ bool IsEmpty() const { return font_faces_->IsEmpty(); }
scoped_refptr<FontData> GetFontData(const FontDescription&);
bool CheckFont(const String&) const;
- void Match(const String&, HeapVector<Member<FontFace>>&) const;
+ void Match(const String&, HeapVector<Member<FontFace>>*) const;
void WillUseFontData(const FontDescription&, const String& text);
void WillUseRange(const FontDescription&, const blink::FontDataForRangeSet&);
size_t ApproximateCharacterCount() const {
@@ -76,16 +118,13 @@ class CSSSegmentedFontFace final
void PruneTable();
bool IsValid() const;
- using FontFaceList = HeapListHashSet<Member<FontFace>>;
-
FontSelectionCapabilities font_selection_capabilities_;
WTF::LruCache<FontCacheKey, scoped_refptr<SegmentedFontData>>
font_data_table_;
// All non-CSS-connected FontFaces are stored after the CSS-connected ones.
- FontFaceList font_faces_;
- FontFaceList::iterator first_non_css_connected_face_;
+ Member<FontFaceList> font_faces_;
// Approximate number of characters styled with this CSSSegmentedFontFace.
// LayoutText::StyleDidChange() increments this on the first