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

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

Issue 196133034: Move inline stylesheet cache decision making from StyleSheetContents to StyleEngine (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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/StyleSheetContents.cpp ('k') | no next file » | 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 m_dirtyTreeScopes.add(&scope); 555 m_dirtyTreeScopes.add(&scope);
556 } 556 }
557 557
558 void StyleEngine::markDocumentDirty() 558 void StyleEngine::markDocumentDirty()
559 { 559 {
560 m_documentScopeDirty = true; 560 m_documentScopeDirty = true;
561 if (!HTMLImport::isMaster(&m_document)) 561 if (!HTMLImport::isMaster(&m_document))
562 m_document.import()->master()->styleEngine()->markDocumentDirty(); 562 m_document.import()->master()->styleEngine()->markDocumentDirty();
563 } 563 }
564 564
565 static bool isCacheableForInlineStyle(const StyleSheetContents& contents)
esprehn 2014/03/19 22:32:14 inline style actually means the style attribute, I
adamk 2014/03/19 22:40:17 You're right, when I re-read this name it sounded
566 {
567 // FIXME: Support copying import rules.
568 if (!contents.importRules().isEmpty())
569 return false;
570 // Until import rules are supported in cached sheets it's not possible for l oading to fail.
571 ASSERT(!contents.didLoadErrorOccur());
572 // It is not the original sheet anymore.
573 if (contents.isMutable())
574 return false;
575 if (!contents.hasSyntacticallyValidCSSHeader())
576 return false;
577 return true;
578 }
579
565 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& text, TextPosition startPosition, bool createdByParser) 580 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& text, TextPosition startPosition, bool createdByParser)
566 { 581 {
567 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet; 582 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet;
568 583
569 e->document().styleEngine()->addPendingSheet(); 584 e->document().styleEngine()->addPendingSheet();
570 585
571 if (!e->document().inQuirksMode()) { 586 if (!e->document().inQuirksMode()) {
572 AtomicString textContent(text); 587 AtomicString textContent(text);
573 588
574 HashMap<AtomicString, StyleSheetContents*>::AddResult result = m_textToS heetCache.add(textContent, 0); 589 HashMap<AtomicString, StyleSheetContents*>::AddResult result = m_textToS heetCache.add(textContent, 0);
575 if (result.isNewEntry || !result.storedValue->value) { 590 if (result.isNewEntry || !result.storedValue->value) {
576 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created ByParser); 591 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created ByParser);
577 if (result.isNewEntry && styleSheet->contents()->maybeCacheable()) { 592 if (result.isNewEntry && isCacheableForInlineStyle(*styleSheet->cont ents())) {
578 result.storedValue->value = styleSheet->contents(); 593 result.storedValue->value = styleSheet->contents();
579 m_sheetToTextCache.add(styleSheet->contents(), textContent); 594 m_sheetToTextCache.add(styleSheet->contents(), textContent);
580 } 595 }
581 } else { 596 } else {
582 ASSERT(result.storedValue->value->maybeCacheable()); 597 StyleSheetContents* contents = result.storedValue->value;
583 ASSERT(result.storedValue->value->singleOwnerDocument() == e->docume nt()); 598 ASSERT(contents);
584 styleSheet = CSSStyleSheet::createInline(result.storedValue->value, e, startPosition); 599 ASSERT(isCacheableForInlineStyle(*contents));
600 ASSERT(contents->singleOwnerDocument() == e->document());
601 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition) ;
585 } 602 }
586 } else { 603 } else {
587 // FIXME: currently we don't cache StyleSheetContents inQuirksMode. 604 // FIXME: currently we don't cache StyleSheetContents inQuirksMode.
588 styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByPa rser); 605 styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByPa rser);
589 } 606 }
590 607
591 ASSERT(styleSheet); 608 ASSERT(styleSheet);
592 styleSheet->setTitle(e->title()); 609 styleSheet->setTitle(e->title());
593 return styleSheet; 610 return styleSheet;
594 } 611 }
(...skipping 18 matching lines...) Expand all
613 630
614 void StyleEngine::trace(Visitor* visitor) 631 void StyleEngine::trace(Visitor* visitor)
615 { 632 {
616 visitor->trace(m_injectedAuthorStyleSheets); 633 visitor->trace(m_injectedAuthorStyleSheets);
617 visitor->trace(m_authorStyleSheets); 634 visitor->trace(m_authorStyleSheets);
618 visitor->trace(m_documentStyleSheetCollection); 635 visitor->trace(m_documentStyleSheetCollection);
619 visitor->trace(m_styleSheetCollectionMap); 636 visitor->trace(m_styleSheetCollectionMap);
620 } 637 }
621 638
622 } 639 }
OLDNEW
« no previous file with comments | « Source/core/css/StyleSheetContents.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698