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

Side by Side Diff: Source/core/css/CSSFontSelector.cpp

Issue 18375005: [oilpan] Move CSSFontFace and CSSSegmentedFontFace to the managed heap (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSFontSelector.h ('k') | Source/core/css/CSSSegmentedFontFace.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 PassRefPtr<FontData> CSSFontSelector::getFontData(const FontDescription& fontDes cription, const AtomicString& familyName) 480 PassRefPtr<FontData> CSSFontSelector::getFontData(const FontDescription& fontDes cription, const AtomicString& familyName)
481 { 481 {
482 if (m_fontFaces.isEmpty()) { 482 if (m_fontFaces.isEmpty()) {
483 if (familyName.startsWith("-webkit-")) 483 if (familyName.startsWith("-webkit-"))
484 return fontDataForGenericFamily(m_document, fontDescription, familyN ame); 484 return fontDataForGenericFamily(m_document, fontDescription, familyN ame);
485 if (fontDescription.genericFamily() == FontDescription::StandardFamily & & !fontDescription.isSpecifiedFont()) 485 if (fontDescription.genericFamily() == FontDescription::StandardFamily & & !fontDescription.isSpecifiedFont())
486 return fontDataForGenericFamily(m_document, fontDescription, "-webki t-standard"); 486 return fontDataForGenericFamily(m_document, fontDescription, "-webki t-standard");
487 return 0; 487 return 0;
488 } 488 }
489 489
490 CSSSegmentedFontFace* face = getFontFace(fontDescription, familyName); 490 Handle<CSSSegmentedFontFace> face = getFontFace(fontDescription, familyName) ;
491 // If no face was found, then return 0 and let the OS come up with its best match for the name. 491 // If no face was found, then return 0 and let the OS come up with its best match for the name.
492 if (!face) { 492 if (!face) {
493 // If we were handed a generic family, but there was no match, go ahead and return the correct font based off our 493 // If we were handed a generic family, but there was no match, go ahead and return the correct font based off our
494 // settings. 494 // settings.
495 if (fontDescription.genericFamily() == FontDescription::StandardFamily & & !fontDescription.isSpecifiedFont()) 495 if (fontDescription.genericFamily() == FontDescription::StandardFamily & & !fontDescription.isSpecifiedFont())
496 return fontDataForGenericFamily(m_document, fontDescription, "-webki t-standard"); 496 return fontDataForGenericFamily(m_document, fontDescription, "-webki t-standard");
497 return fontDataForGenericFamily(m_document, fontDescription, familyName) ; 497 return fontDataForGenericFamily(m_document, fontDescription, familyName) ;
498 } 498 }
499 499
500 // We have a face. Ask it for a font data. If it cannot produce one, it will fail, and the OS will take over. 500 // We have a face. Ask it for a font data. If it cannot produce one, it will fail, and the OS will take over.
501 return face->getFontData(fontDescription); 501 return face->getFontData(fontDescription);
502 } 502 }
503 503
504 CSSSegmentedFontFace* CSSFontSelector::getFontFace(const FontDescription& fontDe scription, const AtomicString& family) 504 Result<CSSSegmentedFontFace> CSSFontSelector::getFontFace(const FontDescription& fontDescription, const AtomicString& family)
505 { 505 {
506 Vector<RefPtr<CSSFontFace> >* familyFontFaces = m_fontFaces.get(family); 506 Vector<RefPtr<CSSFontFace> >* familyFontFaces = m_fontFaces.get(family);
507 if (!familyFontFaces || familyFontFaces->isEmpty()) 507 if (!familyFontFaces || familyFontFaces->isEmpty())
508 return 0; 508 return nullptr;
509 509
510 OwnPtr<HashMap<unsigned, RefPtr<CSSSegmentedFontFace> > >& segmentedFontFace Cache = m_fonts.add(family, nullptr).iterator->value; 510 OwnPtr<HashMap<unsigned, Persistent<CSSSegmentedFontFace> > >& segmentedFont FaceCache = m_fonts.add(family, nullptr).iterator->value;
511 if (!segmentedFontFaceCache) 511 if (!segmentedFontFaceCache)
512 segmentedFontFaceCache = adoptPtr(new HashMap<unsigned, RefPtr<CSSSegmen tedFontFace> >); 512 segmentedFontFaceCache = adoptPtr(new HashMap<unsigned, Persistent<CSSSe gmentedFontFace> >);
513 513
514 FontTraitsMask traitsMask = fontDescription.traitsMask(); 514 FontTraitsMask traitsMask = fontDescription.traitsMask();
515 515
516 RefPtr<CSSSegmentedFontFace>& face = segmentedFontFaceCache->add(traitsMask, 0).iterator->value; 516 Handle<CSSSegmentedFontFace> face = segmentedFontFaceCache->add(traitsMask, nullptr).iterator->value;
517 if (!face) { 517 if (!face) {
518 face = CSSSegmentedFontFace::create(this); 518 face = CSSSegmentedFontFace::create(this);
519 segmentedFontFaceCache->set(traitsMask, face);
haraken 2013/07/08 09:20:08 The only suspicious place is here, but I confirmed
519 520
520 // Collect all matching faces and sort them in order of preference. 521 // Collect all matching faces and sort them in order of preference.
521 Vector<CSSFontFace*, 32> candidateFontFaces; 522 Vector<CSSFontFace*, 32> candidateFontFaces;
522 for (int i = familyFontFaces->size() - 1; i >= 0; --i) { 523 for (int i = familyFontFaces->size() - 1; i >= 0; --i) {
523 CSSFontFace* candidate = familyFontFaces->at(i).get(); 524 CSSFontFace* candidate = familyFontFaces->at(i).get();
524 unsigned candidateTraitsMask = candidate->traitsMask(); 525 unsigned candidateTraitsMask = candidate->traitsMask();
525 if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & Fo ntStyleNormalMask)) 526 if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & Fo ntStyleNormalMask))
526 continue; 527 continue;
527 if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask & FontVariantNormalMask)) 528 if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask & FontVariantNormalMask))
528 continue; 529 continue;
(...skipping 18 matching lines...) Expand all
547 candidateFontFaces.append(candidate); 548 candidateFontFaces.append(candidate);
548 } 549 }
549 } 550 }
550 551
551 desiredTraitsMaskForComparison = traitsMask; 552 desiredTraitsMaskForComparison = traitsMask;
552 stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), compar eFontFaces); 553 stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), compar eFontFaces);
553 unsigned numCandidates = candidateFontFaces.size(); 554 unsigned numCandidates = candidateFontFaces.size();
554 for (unsigned i = 0; i < numCandidates; ++i) 555 for (unsigned i = 0; i < numCandidates; ++i)
555 face->appendFontFace(candidateFontFaces[i]); 556 face->appendFontFace(candidateFontFaces[i]);
556 } 557 }
557 return face.get(); 558 return face;
558 } 559 }
559 560
560 void CSSFontSelector::clearDocument() 561 void CSSFontSelector::clearDocument()
561 { 562 {
562 if (!m_document) { 563 if (!m_document) {
563 ASSERT(!m_beginLoadingTimer.isActive()); 564 ASSERT(!m_beginLoadingTimer.isActive());
564 ASSERT(m_fontsToBeginLoading.isEmpty()); 565 ASSERT(m_fontsToBeginLoading.isEmpty());
565 return; 566 return;
566 } 567 }
567 568
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 } 608 }
608 // Ensure that if the request count reaches zero, the frame loader will know about it. 609 // Ensure that if the request count reaches zero, the frame loader will know about it.
609 cachedResourceLoader->loadDone(0); 610 cachedResourceLoader->loadDone(0);
610 // New font loads may be triggered by layout after the document load is comp lete but before we have dispatched 611 // New font loads may be triggered by layout after the document load is comp lete but before we have dispatched
611 // didFinishLoading for the frame. Make sure the delegate is always dispatch ed by checking explicitly. 612 // didFinishLoading for the frame. Make sure the delegate is always dispatch ed by checking explicitly.
612 if (m_document && m_document->frame()) 613 if (m_document && m_document->frame())
613 m_document->frame()->loader()->checkLoadComplete(); 614 m_document->frame()->loader()->checkLoadComplete();
614 } 615 }
615 616
616 } 617 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSFontSelector.h ('k') | Source/core/css/CSSSegmentedFontFace.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698