| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 { | 234 { |
| 235 DEFINE_STATIC_LOCAL(OwnPtr<WeakDocumentSet>, set, (adoptPtr(new WeakDocument
Set()))); | 235 DEFINE_STATIC_LOCAL(OwnPtr<WeakDocumentSet>, set, (adoptPtr(new WeakDocument
Set()))); |
| 236 return *set; | 236 return *set; |
| 237 } | 237 } |
| 238 #endif | 238 #endif |
| 239 | 239 |
| 240 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
lasses) | 240 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
lasses) |
| 241 : ContainerNode(0, CreateDocument) | 241 : ContainerNode(0, CreateDocument) |
| 242 , TreeScope(*this) | 242 , TreeScope(*this) |
| 243 , m_module(nullptr) | 243 , m_module(nullptr) |
| 244 , m_hasNodesWithPlaceholderStyle(false) | |
| 245 , m_evaluateMediaQueriesOnStyleRecalc(false) | 244 , m_evaluateMediaQueriesOnStyleRecalc(false) |
| 246 , m_pendingSheetLayout(NoLayoutWithPendingSheets) | 245 , m_pendingSheetLayout(NoLayoutWithPendingSheets) |
| 247 , m_frame(initializer.frame()) | 246 , m_frame(initializer.frame()) |
| 248 , m_domWindow(m_frame ? m_frame->domWindow() : 0) | 247 , m_domWindow(m_frame ? m_frame->domWindow() : 0) |
| 249 , m_importsController(initializer.importsController()) | 248 , m_importsController(initializer.importsController()) |
| 250 , m_activeParserCount(0) | 249 , m_activeParserCount(0) |
| 251 , m_executeScriptsWaitingForResourcesTimer(this, &Document::executeScriptsWa
itingForResourcesTimerFired) | 250 , m_executeScriptsWaitingForResourcesTimer(this, &Document::executeScriptsWa
itingForResourcesTimerFired) |
| 252 , m_clearFocusedElementTimer(this, &Document::clearFocusedElementTimerFired) | 251 , m_clearFocusedElementTimer(this, &Document::clearFocusedElementTimerFired) |
| 253 , m_listenerTypes(0) | 252 , m_listenerTypes(0) |
| 254 , m_mutationObserverTypes(0) | 253 , m_mutationObserverTypes(0) |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 | 1070 |
| 1072 if (styleChangeType() >= SubtreeStyleChange) | 1071 if (styleChangeType() >= SubtreeStyleChange) |
| 1073 change = Force; | 1072 change = Force; |
| 1074 | 1073 |
| 1075 // FIXME: Cannot access the ensureStyleResolver() before calling styleForDoc
ument below because | 1074 // FIXME: Cannot access the ensureStyleResolver() before calling styleForDoc
ument below because |
| 1076 // apparently the StyleResolver's constructor has side effects. We should fi
x it. | 1075 // apparently the StyleResolver's constructor has side effects. We should fi
x it. |
| 1077 // See printing/setPrinting.html, printing/width-overflow.html though they o
nly fail on | 1076 // See printing/setPrinting.html, printing/width-overflow.html though they o
nly fail on |
| 1078 // mac when accessing the resolver by what appears to be a viewport size dif
ference. | 1077 // mac when accessing the resolver by what appears to be a viewport size dif
ference. |
| 1079 | 1078 |
| 1080 if (change == Force) { | 1079 if (change == Force) { |
| 1081 m_hasNodesWithPlaceholderStyle = false; | |
| 1082 RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument(*thi
s); | 1080 RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument(*thi
s); |
| 1083 StyleRecalcChange localChange = RenderStyle::stylePropagationDiff(docume
ntStyle.get(), renderView()->style()); | 1081 StyleRecalcChange localChange = RenderStyle::stylePropagationDiff(docume
ntStyle.get(), renderView()->style()); |
| 1084 if (localChange != NoChange) | 1082 if (localChange != NoChange) |
| 1085 renderView()->setStyle(documentStyle.release()); | 1083 renderView()->setStyle(documentStyle.release()); |
| 1086 } | 1084 } |
| 1087 | 1085 |
| 1088 clearNeedsStyleRecalc(); | 1086 clearNeedsStyleRecalc(); |
| 1089 | 1087 |
| 1090 // Uncomment to enable printing of statistics about style sharing and the ma
tched property cache. | 1088 // Uncomment to enable printing of statistics about style sharing and the ma
tched property cache. |
| 1091 // Optionally pass StyleResolver::ReportSlowStats to print numbers that requ
ire crawling the | 1089 // Optionally pass StyleResolver::ReportSlowStats to print numbers that requ
ire crawling the |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 | 1166 |
| 1169 void Document::clearFocusedElementTimerFired(Timer<Document>*) | 1167 void Document::clearFocusedElementTimerFired(Timer<Document>*) |
| 1170 { | 1168 { |
| 1171 updateRenderTreeIfNeeded(); | 1169 updateRenderTreeIfNeeded(); |
| 1172 m_clearFocusedElementTimer.stop(); | 1170 m_clearFocusedElementTimer.stop(); |
| 1173 | 1171 |
| 1174 if (m_focusedElement && !m_focusedElement->isFocusable()) | 1172 if (m_focusedElement && !m_focusedElement->isFocusable()) |
| 1175 m_focusedElement->blur(); | 1173 m_focusedElement->blur(); |
| 1176 } | 1174 } |
| 1177 | 1175 |
| 1178 // FIXME: This is a bad idea and needs to be removed eventually. | |
| 1179 // Other browsers load stylesheets before they continue parsing the web page. | |
| 1180 // Since we don't, we can run JavaScript code that needs answers before the | |
| 1181 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets | |
| 1182 // lets us get reasonable answers. The long term solution to this problem is | |
| 1183 // to instead suspend JavaScript execution. | |
| 1184 void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks
runPostLayoutTasks) | |
| 1185 { | |
| 1186 StyleEngine::IgnoringPendingStylesheet ignoring(m_styleEngine.get()); | |
| 1187 updateLayout(); | |
| 1188 if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view()) | |
| 1189 view()->flushAnyPendingPostLayoutTasks(); | |
| 1190 } | |
| 1191 | |
| 1192 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem
ent* element) | |
| 1193 { | |
| 1194 ASSERT_ARG(element, element->document() == this); | |
| 1195 StyleEngine::IgnoringPendingStylesheet ignoring(m_styleEngine.get()); | |
| 1196 return ensureStyleResolver().styleForElement(element, element->parentNode()
? element->parentNode()->computedStyle() : 0); | |
| 1197 } | |
| 1198 | |
| 1199 StyleResolver* Document::styleResolver() const | 1176 StyleResolver* Document::styleResolver() const |
| 1200 { | 1177 { |
| 1201 if (!isActive()) | 1178 if (!isActive()) |
| 1202 return 0; | 1179 return 0; |
| 1203 return m_styleEngine->resolver(); | 1180 return m_styleEngine->resolver(); |
| 1204 } | 1181 } |
| 1205 | 1182 |
| 1206 StyleResolver& Document::ensureStyleResolver() const | 1183 StyleResolver& Document::ensureStyleResolver() const |
| 1207 { | 1184 { |
| 1208 ASSERT(isActive()); | 1185 ASSERT(isActive()); |
| (...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2735 using namespace blink; | 2712 using namespace blink; |
| 2736 void showLiveDocumentInstances() | 2713 void showLiveDocumentInstances() |
| 2737 { | 2714 { |
| 2738 WeakDocumentSet& set = liveDocumentSet(); | 2715 WeakDocumentSet& set = liveDocumentSet(); |
| 2739 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 2716 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 2740 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { | 2717 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { |
| 2741 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); | 2718 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); |
| 2742 } | 2719 } |
| 2743 } | 2720 } |
| 2744 #endif | 2721 #endif |
| OLD | NEW |