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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 MediaQueryMatcher& Document::mediaQueryMatcher() | 526 MediaQueryMatcher& Document::mediaQueryMatcher() |
527 { | 527 { |
528 if (!m_mediaQueryMatcher) | 528 if (!m_mediaQueryMatcher) |
529 m_mediaQueryMatcher = MediaQueryMatcher::create(*this); | 529 m_mediaQueryMatcher = MediaQueryMatcher::create(*this); |
530 return *m_mediaQueryMatcher; | 530 return *m_mediaQueryMatcher; |
531 } | 531 } |
532 | 532 |
533 void Document::mediaQueryAffectingValueChanged() | 533 void Document::mediaQueryAffectingValueChanged() |
534 { | 534 { |
535 m_evaluateMediaQueriesOnStyleRecalc = true; | 535 m_evaluateMediaQueriesOnStyleRecalc = true; |
536 styleEngine().clearMediaQueryRuleSetStyleSheets(); | 536 styleEngine().mediaQueryAffectingValueChanged(); |
537 InspectorInstrumentation::mediaQueryResultChanged(this); | 537 InspectorInstrumentation::mediaQueryResultChanged(this); |
538 } | 538 } |
539 | 539 |
540 void Document::setCompatibilityMode(CompatibilityMode mode) | 540 void Document::setCompatibilityMode(CompatibilityMode mode) |
541 { | 541 { |
542 if (m_compatibilityModeLocked || mode == m_compatibilityMode) | 542 if (m_compatibilityModeLocked || mode == m_compatibilityMode) |
543 return; | 543 return; |
544 m_compatibilityMode = mode; | 544 m_compatibilityMode = mode; |
545 selectorQueryCache().invalidate(); | 545 selectorQueryCache().invalidate(); |
546 } | 546 } |
547 | 547 |
548 String Document::compatMode() const | 548 String Document::compatMode() const |
549 { | 549 { |
550 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; | 550 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; |
551 } | 551 } |
552 | 552 |
553 void Document::setDoctype(DocumentType* docType) | 553 void Document::setDoctype(DocumentType* docType) |
554 { | 554 { |
555 // This should never be called more than once. | 555 // This should never be called more than once. |
556 DCHECK(!m_docType || !docType); | 556 DCHECK(!m_docType || !docType); |
557 m_docType = docType; | 557 m_docType = docType; |
558 if (m_docType) { | 558 if (m_docType) { |
559 this->adoptIfNeeded(*m_docType); | 559 this->adoptIfNeeded(*m_docType); |
560 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.",
TextCaseInsensitive)) | 560 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.",
TextCaseInsensitive)) { |
561 m_isMobileDocument = true; | 561 m_isMobileDocument = true; |
| 562 styleEngine().setNeedsActiveStyleUpdate(*this); |
| 563 } |
562 } | 564 } |
563 // Doctype affects the interpretation of the stylesheets. | 565 // Doctype affects the interpretation of the stylesheets. |
| 566 // TODO(rune@opera.com): Is this necessary? Smaller cannon? |
564 styleEngine().clearResolver(); | 567 styleEngine().clearResolver(); |
565 } | 568 } |
566 | 569 |
567 DOMImplementation& Document::implementation() | 570 DOMImplementation& Document::implementation() |
568 { | 571 { |
569 if (!m_implementation) | 572 if (!m_implementation) |
570 m_implementation = DOMImplementation::create(*this); | 573 m_implementation = DOMImplementation::create(*this); |
571 return *m_implementation; | 574 return *m_implementation; |
572 } | 575 } |
573 | 576 |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 return true; | 1475 return true; |
1473 if (!m_layerUpdateSVGFilterElements.isEmpty()) | 1476 if (!m_layerUpdateSVGFilterElements.isEmpty()) |
1474 return true; | 1477 return true; |
1475 if (needsStyleRecalc()) | 1478 if (needsStyleRecalc()) |
1476 return true; | 1479 return true; |
1477 if (needsStyleInvalidation()) | 1480 if (needsStyleInvalidation()) |
1478 return true; | 1481 return true; |
1479 // FIXME: The childNeedsDistributionRecalc bit means either self or children
, we should fix that. | 1482 // FIXME: The childNeedsDistributionRecalc bit means either self or children
, we should fix that. |
1480 if (childNeedsDistributionRecalc()) | 1483 if (childNeedsDistributionRecalc()) |
1481 return true; | 1484 return true; |
| 1485 if (m_styleEngine->needsActiveStyleUpdate()) |
| 1486 return true; |
1482 if (DocumentAnimations::needsAnimationTimingUpdate(*this)) | 1487 if (DocumentAnimations::needsAnimationTimingUpdate(*this)) |
1483 return true; | 1488 return true; |
1484 return false; | 1489 return false; |
1485 } | 1490 } |
1486 | 1491 |
1487 bool Document::shouldScheduleLayoutTreeUpdate() const | 1492 bool Document::shouldScheduleLayoutTreeUpdate() const |
1488 { | 1493 { |
1489 if (!isActive()) | 1494 if (!isActive()) |
1490 return false; | 1495 return false; |
1491 if (inStyleRecalc()) | 1496 if (inStyleRecalc()) |
(...skipping 20 matching lines...) Expand all Loading... |
1512 InspectorInstrumentation::didScheduleStyleRecalculation(this); | 1517 InspectorInstrumentation::didScheduleStyleRecalculation(this); |
1513 | 1518 |
1514 ++m_styleVersion; | 1519 ++m_styleVersion; |
1515 } | 1520 } |
1516 | 1521 |
1517 bool Document::hasPendingForcedStyleRecalc() const | 1522 bool Document::hasPendingForcedStyleRecalc() const |
1518 { | 1523 { |
1519 return hasPendingVisualUpdate() && !inStyleRecalc() && getStyleChangeType()
>= SubtreeStyleChange; | 1524 return hasPendingVisualUpdate() && !inStyleRecalc() && getStyleChangeType()
>= SubtreeStyleChange; |
1520 } | 1525 } |
1521 | 1526 |
1522 void Document::updateStyleInvalidationIfNeeded() | 1527 void Document::updateStyleInvalidation() |
1523 { | 1528 { |
1524 ScriptForbiddenScope forbidScript; | 1529 ScriptForbiddenScope forbidScript; |
1525 | 1530 |
1526 if (!isActive()) | 1531 DCHECK(isActive()); |
1527 return; | |
1528 if (!childNeedsStyleInvalidation()) | 1532 if (!childNeedsStyleInvalidation()) |
1529 return; | 1533 return; |
1530 TRACE_EVENT0("blink", "Document::updateStyleInvalidationIfNeeded"); | 1534 TRACE_EVENT0("blink", "Document::updateStyleInvalidation"); |
1531 styleEngine().styleInvalidator().invalidate(*this); | 1535 styleEngine().styleInvalidator().invalidate(*this); |
1532 } | 1536 } |
1533 | 1537 |
1534 void Document::setupFontBuilder(ComputedStyle& documentStyle) | 1538 void Document::setupFontBuilder(ComputedStyle& documentStyle) |
1535 { | 1539 { |
1536 FontBuilder fontBuilder(*this); | 1540 FontBuilder fontBuilder(*this); |
1537 CSSFontSelector* selector = styleEngine().fontSelector(); | 1541 CSSFontSelector* selector = styleEngine().fontSelector(); |
1538 fontBuilder.createFontForDocument(selector, documentStyle); | 1542 fontBuilder.createFontForDocument(selector, documentStyle); |
1539 } | 1543 } |
1540 | 1544 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateLayoutTree"); | 1742 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateLayoutTree"); |
1739 | 1743 |
1740 unsigned startElementCount = styleEngine().styleForElementCount(); | 1744 unsigned startElementCount = styleEngine().styleForElementCount(); |
1741 | 1745 |
1742 InspectorInstrumentation::StyleRecalc instrumentation(this); | 1746 InspectorInstrumentation::StyleRecalc instrumentation(this); |
1743 | 1747 |
1744 DocumentAnimations::updateAnimationTimingIfNeeded(*this); | 1748 DocumentAnimations::updateAnimationTimingIfNeeded(*this); |
1745 evaluateMediaQueryListIfNeeded(); | 1749 evaluateMediaQueryListIfNeeded(); |
1746 updateUseShadowTreesIfNeeded(); | 1750 updateUseShadowTreesIfNeeded(); |
1747 updateDistribution(); | 1751 updateDistribution(); |
1748 updateStyleInvalidationIfNeeded(); | 1752 styleEngine().updateActiveStyle(); |
| 1753 updateStyleInvalidation(); |
1749 | 1754 |
1750 // FIXME: We should update style on our ancestor chain before proceeding | 1755 // FIXME: We should update style on our ancestor chain before proceeding |
1751 // however doing so currently causes several tests to crash, as LocalFrame::
setDocument calls Document::attach | 1756 // however doing so currently causes several tests to crash, as LocalFrame::
setDocument calls Document::attach |
1752 // before setting the LocalDOMWindow on the LocalFrame, or the SecurityOrigi
n on the document. The attach, in turn | 1757 // before setting the LocalDOMWindow on the LocalFrame, or the SecurityOrigi
n on the document. The attach, in turn |
1753 // resolves style (here) and then when we resolve style on the parent chain,
we may end up | 1758 // resolves style (here) and then when we resolve style on the parent chain,
we may end up |
1754 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed | 1759 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed |
1755 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. | 1760 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. |
1756 | 1761 |
1757 updateStyle(); | 1762 updateStyle(); |
1758 | 1763 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1986 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. | 1991 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. |
1987 // Our assumption is that it would be dangerous to try to stop it a seco
nd time, after page | 1992 // Our assumption is that it would be dangerous to try to stop it a seco
nd time, after page |
1988 // content has already been loaded and displayed with accurate style inf
ormation. (Our | 1993 // content has already been loaded and displayed with accurate style inf
ormation. (Our |
1989 // suppression involves blanking the whole page at the moment. If it wer
e more refined, we | 1994 // suppression involves blanking the whole page at the moment. If it wer
e more refined, we |
1990 // might be able to do something better.) It's worth noting though that
this entire method | 1995 // might be able to do something better.) It's worth noting though that
this entire method |
1991 // is a hack, since what we really want to do is suspend JS instead of d
oing a layout with | 1996 // is a hack, since what we really want to do is suspend JS instead of d
oing a layout with |
1992 // inaccurate information. | 1997 // inaccurate information. |
1993 HTMLElement* bodyElement = body(); | 1998 HTMLElement* bodyElement = body(); |
1994 if (bodyElement && !bodyElement->layoutObject() && m_pendingSheetLayout
== NoLayoutWithPendingSheets) { | 1999 if (bodyElement && !bodyElement->layoutObject() && m_pendingSheetLayout
== NoLayoutWithPendingSheets) { |
1995 m_pendingSheetLayout = DidLayoutWithPendingSheets; | 2000 m_pendingSheetLayout = DidLayoutWithPendingSheets; |
1996 styleEngine().resolverChanged(FullStyleUpdate); | 2001 styleEngine().markAllTreeScopesDirty(); |
| 2002 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:create(StyleChangeReason::CleanupPlaceholderStyles)); |
1997 } else if (m_hasNodesWithPlaceholderStyle) { | 2003 } else if (m_hasNodesWithPlaceholderStyle) { |
1998 // If new nodes have been added or style recalc has been done with s
tyle sheets still | 2004 // If new nodes have been added or style recalc has been done with s
tyle sheets still |
1999 // pending, some nodes may not have had their real style calculated
yet. Normally this | 2005 // pending, some nodes may not have had their real style calculated
yet. Normally this |
2000 // gets cleaned when style sheets arrive but here we need up-to-date
style immediately. | 2006 // gets cleaned when style sheets arrive but here we need up-to-date
style immediately. |
2001 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:create(StyleChangeReason::CleanupPlaceholderStyles)); | 2007 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:create(StyleChangeReason::CleanupPlaceholderStyles)); |
2002 } | 2008 } |
2003 } | 2009 } |
2004 updateStyleAndLayoutTree(); | 2010 updateStyleAndLayoutTree(); |
2005 } | 2011 } |
2006 | 2012 |
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3445 if (m_mediaQueryMatcher) | 3451 if (m_mediaQueryMatcher) |
3446 m_mediaQueryMatcher->viewportChanged(); | 3452 m_mediaQueryMatcher->viewportChanged(); |
3447 if (!hasViewportUnits()) | 3453 if (!hasViewportUnits()) |
3448 return; | 3454 return; |
3449 ensureStyleResolver().notifyResizeForViewportUnits(); | 3455 ensureStyleResolver().notifyResizeForViewportUnits(); |
3450 setNeedsStyleRecalcForViewportUnits(); | 3456 setNeedsStyleRecalcForViewportUnits(); |
3451 } | 3457 } |
3452 | 3458 |
3453 void Document::styleResolverMayHaveChanged() | 3459 void Document::styleResolverMayHaveChanged() |
3454 { | 3460 { |
3455 styleEngine().resolverChanged(hasNodesWithPlaceholderStyle() ? FullStyleUpda
te : AnalyzedStyleUpdate); | 3461 if (hasNodesWithPlaceholderStyle()) { |
| 3462 styleEngine().markAllTreeScopesDirty(); |
| 3463 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre
ate(StyleChangeReason::CleanupPlaceholderStyles)); |
| 3464 } |
3456 | 3465 |
3457 if (didLayoutWithPendingStylesheets() && !styleEngine().hasPendingScriptBloc
kingSheets()) { | 3466 if (didLayoutWithPendingStylesheets() && !styleEngine().hasPendingScriptBloc
kingSheets()) { |
3458 // We need to manually repaint because we avoid doing all repaints in la
yout or style | 3467 // We need to manually repaint because we avoid doing all repaints in la
yout or style |
3459 // recalc while sheets are still loading to avoid FOUC. | 3468 // recalc while sheets are still loading to avoid FOUC. |
3460 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets; | 3469 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets; |
3461 | 3470 |
3462 DCHECK(layoutView() || importsController()); | 3471 DCHECK(layoutView() || importsController()); |
3463 if (layoutView()) | 3472 if (layoutView()) |
3464 layoutView()->invalidatePaintForViewAndCompositedLayers(); | 3473 layoutView()->invalidatePaintForViewAndCompositedLayers(); |
3465 } | 3474 } |
(...skipping 2567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6033 #ifndef NDEBUG | 6042 #ifndef NDEBUG |
6034 using namespace blink; | 6043 using namespace blink; |
6035 void showLiveDocumentInstances() | 6044 void showLiveDocumentInstances() |
6036 { | 6045 { |
6037 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 6046 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
6038 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6047 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6039 for (Document* document : set) | 6048 for (Document* document : set) |
6040 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 6049 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
6041 } | 6050 } |
6042 #endif | 6051 #endif |
OLD | NEW |