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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 } | 378 } |
379 }; | 379 }; |
380 | 380 |
381 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
lasses) | 381 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
lasses) |
382 : ContainerNode(0, CreateDocument) | 382 : ContainerNode(0, CreateDocument) |
383 , TreeScope(this) | 383 , TreeScope(this) |
384 , m_styleResolverThrowawayTimer(this, &Document::styleResolverThrowawayTimer
Fired) | 384 , m_styleResolverThrowawayTimer(this, &Document::styleResolverThrowawayTimer
Fired) |
385 , m_lastStyleResolverAccessTime(0) | 385 , m_lastStyleResolverAccessTime(0) |
386 , m_didCalculateStyleResolver(false) | 386 , m_didCalculateStyleResolver(false) |
387 , m_ignorePendingStylesheets(false) | 387 , m_ignorePendingStylesheets(false) |
| 388 , m_evaluateMediaQueriesOnStyleRecalc(false) |
388 , m_needsNotifyRemoveAllPendingStylesheet(false) | 389 , m_needsNotifyRemoveAllPendingStylesheet(false) |
389 , m_hasNodesWithPlaceholderStyle(false) | 390 , m_hasNodesWithPlaceholderStyle(false) |
390 , m_pendingSheetLayout(NoLayoutWithPendingSheets) | 391 , m_pendingSheetLayout(NoLayoutWithPendingSheets) |
391 , m_frame(initializer.frame()) | 392 , m_frame(initializer.frame()) |
392 , m_domWindow(0) | 393 , m_domWindow(0) |
393 , m_import(initializer.import()) | 394 , m_import(initializer.import()) |
394 , m_activeParserCount(0) | 395 , m_activeParserCount(0) |
395 , m_contextFeatures(ContextFeatures::defaultSwitch()) | 396 , m_contextFeatures(ContextFeatures::defaultSwitch()) |
396 , m_wellFormed(false) | 397 , m_wellFormed(false) |
397 , m_printing(false) | 398 , m_printing(false) |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1685 ASSERT(!view() || !view()->isPainting()); | 1686 ASSERT(!view() || !view()->isPainting()); |
1686 if (view() && view()->isPainting()) | 1687 if (view() && view()->isPainting()) |
1687 return; | 1688 return; |
1688 | 1689 |
1689 if (m_inStyleRecalc) | 1690 if (m_inStyleRecalc) |
1690 return; // Guard against re-entrancy. -dwh | 1691 return; // Guard against re-entrancy. -dwh |
1691 | 1692 |
1692 TRACE_EVENT0("webkit", "Document::recalcStyle"); | 1693 TRACE_EVENT0("webkit", "Document::recalcStyle"); |
1693 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle"); | 1694 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle"); |
1694 | 1695 |
| 1696 if (m_evaluateMediaQueriesOnStyleRecalc) { |
| 1697 m_evaluateMediaQueriesOnStyleRecalc = false; |
| 1698 evaluateMediaQueryList(); |
| 1699 } |
| 1700 |
1695 updateDistributionIfNeeded(); | 1701 updateDistributionIfNeeded(); |
1696 | 1702 |
1697 // FIXME: We should update style on our ancestor chain before proceeding (es
pecially for seamless), | 1703 // FIXME: We should update style on our ancestor chain before proceeding (es
pecially for seamless), |
1698 // however doing so currently causes several tests to crash, as Frame::setDo
cument calls Document::attach | 1704 // however doing so currently causes several tests to crash, as Frame::setDo
cument calls Document::attach |
1699 // before setting the DOMWindow on the Frame, or the SecurityOrigin on the d
ocument. The attach, in turn | 1705 // before setting the DOMWindow on the Frame, or the SecurityOrigin on the d
ocument. The attach, in turn |
1700 // resolves style (here) and then when we resolve style on the parent chain,
we may end up | 1706 // resolves style (here) and then when we resolve style on the parent chain,
we may end up |
1701 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed | 1707 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed |
1702 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. | 1708 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. |
1703 | 1709 |
1704 if (m_styleSheetCollections->needsUpdateActiveStylesheetsOnStyleRecalc()) | 1710 if (m_styleSheetCollections->needsUpdateActiveStylesheetsOnStyleRecalc()) |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2821 void Document::seamlessParentUpdatedStylesheets() | 2827 void Document::seamlessParentUpdatedStylesheets() |
2822 { | 2828 { |
2823 m_styleSheetCollections->didModifySeamlessParentStyleSheet(); | 2829 m_styleSheetCollections->didModifySeamlessParentStyleSheet(); |
2824 styleResolverChanged(RecalcStyleImmediately); | 2830 styleResolverChanged(RecalcStyleImmediately); |
2825 } | 2831 } |
2826 | 2832 |
2827 void Document::didRemoveAllPendingStylesheet() | 2833 void Document::didRemoveAllPendingStylesheet() |
2828 { | 2834 { |
2829 m_needsNotifyRemoveAllPendingStylesheet = false; | 2835 m_needsNotifyRemoveAllPendingStylesheet = false; |
2830 | 2836 |
2831 styleResolverChanged(RecalcStyleImmediately, AnalyzedStyleUpdate); | 2837 styleResolverChanged(RecalcStyleDeferred, AnalyzedStyleUpdate); |
2832 executeScriptsWaitingForResourcesIfNeeded(); | 2838 executeScriptsWaitingForResourcesIfNeeded(); |
2833 | 2839 |
2834 if (m_gotoAnchorNeededAfterStylesheetsLoad && view()) | 2840 if (m_gotoAnchorNeededAfterStylesheetsLoad && view()) |
2835 view()->scrollToFragment(m_url); | 2841 view()->scrollToFragment(m_url); |
2836 } | 2842 } |
2837 | 2843 |
2838 void Document::executeScriptsWaitingForResourcesIfNeeded() | 2844 void Document::executeScriptsWaitingForResourcesIfNeeded() |
2839 { | 2845 { |
2840 if (!haveStylesheetsAndImportsLoaded()) | 2846 if (!haveStylesheetsAndImportsLoaded()) |
2841 return; | 2847 return; |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3296 // Don't bother updating, since we haven't loaded all our style info yet | 3302 // Don't bother updating, since we haven't loaded all our style info yet |
3297 // and haven't calculated the style selector for the first time. | 3303 // and haven't calculated the style selector for the first time. |
3298 if (!attached() || (!m_didCalculateStyleResolver && !haveStylesheetsLoaded()
)) { | 3304 if (!attached() || (!m_didCalculateStyleResolver && !haveStylesheetsLoaded()
)) { |
3299 m_styleResolver.clear(); | 3305 m_styleResolver.clear(); |
3300 return; | 3306 return; |
3301 } | 3307 } |
3302 m_didCalculateStyleResolver = true; | 3308 m_didCalculateStyleResolver = true; |
3303 | 3309 |
3304 bool needsRecalc = m_styleSheetCollections->updateActiveStyleSheets(updateMo
de); | 3310 bool needsRecalc = m_styleSheetCollections->updateActiveStyleSheets(updateMo
de); |
3305 | 3311 |
3306 if (updateType >= RecalcStyleDeferred) { | |
3307 setNeedsStyleRecalc(); | |
3308 return; | |
3309 } | |
3310 | |
3311 if (didLayoutWithPendingStylesheets() && !m_styleSheetCollections->hasPendin
gSheets()) { | 3312 if (didLayoutWithPendingStylesheets() && !m_styleSheetCollections->hasPendin
gSheets()) { |
| 3313 // We need to manually repaint because we avoid doing all repaints in la
yout or style |
| 3314 // recalc while sheets are still loading to avoid FOUC. |
3312 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets; | 3315 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets; |
3313 if (renderer()) | 3316 renderView()->repaintViewAndCompositedLayers(); |
3314 renderView()->repaintViewAndCompositedLayers(); | |
3315 } | 3317 } |
3316 | 3318 |
3317 if (!needsRecalc) | 3319 if (!needsRecalc) |
3318 return; | 3320 return; |
3319 | 3321 |
3320 // This recalcStyle initiates a new recalc cycle. We need to bracket it to | 3322 m_evaluateMediaQueriesOnStyleRecalc = true; |
3321 // make sure animations get the correct update time | 3323 setNeedsStyleRecalc(); |
3322 { | |
3323 AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation()
: 0); | |
3324 recalcStyle(Force); | |
3325 } | |
3326 | 3324 |
3327 if (renderer()) { | 3325 if (updateType == RecalcStyleImmediately) |
3328 renderer()->setNeedsLayoutAndPrefWidthsRecalc(); | 3326 updateStyleIfNeeded(); |
3329 if (view()) | |
3330 view()->scheduleRelayout(); | |
3331 } | |
3332 | |
3333 evaluateMediaQueryList(); | |
3334 } | 3327 } |
3335 | 3328 |
3336 void Document::notifySeamlessChildDocumentsOfStylesheetUpdate() const | 3329 void Document::notifySeamlessChildDocumentsOfStylesheetUpdate() const |
3337 { | 3330 { |
3338 // If we're not in a frame yet any potential child documents won't have a St
yleResolver to update. | 3331 // If we're not in a frame yet any potential child documents won't have a St
yleResolver to update. |
3339 if (!frame()) | 3332 if (!frame()) |
3340 return; | 3333 return; |
3341 | 3334 |
3342 // Seamless child frames are expected to notify their seamless children recu
rsively, so we only do direct children. | 3335 // Seamless child frames are expected to notify their seamless children recu
rsively, so we only do direct children. |
3343 for (Frame* child = frame()->tree()->firstChild(); child; child = child->tre
e()->nextSibling()) { | 3336 for (Frame* child = frame()->tree()->firstChild(); child; child = child->tre
e()->nextSibling()) { |
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5451 { | 5444 { |
5452 return DocumentLifecycleNotifier::create(this); | 5445 return DocumentLifecycleNotifier::create(this); |
5453 } | 5446 } |
5454 | 5447 |
5455 DocumentLifecycleNotifier* Document::lifecycleNotifier() | 5448 DocumentLifecycleNotifier* Document::lifecycleNotifier() |
5456 { | 5449 { |
5457 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); | 5450 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); |
5458 } | 5451 } |
5459 | 5452 |
5460 } // namespace WebCore | 5453 } // namespace WebCore |
OLD | NEW |