⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 102071 in webkit


Ignore:
Timestamp:
Dec 5, 2011, 5:03:53 PM (15 years ago)
Author:
Darin Adler
Message:

Change CSSFontSelector to use HashMap<OwnPtr>
https://bugs.webkit.org/show_bug.cgi?id=73781

Reviewed by Dan Bernstein.

  • css/CSSFontSelector.cpp:

(WebCore::CSSFontSelector::~CSSFontSelector): Removed calls to deleteAllValues.
(WebCore::CSSFontSelector::addFontFaceRule): Updated to use OwnPtr instead of raw
pointer for the entry in m_fontFaces and m_locallyInstalledFontFaces.
(WebCore::CSSFontSelector::getFontData): Updated to use OwnPtr instead of raw
pointer for the entry in m_fonts. Also removed an unneeded std:: prefix.

  • css/CSSFontSelector.h: Made m_fontFaces, m_locallyInstalledFontFaces, and m_fonts

be HashMap<OwnPtr>.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102067 r102071  
     12011-12-05  Darin Adler  <darin@apple.com>
     2
     3        Change CSSFontSelector to use HashMap<OwnPtr>
     4        https://bugs.webkit.org/show_bug.cgi?id=73781
     5
     6        Reviewed by Dan Bernstein.
     7
     8        * css/CSSFontSelector.cpp:
     9        (WebCore::CSSFontSelector::~CSSFontSelector): Removed calls to deleteAllValues.
     10        (WebCore::CSSFontSelector::addFontFaceRule): Updated to use OwnPtr instead of raw
     11        pointer for the entry in m_fontFaces and m_locallyInstalledFontFaces.
     12        (WebCore::CSSFontSelector::getFontData): Updated to use OwnPtr instead of raw
     13        pointer for the entry in m_fonts. Also removed an unneeded std:: prefix.
     14
     15        * css/CSSFontSelector.h: Made m_fontFaces, m_locallyInstalledFontFaces, and m_fonts
     16        be HashMap<OwnPtr>.
     17
    1182011-12-05  Adam Klein  <adamk@chromium.org>
    219
  • trunk/Source/WebCore/css/CSSFontSelector.cpp

    r101858 r102071  
    5757#endif
    5858
     59using namespace std;
     60
    5961namespace WebCore {
    6062
     
    7577    clearDocument();
    7678    fontCache()->removeClient(this);
    77     deleteAllValues(m_fontFaces);
    78     deleteAllValues(m_locallyInstalledFontFaces);
    79     deleteAllValues(m_fonts);
    8079}
    8180
     
    321320            continue;
    322321
    323         Vector<RefPtr<CSSFontFace> >* familyFontFaces = m_fontFaces.get(familyName);
     322        OwnPtr<Vector<RefPtr<CSSFontFace> > >& familyFontFaces = m_fontFaces.add(familyName, nullptr).first->second;
    324323        if (!familyFontFaces) {
    325             familyFontFaces = new Vector<RefPtr<CSSFontFace> >;
    326             m_fontFaces.set(familyName, familyFontFaces);
     324            familyFontFaces = adoptPtr(new Vector<RefPtr<CSSFontFace> >);
    327325
    328326            ASSERT(!m_locallyInstalledFontFaces.contains(familyName));
    329             Vector<RefPtr<CSSFontFace> >* familyLocallyInstalledFaces;
    330327
    331328            Vector<unsigned> locallyInstalledFontsTraitsMasks;
    332329            fontCache()->getTraitsInFamily(familyName, locallyInstalledFontsTraitsMasks);
    333             unsigned numLocallyInstalledFaces = locallyInstalledFontsTraitsMasks.size();
    334             if (numLocallyInstalledFaces) {
    335                 familyLocallyInstalledFaces = new Vector<RefPtr<CSSFontFace> >;
    336                 m_locallyInstalledFontFaces.set(familyName, familyLocallyInstalledFaces);
     330            if (unsigned numLocallyInstalledFaces = locallyInstalledFontsTraitsMasks.size()) {
     331                OwnPtr<Vector<RefPtr<CSSFontFace> > > familyLocallyInstalledFaces = adoptPtr(new Vector<RefPtr<CSSFontFace> >);
    337332
    338333                for (unsigned i = 0; i < numLocallyInstalledFaces; ++i) {
     
    342337                    familyLocallyInstalledFaces->append(locallyInstalledFontFace);
    343338                }
     339
     340                m_locallyInstalledFontFaces.set(familyName, familyLocallyInstalledFaces.release());
    344341            }
    345342        }
     
    523520    }
    524521
    525     HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >* segmentedFontFaceCache = m_fonts.get(family);
    526     if (!segmentedFontFaceCache) {
    527         segmentedFontFaceCache = new HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >;
    528         m_fonts.set(family, segmentedFontFaceCache);
    529     }
     522    OwnPtr<HashMap<unsigned, RefPtr<CSSSegmentedFontFace> > >& segmentedFontFaceCache = m_fonts.add(family, nullptr).first->second;
     523    if (!segmentedFontFaceCache)
     524        segmentedFontFaceCache = adoptPtr(new HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >);
    530525
    531526    FontTraitsMask traitsMask = fontDescription.traitsMask();
    532527
    533     RefPtr<CSSSegmentedFontFace> face = segmentedFontFaceCache->get(traitsMask);
    534 
     528    RefPtr<CSSSegmentedFontFace>& face = segmentedFontFaceCache->add(traitsMask, 0).first->second;
    535529    if (!face) {
    536530        face = CSSSegmentedFontFace::create(this);
    537         segmentedFontFaceCache->set(traitsMask, face);
     531
    538532        // Collect all matching faces and sort them in order of preference.
    539533        Vector<CSSFontFace*, 32> candidateFontFaces;
     
    568562
    569563        desiredTraitsMaskForComparison = traitsMask;
    570         std::stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), compareFontFaces);
     564        stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), compareFontFaces);
    571565        unsigned numCandidates = candidateFontFaces.size();
    572566        for (unsigned i = 0; i < numCandidates; ++i)
  • trunk/Source/WebCore/css/CSSFontSelector.h

    r101858 r102071  
    7979
    8080    Document* m_document;
    81     HashMap<String, Vector<RefPtr<CSSFontFace> >*, CaseFoldingHash> m_fontFaces;
    82     HashMap<String, Vector<RefPtr<CSSFontFace> >*, CaseFoldingHash> m_locallyInstalledFontFaces;
    83     HashMap<String, HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >*, CaseFoldingHash> m_fonts;
     81    HashMap<String, OwnPtr<Vector<RefPtr<CSSFontFace> > >, CaseFoldingHash> m_fontFaces;
     82    HashMap<String, OwnPtr<Vector<RefPtr<CSSFontFace> > >, CaseFoldingHash> m_locallyInstalledFontFaces;
     83    HashMap<String, OwnPtr<HashMap<unsigned, RefPtr<CSSSegmentedFontFace> > >, CaseFoldingHash> m_fonts;
    8484    HashSet<FontSelectorClient*> m_clients;
    8585
Note: See TracChangeset for help on using the changeset viewer.