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 12 matching lines...) Expand all Loading... | |
23 * along with this library; see the file COPYING.LIB. If not, write to | 23 * along with this library; see the file COPYING.LIB. If not, write to |
24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
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/CSSStyleSheet.h" | 34 #include "core/css/CSSStyleSheet.h" |
34 #include "core/css/StyleInvalidationAnalysis.h" | 35 #include "core/css/StyleInvalidationAnalysis.h" |
35 #include "core/css/StyleSheetContents.h" | 36 #include "core/css/StyleSheetContents.h" |
36 #include "core/dom/Element.h" | 37 #include "core/dom/Element.h" |
37 #include "core/dom/ProcessingInstruction.h" | 38 #include "core/dom/ProcessingInstruction.h" |
38 #include "core/dom/ShadowTreeStyleSheetCollection.h" | 39 #include "core/dom/ShadowTreeStyleSheetCollection.h" |
39 #include "core/dom/shadow/ShadowRoot.h" | 40 #include "core/dom/shadow/ShadowRoot.h" |
40 #include "core/html/HTMLIFrameElement.h" | 41 #include "core/html/HTMLIFrameElement.h" |
41 #include "core/html/HTMLLinkElement.h" | 42 #include "core/html/HTMLLinkElement.h" |
42 #include "core/html/HTMLStyleElement.h" | 43 #include "core/html/HTMLStyleElement.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
61 , m_usesSiblingRules(false) | 62 , m_usesSiblingRules(false) |
62 , m_usesSiblingRulesOverride(false) | 63 , m_usesSiblingRulesOverride(false) |
63 , m_usesFirstLineRules(false) | 64 , m_usesFirstLineRules(false) |
64 , m_usesFirstLetterRules(false) | 65 , m_usesFirstLetterRules(false) |
65 , m_usesRemUnits(false) | 66 , m_usesRemUnits(false) |
66 , m_maxDirectAdjacentSelectors(0) | 67 , m_maxDirectAdjacentSelectors(0) |
67 , m_ignorePendingStylesheets(false) | 68 , m_ignorePendingStylesheets(false) |
68 , m_didCalculateResolver(false) | 69 , m_didCalculateResolver(false) |
69 , m_lastResolverAccessCount(0) | 70 , m_lastResolverAccessCount(0) |
70 , m_resolverThrowawayTimer(this, &StyleEngine::resolverThrowawayTimerFired) | 71 , m_resolverThrowawayTimer(this, &StyleEngine::resolverThrowawayTimerFired) |
72 , m_fontSelector(CSSFontSelector::create(&document)) | |
71 { | 73 { |
72 } | 74 } |
73 | 75 |
74 StyleEngine::~StyleEngine() | 76 StyleEngine::~StyleEngine() |
75 { | 77 { |
78 if (m_resolver) | |
79 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()); | |
80 m_fontSelector->clearDocument(); | |
81 | |
76 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) | 82 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) |
77 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); | 83 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); |
78 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i) | 84 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i) |
79 m_authorStyleSheets[i]->clearOwnerNode(); | 85 m_authorStyleSheets[i]->clearOwnerNode(); |
80 } | 86 } |
81 | 87 |
82 void StyleEngine::insertTreeScopeInDocumentOrder(TreeScopeSet& treeScopes, TreeS cope* treeScope) | 88 void StyleEngine::insertTreeScopeInDocumentOrder(TreeScopeSet& treeScopes, TreeS cope* treeScope) |
83 { | 89 { |
84 if (treeScopes.isEmpty()) { | 90 if (treeScopes.isEmpty()) { |
85 treeScopes.add(treeScope); | 91 treeScopes.add(treeScope); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 | 403 |
398 void StyleEngine::createResolver() | 404 void StyleEngine::createResolver() |
399 { | 405 { |
400 // It is a programming error to attempt to resolve style on a Document | 406 // It is a programming error to attempt to resolve style on a Document |
401 // which is not in a frame. Code which hits this should have checked | 407 // which is not in a frame. Code which hits this should have checked |
402 // Document::isActive() before calling into code which could get here. | 408 // Document::isActive() before calling into code which could get here. |
403 | 409 |
404 ASSERT(m_document.frame()); | 410 ASSERT(m_document.frame()); |
405 | 411 |
406 m_resolver = adoptPtr(new StyleResolver(m_document)); | 412 m_resolver = adoptPtr(new StyleResolver(m_document)); |
413 m_fontSelector->registerForInvalidationCallbacks(m_resolver.get()); | |
407 combineCSSFeatureFlags(m_resolver->ensureRuleFeatureSet()); | 414 combineCSSFeatureFlags(m_resolver->ensureRuleFeatureSet()); |
408 } | 415 } |
409 | 416 |
410 void StyleEngine::clearResolver() | 417 void StyleEngine::clearResolver() |
411 { | 418 { |
419 if (m_resolver) | |
420 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()); | |
412 m_resolver.clear(); | 421 m_resolver.clear(); |
413 } | 422 } |
414 | 423 |
415 unsigned StyleEngine::resolverAccessCount() const | 424 unsigned StyleEngine::resolverAccessCount() const |
416 { | 425 { |
417 return m_resolver ? m_resolver->accessCount() : 0; | 426 return m_resolver ? m_resolver->accessCount() : 0; |
418 } | 427 } |
419 | 428 |
420 void StyleEngine::resolverThrowawayTimerFired(Timer<StyleEngine>*) | 429 void StyleEngine::resolverThrowawayTimerFired(Timer<StyleEngine>*) |
421 { | 430 { |
422 if (resolverAccessCount() == m_lastResolverAccessCount) | 431 if (resolverAccessCount() == m_lastResolverAccessCount) |
423 clearResolver(); | 432 clearResolver(); |
424 m_lastResolverAccessCount = resolverAccessCount(); | 433 m_lastResolverAccessCount = resolverAccessCount(); |
425 } | 434 } |
426 | 435 |
427 CSSFontSelector* StyleEngine::fontSelector() | |
428 { | |
429 return m_resolver ? m_resolver->fontSelector() : 0; | |
430 } | |
431 | |
432 void StyleEngine::didAttach() | 436 void StyleEngine::didAttach() |
433 { | 437 { |
434 m_resolverThrowawayTimer.startRepeating(60); | 438 m_resolverThrowawayTimer.startRepeating(60); |
435 } | 439 } |
436 | 440 |
437 void StyleEngine::didDetach() | 441 void StyleEngine::didDetach() |
438 { | 442 { |
439 m_resolverThrowawayTimer.stop(); | 443 m_resolverThrowawayTimer.stop(); |
440 clearResolver(); | 444 clearResolver(); |
441 } | 445 } |
(...skipping 17 matching lines...) Expand all Loading... | |
459 m_didCalculateResolver = true; | 463 m_didCalculateResolver = true; |
460 if (m_document.didLayoutWithPendingStylesheets() && !hasPendingSheets()) | 464 if (m_document.didLayoutWithPendingStylesheets() && !hasPendingSheets()) |
461 change.setNeedsRepaint(); | 465 change.setNeedsRepaint(); |
462 | 466 |
463 if (updateActiveStyleSheets(mode)) | 467 if (updateActiveStyleSheets(mode)) |
464 change.setNeedsStyleRecalc(); | 468 change.setNeedsStyleRecalc(); |
465 | 469 |
466 return change; | 470 return change; |
467 } | 471 } |
468 | 472 |
473 void StyleEngine::resetFontSelector() | |
474 { | |
475 m_fontSelector->clearDocument(); | |
476 if (m_resolver) { | |
477 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()); | |
dglazkov
2013/12/02 17:47:42
This is fishy, but we'll fix this in another patch
tasak
2013/12/05 05:09:44
Yeah, I will remove this method.
| |
478 m_resolver->invalidateMatchedPropertiesCache(); | |
479 } | |
480 m_fontSelector = CSSFontSelector::create(&m_document); | |
481 if (m_resolver) | |
482 m_fontSelector->registerForInvalidationCallbacks(m_resolver.get()); | |
469 } | 483 } |
484 | |
485 } | |
OLD | NEW |