| 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) | 379 static bool isCacheableForStyleElement(const StyleSheetContents& contents) |
| 380 { | 380 { |
| 381 if (!contents.hasSyntacticallyValidCSSHeader()) | 381 if (!contents.hasSyntacticallyValidCSSHeader()) |
| 382 return false; | 382 return false; |
| 383 return true; | 383 return true; |
| 384 } | 384 } |
| 385 | 385 |
| 386 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex
t, TextPosition startPosition, bool createdByParser) | 386 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex
t) |
| 387 { | 387 { |
| 388 RefPtr<CSSStyleSheet> styleSheet = nullptr; | 388 RefPtr<CSSStyleSheet> styleSheet; |
| 389 | |
| 390 AtomicString textContent(text); | 389 AtomicString textContent(text); |
| 391 | 390 |
| 392 HashMap<AtomicString, RawPtr<StyleSheetContents> >::AddResult result = m_tex
tToSheetCache.add(textContent, nullptr); | 391 HashMap<AtomicString, RawPtr<StyleSheetContents> >::AddResult result = m_tex
tToSheetCache.add(textContent, nullptr); |
| 393 if (result.isNewEntry || !result.storedValue->value) { | 392 if (result.isNewEntry || !result.storedValue->value) { |
| 394 styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByPa
rser); | 393 styleSheet = CSSStyleSheet::createInline(e, KURL()); |
| 394 styleSheet->contents()->parseString(text); |
| 395 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->content
s())) { | 395 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->content
s())) { |
| 396 result.storedValue->value = styleSheet->contents(); | 396 result.storedValue->value = styleSheet->contents(); |
| 397 m_sheetToTextCache.add(styleSheet->contents(), textContent); | 397 m_sheetToTextCache.add(styleSheet->contents(), textContent); |
| 398 } | 398 } |
| 399 } else { | 399 } else { |
| 400 StyleSheetContents* contents = result.storedValue->value; | 400 StyleSheetContents* contents = result.storedValue->value; |
| 401 ASSERT(contents); | 401 ASSERT(contents); |
| 402 ASSERT(isCacheableForStyleElement(*contents)); | 402 ASSERT(isCacheableForStyleElement(*contents)); |
| 403 ASSERT(contents->singleOwnerDocument() == e->document()); | 403 ASSERT(contents->singleOwnerDocument() == e->document()); |
| 404 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); | 404 styleSheet = CSSStyleSheet::createInline(contents, e); |
| 405 } | 405 } |
| 406 | 406 |
| 407 ASSERT(styleSheet); | 407 ASSERT(styleSheet); |
| 408 return styleSheet; | 408 return styleSheet; |
| 409 } | 409 } |
| 410 | 410 |
| 411 PassRefPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const String& text
, TextPosition startPosition, bool createdByParser) | |
| 412 { | |
| 413 RefPtr<CSSStyleSheet> styleSheet = nullptr; | |
| 414 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition); | |
| 415 styleSheet->contents()->parseStringAtPosition(text, startPosition, createdBy
Parser); | |
| 416 return styleSheet; | |
| 417 } | |
| 418 | |
| 419 void StyleEngine::removeSheet(StyleSheetContents* contents) | 411 void StyleEngine::removeSheet(StyleSheetContents* contents) |
| 420 { | 412 { |
| 421 HashMap<RawPtr<StyleSheetContents>, AtomicString>::iterator it = m_sheetToTe
xtCache.find(contents); | 413 HashMap<RawPtr<StyleSheetContents>, AtomicString>::iterator it = m_sheetToTe
xtCache.find(contents); |
| 422 if (it == m_sheetToTextCache.end()) | 414 if (it == m_sheetToTextCache.end()) |
| 423 return; | 415 return; |
| 424 | 416 |
| 425 m_textToSheetCache.remove(it->value); | 417 m_textToSheetCache.remove(it->value); |
| 426 m_sheetToTextCache.remove(contents); | 418 m_sheetToTextCache.remove(contents); |
| 427 } | 419 } |
| 428 | 420 |
| 429 void StyleEngine::collectScopedStyleFeaturesTo(RuleFeatureSet& features) const | 421 void StyleEngine::collectScopedStyleFeaturesTo(RuleFeatureSet& features) const |
| 430 { | 422 { |
| 431 HashSet<const StyleSheetContents*> visitedSharedStyleSheetContents; | 423 HashSet<const StyleSheetContents*> visitedSharedStyleSheetContents; |
| 432 for (ScopedStyleResolverSet::iterator it = m_scopedStyleResolvers.begin(); i
t != m_scopedStyleResolvers.end(); ++it) | 424 for (ScopedStyleResolverSet::iterator it = m_scopedStyleResolvers.begin(); i
t != m_scopedStyleResolvers.end(); ++it) |
| 433 (*it)->collectFeaturesTo(features, visitedSharedStyleSheetContents); | 425 (*it)->collectFeaturesTo(features, visitedSharedStyleSheetContents); |
| 434 } | 426 } |
| 435 | 427 |
| 436 void StyleEngine::fontsNeedUpdate(CSSFontSelector*) | 428 void StyleEngine::fontsNeedUpdate(CSSFontSelector*) |
| 437 { | 429 { |
| 438 if (!document().isActive()) | 430 if (!document().isActive()) |
| 439 return; | 431 return; |
| 440 | 432 |
| 441 if (m_resolver) | 433 if (m_resolver) |
| 442 m_resolver->invalidateMatchedPropertiesCache(); | 434 m_resolver->invalidateMatchedPropertiesCache(); |
| 443 document().setNeedsStyleRecalc(SubtreeStyleChange); | 435 document().setNeedsStyleRecalc(SubtreeStyleChange); |
| 444 } | 436 } |
| 445 | 437 |
| 446 } | 438 } |
| OLD | NEW |