| OLD | NEW |
| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 m_dirtyTreeScopes.add(&scope); | 369 m_dirtyTreeScopes.add(&scope); |
| 370 } | 370 } |
| 371 | 371 |
| 372 void StyleEngine::markDocumentDirty() | 372 void StyleEngine::markDocumentDirty() |
| 373 { | 373 { |
| 374 m_documentScopeDirty = true; | 374 m_documentScopeDirty = true; |
| 375 if (document().importLoader()) | 375 if (document().importLoader()) |
| 376 document().importsController()->master()->styleEngine()->markDocumentDir
ty(); | 376 document().importsController()->master()->styleEngine()->markDocumentDir
ty(); |
| 377 } | 377 } |
| 378 | 378 |
| 379 static bool isCacheableForStyleElement(const StyleSheetContents& contents) | |
| 380 { | |
| 381 if (!contents.hasSyntacticallyValidCSSHeader()) | |
| 382 return false; | |
| 383 return true; | |
| 384 } | |
| 385 | |
| 386 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex
t) | 379 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex
t) |
| 387 { | 380 { |
| 388 RefPtr<CSSStyleSheet> styleSheet; | 381 RefPtr<CSSStyleSheet> styleSheet; |
| 389 AtomicString textContent(text); | 382 AtomicString textContent(text); |
| 390 | 383 |
| 391 HashMap<AtomicString, RawPtr<StyleSheetContents> >::AddResult result = m_tex
tToSheetCache.add(textContent, nullptr); | 384 HashMap<AtomicString, RawPtr<StyleSheetContents> >::AddResult result = m_tex
tToSheetCache.add(textContent, nullptr); |
| 392 if (result.isNewEntry || !result.storedValue->value) { | 385 if (result.isNewEntry || !result.storedValue->value) { |
| 393 styleSheet = CSSStyleSheet::createInline(e, KURL()); | 386 styleSheet = CSSStyleSheet::createInline(e, KURL()); |
| 394 styleSheet->contents()->parseString(text); | 387 styleSheet->contents()->parseString(text); |
| 395 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->content
s())) { | 388 if (result.isNewEntry) { |
| 396 result.storedValue->value = styleSheet->contents(); | 389 result.storedValue->value = styleSheet->contents(); |
| 397 m_sheetToTextCache.add(styleSheet->contents(), textContent); | 390 m_sheetToTextCache.add(styleSheet->contents(), textContent); |
| 398 } | 391 } |
| 399 } else { | 392 } else { |
| 400 StyleSheetContents* contents = result.storedValue->value; | 393 StyleSheetContents* contents = result.storedValue->value; |
| 401 ASSERT(contents); | 394 ASSERT(contents); |
| 402 ASSERT(isCacheableForStyleElement(*contents)); | |
| 403 ASSERT(contents->singleOwnerDocument() == e->document()); | 395 ASSERT(contents->singleOwnerDocument() == e->document()); |
| 404 styleSheet = CSSStyleSheet::createInline(contents, e); | 396 styleSheet = CSSStyleSheet::createInline(contents, e); |
| 405 } | 397 } |
| 406 | 398 |
| 407 ASSERT(styleSheet); | 399 ASSERT(styleSheet); |
| 408 return styleSheet; | 400 return styleSheet; |
| 409 } | 401 } |
| 410 | 402 |
| 411 void StyleEngine::removeSheet(StyleSheetContents* contents) | 403 void StyleEngine::removeSheet(StyleSheetContents* contents) |
| 412 { | 404 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 429 { | 421 { |
| 430 if (!document().isActive()) | 422 if (!document().isActive()) |
| 431 return; | 423 return; |
| 432 | 424 |
| 433 if (m_resolver) | 425 if (m_resolver) |
| 434 m_resolver->invalidateMatchedPropertiesCache(); | 426 m_resolver->invalidateMatchedPropertiesCache(); |
| 435 document().setNeedsStyleRecalc(SubtreeStyleChange); | 427 document().setNeedsStyleRecalc(SubtreeStyleChange); |
| 436 } | 428 } |
| 437 | 429 |
| 438 } | 430 } |
| OLD | NEW |