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 | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
7 * rights reserved. | 7 * rights reserved. |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 void StyleEngine::initialViewportChanged() { | 1043 void StyleEngine::initialViewportChanged() { |
1044 if (m_viewportResolver) | 1044 if (m_viewportResolver) |
1045 m_viewportResolver->initialViewportChanged(); | 1045 m_viewportResolver->initialViewportChanged(); |
1046 } | 1046 } |
1047 | 1047 |
1048 void StyleEngine::viewportRulesChanged() { | 1048 void StyleEngine::viewportRulesChanged() { |
1049 if (m_viewportResolver) | 1049 if (m_viewportResolver) |
1050 m_viewportResolver->setNeedsCollectRules(); | 1050 m_viewportResolver->setNeedsCollectRules(); |
1051 } | 1051 } |
1052 | 1052 |
1053 void StyleEngine::importRemoved() { | 1053 void StyleEngine::htmlImportAddedOrRemoved() { |
1054 if (document().importLoader()) { | 1054 if (document().importLoader()) { |
1055 document().importsController()->master()->styleEngine().importRemoved(); | 1055 document() |
| 1056 .importsController() |
| 1057 ->master() |
| 1058 ->styleEngine() |
| 1059 .htmlImportAddedOrRemoved(); |
1056 return; | 1060 return; |
1057 } | 1061 } |
1058 | 1062 |
1059 // When we remove an import link and re-insert it into the document, the | 1063 // When we remove an import link and re-insert it into the document, the |
1060 // import Document and CSSStyleSheet pointers are persisted. That means the | 1064 // import Document and CSSStyleSheet pointers are persisted. That means the |
1061 // comparison of active stylesheets is not able to figure out that the order | 1065 // comparison of active stylesheets is not able to figure out that the order |
1062 // of the stylesheets have changed after insertion. | 1066 // of the stylesheets have changed after insertion. |
1063 // | 1067 // |
| 1068 // This is also the case when we import the same document twice where the |
| 1069 // last inserted document is inserted before the first one in dom order where |
| 1070 // the last would take precedence. |
| 1071 // |
1064 // Fall back to re-add all sheets to the scoped resolver and recalculate style | 1072 // Fall back to re-add all sheets to the scoped resolver and recalculate style |
1065 // for the whole document if we remove an import in case it is re-inserted | 1073 // for the whole document when we remove or insert an import document. |
1066 // into the document. The assumption is that removing html imports is very | |
1067 // rare. | |
1068 if (ScopedStyleResolver* resolver = document().scopedStyleResolver()) { | 1074 if (ScopedStyleResolver* resolver = document().scopedStyleResolver()) { |
| 1075 markDocumentDirty(); |
1069 resolver->setNeedsAppendAllSheets(); | 1076 resolver->setNeedsAppendAllSheets(); |
1070 document().setNeedsStyleRecalc( | 1077 document().setNeedsStyleRecalc( |
1071 SubtreeStyleChange, StyleChangeReasonForTracing::create( | 1078 SubtreeStyleChange, StyleChangeReasonForTracing::create( |
1072 StyleChangeReason::ActiveStylesheetsUpdate)); | 1079 StyleChangeReason::ActiveStylesheetsUpdate)); |
1073 } | 1080 } |
1074 } | 1081 } |
1075 | 1082 |
1076 PassRefPtr<ComputedStyle> StyleEngine::findSharedStyle( | 1083 PassRefPtr<ComputedStyle> StyleEngine::findSharedStyle( |
1077 const ElementResolveContext& elementResolveContext) { | 1084 const ElementResolveContext& elementResolveContext) { |
1078 DCHECK(m_resolver); | 1085 DCHECK(m_resolver); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 } | 1238 } |
1232 | 1239 |
1233 DEFINE_TRACE_WRAPPERS(StyleEngine) { | 1240 DEFINE_TRACE_WRAPPERS(StyleEngine) { |
1234 for (auto sheet : m_injectedAuthorStyleSheets) { | 1241 for (auto sheet : m_injectedAuthorStyleSheets) { |
1235 visitor->traceWrappers(sheet); | 1242 visitor->traceWrappers(sheet); |
1236 } | 1243 } |
1237 visitor->traceWrappers(m_documentStyleSheetCollection); | 1244 visitor->traceWrappers(m_documentStyleSheetCollection); |
1238 } | 1245 } |
1239 | 1246 |
1240 } // namespace blink | 1247 } // namespace blink |
OLD | NEW |