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

Side by Side Diff: Source/core/dom/StyleEngine.cpp

Issue 82583005: Use removeFontFace to avoid resetting fontSelector. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing Created 6 years, 10 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/dom/StyleEngine.h ('k') | Source/core/dom/TreeScopeStyleSheetCollection.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 14 matching lines...) Expand all
25 * Boston, MA 02110-1301, USA. 25 * Boston, MA 02110-1301, USA.
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "core/dom/StyleEngine.h" 29 #include "core/dom/StyleEngine.h"
30 30
31 #include "HTMLNames.h" 31 #include "HTMLNames.h"
32 #include "SVGNames.h" 32 #include "SVGNames.h"
33 #include "core/css/CSSFontSelector.h" 33 #include "core/css/CSSFontSelector.h"
34 #include "core/css/CSSStyleSheet.h" 34 #include "core/css/CSSStyleSheet.h"
35 #include "core/css/FontFaceCache.h"
35 #include "core/css/StyleInvalidationAnalysis.h" 36 #include "core/css/StyleInvalidationAnalysis.h"
36 #include "core/css/StyleSheetContents.h" 37 #include "core/css/StyleSheetContents.h"
37 #include "core/dom/DocumentStyleSheetCollector.h" 38 #include "core/dom/DocumentStyleSheetCollector.h"
38 #include "core/dom/Element.h" 39 #include "core/dom/Element.h"
39 #include "core/dom/ProcessingInstruction.h" 40 #include "core/dom/ProcessingInstruction.h"
40 #include "core/dom/ShadowTreeStyleSheetCollection.h" 41 #include "core/dom/ShadowTreeStyleSheetCollection.h"
41 #include "core/dom/shadow/ShadowRoot.h" 42 #include "core/dom/shadow/ShadowRoot.h"
42 #include "core/html/HTMLIFrameElement.h" 43 #include "core/html/HTMLIFrameElement.h"
43 #include "core/html/HTMLImport.h" 44 #include "core/html/HTMLImport.h"
44 #include "core/html/HTMLLinkElement.h" 45 #include "core/html/HTMLLinkElement.h"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 m_didCalculateResolver = true; 513 m_didCalculateResolver = true;
513 if (m_document.didLayoutWithPendingStylesheets() && !hasPendingSheets()) 514 if (m_document.didLayoutWithPendingStylesheets() && !hasPendingSheets())
514 change.setNeedsRepaint(); 515 change.setNeedsRepaint();
515 516
516 if (updateActiveStyleSheets(mode)) 517 if (updateActiveStyleSheets(mode))
517 change.setNeedsStyleRecalc(); 518 change.setNeedsStyleRecalc();
518 519
519 return change; 520 return change;
520 } 521 }
521 522
522 void StyleEngine::resetFontSelector() 523 void StyleEngine::clearFontCache()
524 {
525 // We should not recreate FontSelector. Instead, clear fontFaceCache.
526 if (m_fontSelector)
527 m_fontSelector->fontFaceCache()->clear();
528 if (m_resolver)
529 m_resolver->invalidateMatchedPropertiesCache();
530 }
531
532 void StyleEngine::updateGenericFontFamilySettings()
523 { 533 {
524 if (!m_fontSelector) 534 if (!m_fontSelector)
525 return; 535 return;
526 536
527 m_fontSelector->clearDocument(); 537 m_fontSelector->updateGenericFontFamilySettings(m_document);
528 if (m_resolver) { 538 if (m_resolver)
529 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get());
530 m_resolver->invalidateMatchedPropertiesCache(); 539 m_resolver->invalidateMatchedPropertiesCache();
531 } 540 }
532 541
533 // If the document has been already detached, we don't need to recreate 542 void StyleEngine::removeFontFaceRules(const Vector<const StyleRuleFontFace*>& fo ntFaceRules)
534 // CSSFontSelector. 543 {
535 if (m_document.isActive()) { 544 if (!m_fontSelector)
536 m_fontSelector = CSSFontSelector::create(&m_document); 545 return;
537 if (m_resolver) 546
538 m_fontSelector->registerForInvalidationCallbacks(m_resolver.get()); 547 FontFaceCache* cache = m_fontSelector->fontFaceCache();
539 } else { 548 for (unsigned i = 0; i < fontFaceRules.size(); ++i)
540 m_fontSelector = 0; 549 cache->remove(fontFaceRules[i]);
541 } 550 if (m_resolver)
551 m_resolver->invalidateMatchedPropertiesCache();
542 } 552 }
543 553
544 void StyleEngine::markTreeScopeDirty(TreeScope& scope) 554 void StyleEngine::markTreeScopeDirty(TreeScope& scope)
545 { 555 {
546 if (scope == m_document) { 556 if (scope == m_document) {
547 markDocumentDirty(); 557 markDocumentDirty();
548 return; 558 return;
549 } 559 }
550 560
551 m_dirtyTreeScopes.add(&scope); 561 m_dirtyTreeScopes.add(&scope);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 { 610 {
601 HashMap<StyleSheetContents*, AtomicString>::iterator it = sheetToTextCache() .find(contents); 611 HashMap<StyleSheetContents*, AtomicString>::iterator it = sheetToTextCache() .find(contents);
602 if (it == sheetToTextCache().end()) 612 if (it == sheetToTextCache().end())
603 return; 613 return;
604 614
605 textToSheetCache().remove(it->value); 615 textToSheetCache().remove(it->value);
606 sheetToTextCache().remove(contents); 616 sheetToTextCache().remove(contents);
607 } 617 }
608 618
609 } 619 }
OLDNEW
« no previous file with comments | « Source/core/dom/StyleEngine.h ('k') | Source/core/dom/TreeScopeStyleSheetCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698