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

Side by Side Diff: sky/engine/core/dom/StyleEngine.cpp

Issue 791633010: StyleSheetContents doesn't need a set of clients. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 if (scope == m_document) 273 if (scope == m_document)
274 return; 274 return;
275 m_dirtyTreeScopes.add(&scope); 275 m_dirtyTreeScopes.add(&scope);
276 } 276 }
277 277
278 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t) 278 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t)
279 { 279 {
280 RefPtr<CSSStyleSheet> styleSheet; 280 RefPtr<CSSStyleSheet> styleSheet;
281 AtomicString textContent(text); 281 AtomicString textContent(text);
282 282
283 HashMap<AtomicString, RawPtr<StyleSheetContents> >::AddResult result = m_tex tToSheetCache.add(textContent, nullptr); 283 HashMap<AtomicString, StyleSheetContents*>::AddResult result = m_textToSheet Cache.add(textContent, nullptr);
284 if (result.isNewEntry || !result.storedValue->value) { 284 if (result.isNewEntry || !result.storedValue->value) {
285 styleSheet = CSSStyleSheet::create(e, KURL()); 285 styleSheet = CSSStyleSheet::create(e, KURL());
286 styleSheet->contents()->parseString(text); 286 styleSheet->contents()->parseString(text);
287 if (result.isNewEntry) { 287 if (result.isNewEntry) {
288 result.storedValue->value = styleSheet->contents(); 288 result.storedValue->value = styleSheet->contents();
289 m_sheetToTextCache.add(styleSheet->contents(), textContent); 289 m_sheetToTextCache.add(styleSheet->contents(), textContent);
290 } 290 }
291 } else { 291 } else {
292 StyleSheetContents* contents = result.storedValue->value; 292 StyleSheetContents* contents = result.storedValue->value;
293 ASSERT(contents); 293 ASSERT(contents);
294 styleSheet = CSSStyleSheet::create(contents, e); 294 styleSheet = CSSStyleSheet::create(contents, e);
295 } 295 }
296 296
297 ASSERT(styleSheet); 297 ASSERT(styleSheet);
298 return styleSheet; 298 return styleSheet;
299 } 299 }
300 300
301 void StyleEngine::removeSheet(StyleSheetContents* contents) 301 void StyleEngine::removeSheet(StyleSheetContents* contents)
302 { 302 {
303 HashMap<RawPtr<StyleSheetContents>, AtomicString>::iterator it = m_sheetToTe xtCache.find(contents); 303 HashMap<StyleSheetContents*, AtomicString>::iterator it = m_sheetToTextCache .find(contents);
304 if (it == m_sheetToTextCache.end()) 304 if (it == m_sheetToTextCache.end())
305 return; 305 return;
306 306
307 m_textToSheetCache.remove(it->value); 307 m_textToSheetCache.remove(it->value);
308 m_sheetToTextCache.remove(contents); 308 m_sheetToTextCache.remove(contents);
309 } 309 }
310 310
311 // TODO(esprehn): This walks the entire document to collect features, instead 311 // TODO(esprehn): This walks the entire document to collect features, instead
312 // we should store features per scope and get rid of the global set. 312 // we should store features per scope and get rid of the global set.
313 static void collectFeatures(TreeScope& scope, RuleFeatureSet& features, HashSet< const StyleSheetContents*> visitedSharedStyleSheetContents) 313 static void collectFeatures(TreeScope& scope, RuleFeatureSet& features, HashSet< const StyleSheetContents*> visitedSharedStyleSheetContents)
(...skipping 12 matching lines...) Expand all
326 } 326 }
327 327
328 void StyleEngine::fontsNeedUpdate(CSSFontSelector*) 328 void StyleEngine::fontsNeedUpdate(CSSFontSelector*)
329 { 329 {
330 if (m_resolver) 330 if (m_resolver)
331 m_resolver->invalidateMatchedPropertiesCache(); 331 m_resolver->invalidateMatchedPropertiesCache();
332 m_document->setNeedsStyleRecalc(SubtreeStyleChange); 332 m_document->setNeedsStyleRecalc(SubtreeStyleChange);
333 } 333 }
334 334
335 } 335 }
OLDNEW
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698