Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: third_party/WebKit/Source/core/css/FontFaceSet.cpp

Issue 1409433003: CSS Font Loading: make FontFaceSet Setlike (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert FastAlloc Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/FontFaceSet.cpp
diff --git a/third_party/WebKit/Source/core/css/FontFaceSet.cpp b/third_party/WebKit/Source/core/css/FontFaceSet.cpp
index c30c35aaaedae60817fd0e0c6404db3bad33c182..f6ef411b9aab5f2111f514ff2531249dfee2bf7b 100644
--- a/third_party/WebKit/Source/core/css/FontFaceSet.cpp
+++ b/third_party/WebKit/Source/core/css/FontFaceSet.cpp
@@ -317,7 +317,7 @@ bool FontFaceSet::remove(FontFace* fontFace, ExceptionState& exceptionState)
return false;
}
-bool FontFaceSet::has(FontFace* fontFace, ExceptionState& exceptionState) const
+bool FontFaceSet::hasForBinding(ScriptState*, FontFace* fontFace, ExceptionState& exceptionState) const
{
if (!inActiveDocumentContext())
return false;
@@ -340,38 +340,7 @@ bool FontFaceSet::isCSSConnectedFontFace(FontFace* fontFace) const
return cssConnectedFontFaceList().contains(fontFace);
}
-void FontFaceSet::forEach(FontFaceSetForEachCallback* callback, const ScriptValue& thisArg) const
-{
- forEachInternal(callback, &thisArg);
-}
-
-void FontFaceSet::forEach(FontFaceSetForEachCallback* callback) const
-{
- forEachInternal(callback, 0);
-}
-
-void FontFaceSet::forEachInternal(FontFaceSetForEachCallback* callback, const ScriptValue* thisArg) const
-{
- if (!inActiveDocumentContext())
- return;
- const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>& cssConnectedFaces = cssConnectedFontFaceList();
- WillBeHeapVector<RefPtrWillBeMember<FontFace>> fontFaces;
- fontFaces.reserveInitialCapacity(cssConnectedFaces.size() + m_nonCSSConnectedFaces.size());
- for (const auto& fontFace : cssConnectedFaces)
- fontFaces.append(fontFace);
- for (const auto& fontFace : m_nonCSSConnectedFaces)
- fontFaces.append(fontFace);
-
- for (size_t i = 0; i < fontFaces.size(); ++i) {
- FontFace* face = fontFaces[i].get();
- if (thisArg)
- callback->handleItem(*thisArg, face, face, const_cast<FontFaceSet*>(this));
- else
- callback->handleItem(face, face, const_cast<FontFaceSet*>(this));
- }
-}
-
-unsigned long FontFaceSet::size() const
+size_t FontFaceSet::size() const
{
if (!inActiveDocumentContext())
return m_nonCSSConnectedFaces.size();
@@ -550,6 +519,31 @@ void FontFaceSet::didLayout(Document& document)
fonts->didLayout();
}
+FontFaceSetIterable::IterationSource* FontFaceSet::startIteration(ScriptState*, ExceptionState&)
+{
+ // Setlike should iterate each item in insertion order, and items should
+ // be keep on up to date. But since blink does not have a way to hook up CSS
+ // modification, take a snapshot here, and make it ordered as follows.
+ WillBeHeapVector<RefPtrWillBeMember<FontFace>> fontFaces;
+ if (inActiveDocumentContext()) {
+ const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>& cssConnectedFaces = cssConnectedFontFaceList();
+ fontFaces.reserveInitialCapacity(cssConnectedFaces.size() + m_nonCSSConnectedFaces.size());
+ for (const auto& fontFace : cssConnectedFaces)
+ fontFaces.append(fontFace);
+ for (const auto& fontFace : m_nonCSSConnectedFaces)
+ fontFaces.append(fontFace);
+ }
+ return new IterationSource(fontFaces);
+}
+
+bool FontFaceSet::IterationSource::next(ScriptState*, RefPtrWillBeMember<FontFace>& key, RefPtrWillBeMember<FontFace>& value, ExceptionState&)
+{
+ if (m_fontFaces.size() <= m_index)
+ return false;
+ key = value = m_fontFaces[m_index++];
+ return true;
+}
+
DEFINE_TRACE(FontFaceSet)
{
#if ENABLE(OILPAN)
« no previous file with comments | « third_party/WebKit/Source/core/css/FontFaceSet.h ('k') | third_party/WebKit/Source/core/css/FontFaceSet.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698