Chromium Code Reviews| 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..dd20d9cdf0dd496982ecdbcbde298454d2d3bb15 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*, const PassRefPtrWillBeRawPtr<FontFace>& fontFace, ExceptionState& exceptionState) const |
| { |
| if (!inActiveDocumentContext()) |
| return false; |
| @@ -325,7 +325,7 @@ bool FontFaceSet::has(FontFace* fontFace, ExceptionState& exceptionState) const |
| exceptionState.throwTypeError("The argument is not a FontFace."); |
| return false; |
| } |
| - return m_nonCSSConnectedFaces.contains(fontFace) || isCSSConnectedFontFace(fontFace); |
| + return m_nonCSSConnectedFaces.contains(fontFace.get()) || isCSSConnectedFontFace(fontFace.get()); |
| } |
| const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>& FontFaceSet::cssConnectedFontFaceList() const |
| @@ -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* scriptState, RefPtrWillBeMember<FontFace>& key, RefPtrWillBeMember<FontFace>& value, ExceptionState& exceptionState) |
|
Kunihiko Sakamoto
2015/10/16 09:50:07
nit: omit unused parameter names
Takashi Toyoshima
2015/10/16 10:07:03
Done.
|
| +{ |
| + if (m_fontFaces.size() <= m_index) |
| + return false; |
| + key = value = m_fontFaces[m_index++]; |
| + return true; |
| +} |
| + |
| DEFINE_TRACE(FontFaceSet) |
| { |
| #if ENABLE(OILPAN) |