| Index: Source/core/css/FontFaceSet.cpp
|
| diff --git a/Source/core/css/FontFaceSet.cpp b/Source/core/css/FontFaceSet.cpp
|
| index b30a902ca1abce005bbb7dd3c4725ccf80ec1641..75aa658b8d00dba83ee2ecc0ee5d3d837928bfcd 100644
|
| --- a/Source/core/css/FontFaceSet.cpp
|
| +++ b/Source/core/css/FontFaceSet.cpp
|
| @@ -29,6 +29,7 @@
|
| #include "bindings/core/v8/Dictionary.h"
|
| #include "bindings/core/v8/ScriptPromiseResolver.h"
|
| #include "bindings/core/v8/ScriptState.h"
|
| +#include "bindings/core/v8/V8FontFace.h"
|
| #include "core/css/CSSFontSelector.h"
|
| #include "core/css/CSSSegmentedFontFace.h"
|
| #include "core/css/FontFaceCache.h"
|
| @@ -387,6 +388,21 @@ void FontFaceSet::forEachInternal(PassOwnPtrWillBeRawPtr<FontFaceSetForEachCallb
|
| }
|
| }
|
|
|
| +Iterator* FontFaceSet::keys()
|
| +{
|
| + return new FontFaceSetIterator(this, FontFaceSetIterator::Keys);
|
| +}
|
| +
|
| +Iterator* FontFaceSet::values()
|
| +{
|
| + return new FontFaceSetIterator(this, FontFaceSetIterator::Values);
|
| +}
|
| +
|
| +Iterator* FontFaceSet::entries()
|
| +{
|
| + return new FontFaceSetIterator(this, FontFaceSetIterator::Entries);
|
| +}
|
| +
|
| unsigned long FontFaceSet::size() const
|
| {
|
| if (!inActiveDocumentContext())
|
| @@ -394,6 +410,27 @@ unsigned long FontFaceSet::size() const
|
| return cssConnectedFontFaceList().size() + m_nonCSSConnectedFaces.size();
|
| }
|
|
|
| +FontFace* FontFaceSet::fontFaceAt(size_t index) const
|
| +{
|
| + if (inActiveDocumentContext()) {
|
| + const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace> >& cssConnectedFaces = cssConnectedFontFaceList();
|
| + if (index < cssConnectedFaces.size()) {
|
| + WillBeHeapListHashSet<RefPtrWillBeMember<FontFace> >::const_iterator it = cssConnectedFaces.begin();
|
| + for (size_t i = 0; i < index; i++)
|
| + ++it;
|
| + return it->get();
|
| + }
|
| + index -= cssConnectedFaces.size();
|
| + }
|
| + if (index < m_nonCSSConnectedFaces.size()) {
|
| + WillBeHeapListHashSet<RefPtrWillBeMember<FontFace> >::const_iterator it = m_nonCSSConnectedFaces.begin();
|
| + for (size_t i = 0; i < index; i++)
|
| + ++it;
|
| + return it->get();
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| void FontFaceSet::fireDoneEventIfPossible()
|
| {
|
| if (m_shouldFireLoadingEvent)
|
| @@ -592,4 +629,22 @@ void FontFaceSet::trace(Visitor* visitor)
|
| }
|
| #endif
|
|
|
| +ScriptValue FontFaceSet::FontFaceSetIterator::next(ScriptState* scriptState, ExceptionState&)
|
| +{
|
| + // FIXME: It takes O(n^2) to iterate all font faces. A better solution
|
| + // is needed.
|
| + FontFace* fontFace = m_fontFaceSet->fontFaceAt(m_index);
|
| + if (!fontFace)
|
| + return ScriptValue(scriptState, v8DoneIteratorResult(scriptState->isolate()));
|
| + m_index++;
|
| + if (m_kind == FontFaceSetIterator::Entries) {
|
| + Vector<ScriptValue> entry;
|
| + ScriptValue value = ScriptValue(scriptState, toV8(fontFace, scriptState->context()->Global(), scriptState->isolate()));
|
| + entry.append(value);
|
| + entry.append(value);
|
| + return ScriptValue(scriptState, v8IteratorResult(scriptState, entry));
|
| + }
|
| + return ScriptValue(scriptState, v8IteratorResult(scriptState, fontFace));
|
| +}
|
| +
|
| } // namespace blink
|
|
|