Source/WebCore/ChangeLog

 12012-06-21 Balazs Kelemen <kbalazs@webkit.org>
 2
 3 FontFallbackList should release cached font data when the FontCache is invalidated
 4 https://bugs.webkit.org/show_bug.cgi?id=89658
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Existing tests coverst this as long as the driver purge the
 9 font cache regularly. This is what the Qt and EFL DRT's do.
 10
 11 Currently there is no guarantee that cached FontData stored in
 12 FontFallBackList's will be invalidated after fontCache()->invalidate().
 13 If we are lucky it can be invalidated in style updates via Font::update
 14 but it is not reliable. Fix this by making FontFallBackList a client of
 15 the FontCache so it will observe invalidation just like FontSelector does.
 16 I believe the only reason it did not show up so far is that FontCache::invalidate
 17 is not well tested and also rarely used by browsers. This bug has shown
 18 on Qt as a failing assertion in FontFallBackList::fontDataAt:
 19 ASSERTION FAILED: fontCache()->generation() == m_generation
 20
 21 * Target.pri:
 22 * platform/graphics/FontCache.cpp:
 23 (WebCore):
 24 (WebCore::FontCache::addClient):
 25 (WebCore::FontCache::removeClient):
 26 (WebCore::FontCache::invalidate):
 27 * platform/graphics/FontCache.h:
 28 (WebCore):
 29 * platform/graphics/FontCacheClient.h:
 30 (FontCacheClient):
 31 (WebCore::FontCacheClient::fontCacheInvalidated):
 32 (WebCore::FontCacheClient::~FontCacheClient):
 33 * platform/graphics/FontFallbackList.cpp:
 34 (WebCore::FontFallbackList::FontFallbackList):
 35 (WebCore):
 36 (WebCore::FontFallbackList::~FontFallbackList):
 37 (WebCore::FontFallbackList::invalidate):
 38 (WebCore::FontFallbackList::invalidateFontData):
 39 (WebCore::FontFallbackList::fontCacheInvalidated):
 40 * platform/graphics/FontFallbackList.h:
 41 (FontFallbackList):
 42 * platform/graphics/FontSelector.h:
 43
1442012-06-19 Mike West <mkwst@chromium.org>
245
346 Add a scheme registry for bypassing Content Security Policy.

Source/WebCore/Target.pri

@@SOURCES += \
10921092 platform/FileStream.cpp \
10931093 platform/FileSystem.cpp \
10941094 platform/HistogramSupport.cpp \
 1095 platform/graphics/FontCacheClient.cpp \
10951096 platform/graphics/FontDescription.cpp \
10961097 platform/graphics/FontFallbackList.cpp \
10971098 platform/graphics/FontFamily.cpp \

Source/WebCore/platform/graphics/FontCache.cpp

@@const FontData* FontCache::getFontData(const Font& font, int& familyIndex, FontS
444444 return result;
445445}
446446
447 static HashSet<FontSelector*>* gClients;
 447static HashSet<FontCacheClient*>* gClients;
448448
449 void FontCache::addClient(FontSelector* client)
 449void FontCache::addClient(FontCacheClient* client)
450450{
451451 if (!gClients)
452  gClients = new HashSet<FontSelector*>;
 452 gClients = new HashSet<FontCacheClient*>;
453453
454454 ASSERT(!gClients->contains(client));
455455 gClients->add(client);
456456}
457457
458 void FontCache::removeClient(FontSelector* client)
 458void FontCache::removeClient(FontCacheClient* client)
459459{
460460 ASSERT(gClients);
461461 ASSERT(gClients->contains(client));

@@void FontCache::invalidate()
485485
486486 gGeneration++;
487487
488  Vector<RefPtr<FontSelector> > clients;
 488 Vector<RefPtr<FontCacheClient> > clients;
489489 size_t numClients = gClients->size();
490490 clients.reserveInitialCapacity(numClients);
491  HashSet<FontSelector*>::iterator end = gClients->end();
492  for (HashSet<FontSelector*>::iterator it = gClients->begin(); it != end; ++it)
 491 HashSet<FontCacheClient*>::iterator end = gClients->end();
 492 for (HashSet<FontCacheClient*>::iterator it = gClients->begin(); it != end; ++it)
493493 clients.append(*it);
494494
495495 ASSERT(numClients == clients.size());

Source/WebCore/platform/graphics/FontCache.h

@@class Font;
4848class FontPlatformData;
4949class FontData;
5050class FontDescription;
 51class FontCacheClient;
5152class FontSelector;
5253class SimpleFontData;
5354

@@public:
8889 SimpleFontData* getLastResortFallbackFont(const FontDescription&, ShouldRetain = Retain);
8990 SimpleFontData* getNonRetainedLastResortFallbackFont(const FontDescription&);
9091
91  void addClient(FontSelector*);
92  void removeClient(FontSelector*);
 92 void addClient(FontCacheClient*);
 93 void removeClient(FontCacheClient*);
9394
9495 unsigned short generation();
9596 void invalidate();

Source/WebCore/platform/graphics/FontCacheClient.h

 1/*
 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
 3 * Copyright (C) 2012 University of Szeged. All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 25 */
 26
 27#ifndef FontCacheClient_h
 28#define FontCacheClient_h
 29
 30#include <wtf/RefCounted.h>
 31
 32namespace WebCore {
 33
 34class FontCacheClient : public RefCounted<FontCacheClient> {
 35public:
 36 virtual void fontCacheInvalidated() = 0;
 37 virtual ~FontCacheClient() { }
 38};
 39
 40}
 41
 42#endif

Source/WebCore/platform/graphics/FontFallbackList.cpp

@@FontFallbackList::FontFallbackList()
4545 , m_pitch(UnknownPitch)
4646 , m_loadingCustomFonts(false)
4747{
 48 fontCache()->addClient(this);
 49}
 50
 51FontFallbackList::~FontFallbackList()
 52{
 53 releaseFontData();
 54 fontCache()->removeClient(this);
4855}
4956
5057void FontFallbackList::invalidate(PassRefPtr<FontSelector> fontSelector)
5158{
 59 invalidateFontData();
 60 m_fontSelector = fontSelector;
 61 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0;
 62}
 63
 64void FontFallbackList::invalidateFontData()
 65{
5266 releaseFontData();
5367 m_fontList.clear();
5468 m_pageZero = 0;
5569 m_pages.clear();
5670 m_cachedPrimarySimpleFontData = 0;
57  m_familyIndex = 0;
 71 m_familyIndex = 0;
5872 m_pitch = UnknownPitch;
5973 m_loadingCustomFonts = false;
60  m_fontSelector = fontSelector;
61  m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0;
6274 m_generation = fontCache()->generation();
6375}
6476
 77void FontFallbackList::fontCacheInvalidated()
 78{
 79 invalidateFontData();
 80}
 81
6582void FontFallbackList::releaseFontData()
6683{
6784 unsigned numFonts = m_fontList.size();

Source/WebCore/platform/graphics/FontFallbackList.h

@@class FontSelector;
3838
3939const int cAllFamiliesScanned = -1;
4040
41 class FontFallbackList : public RefCounted<FontFallbackList> {
 41class FontFallbackList : public FontCacheClient {
4242public:
4343 static PassRefPtr<FontFallbackList> create() { return adoptRef(new FontFallbackList()); }
4444
45  ~FontFallbackList() { releaseFontData(); }
 45 virtual ~FontFallbackList();
4646 void invalidate(PassRefPtr<FontSelector>);
4747
4848 bool isFixedPitch(const Font* f) const { if (m_pitch == UnknownPitch) determinePitch(f); return m_pitch == FixedPitch; };

@@private:
8282
8383 void setPlatformFont(const FontPlatformData&);
8484
 85 virtual void fontCacheInvalidated();
 86 void invalidateFontData();
8587 void releaseFontData();
8688
8789 mutable Vector<pair<const FontData*, bool>, 1> m_fontList;

Source/WebCore/platform/graphics/FontSelector.h

2626#ifndef FontSelector_h
2727#define FontSelector_h
2828
 29#include "FontCacheClient.h"
2930#include <wtf/Forward.h>
3031#include <wtf/RefCounted.h>
3132

@@class FontData;
3536class FontDescription;
3637class FontSelectorClient;
3738
38 class FontSelector : public RefCounted<FontSelector> {
 39class FontSelector : public FontCacheClient {
3940public:
4041 virtual ~FontSelector() { }
4142 virtual FontData* getFontData(const FontDescription&, const AtomicString& familyName) = 0;

LayoutTests/ChangeLog

 12012-06-21 Balazs Kelemen <kbalazs@webkit.org>
 2
 3 FontFallbackList should release cached font data when the FontCache is invalidated
 4 https://bugs.webkit.org/show_bug.cgi?id=89658
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Unskip the test that triggered this bug.
 9 * platform/qt/Skipped:
 10
1112012-06-19 MORITA Hajime <morrita@google.com>
212
313 Unreviewed expectation update.

LayoutTests/platform/qt/Skipped

@@svg/zoom/text/zoom-coords-viewattr-01-b.svg
13761376# https://bugs.webkit.org/show_bug.cgi?id=86971
13771377svg/custom/non-scaling-stroke.svg
13781378
1379 # [Qt] fontCache related assertion revealed by r105143
1380 # https://bugs.webkit.org/show_bug.cgi?id=76534
1381 svg/carto.net/combobox.svg
1382 
13831379# [Qt] svg/custom/getBBox-path.svg fails
13841380# https://bugs.webkit.org/show_bug.cgi?id=71766
13851381svg/custom/getBBox-path.svg