| 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; | 599 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; |
| 600 } | 600 } |
| 601 | 601 |
| 602 void Document::setDoctype(DocumentType* docType) { | 602 void Document::setDoctype(DocumentType* docType) { |
| 603 // This should never be called more than once. | 603 // This should never be called more than once. |
| 604 DCHECK(!m_docType || !docType); | 604 DCHECK(!m_docType || !docType); |
| 605 m_docType = docType; | 605 m_docType = docType; |
| 606 if (m_docType) { | 606 if (m_docType) { |
| 607 this->adoptIfNeeded(*m_docType); | 607 this->adoptIfNeeded(*m_docType); |
| 608 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", | 608 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", |
| 609 TextCaseInsensitive)) | 609 TextCaseInsensitive)) { |
| 610 m_isMobileDocument = true; | 610 m_isMobileDocument = true; |
| 611 m_styleEngine->viewportRulesChanged(); |
| 612 } |
| 611 } | 613 } |
| 612 // Doctype affects the interpretation of the stylesheets. | |
| 613 styleEngine().clearResolver(); | |
| 614 } | 614 } |
| 615 | 615 |
| 616 DOMImplementation& Document::implementation() { | 616 DOMImplementation& Document::implementation() { |
| 617 if (!m_implementation) | 617 if (!m_implementation) |
| 618 m_implementation = DOMImplementation::create(*this); | 618 m_implementation = DOMImplementation::create(*this); |
| 619 return *m_implementation; | 619 return *m_implementation; |
| 620 } | 620 } |
| 621 | 621 |
| 622 bool Document::hasAppCacheManifest() const { | 622 bool Document::hasAppCacheManifest() const { |
| 623 return isHTMLHtmlElement(documentElement()) && | 623 return isHTMLHtmlElement(documentElement()) && |
| (...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 if (childNeedsStyleInvalidation()) | 1559 if (childNeedsStyleInvalidation()) |
| 1560 return true; | 1560 return true; |
| 1561 if (layoutViewItem().wasNotifiedOfSubtreeChange()) | 1561 if (layoutViewItem().wasNotifiedOfSubtreeChange()) |
| 1562 return true; | 1562 return true; |
| 1563 return false; | 1563 return false; |
| 1564 } | 1564 } |
| 1565 | 1565 |
| 1566 bool Document::needsFullLayoutTreeUpdate() const { | 1566 bool Document::needsFullLayoutTreeUpdate() const { |
| 1567 if (!isActive() || !view()) | 1567 if (!isActive() || !view()) |
| 1568 return false; | 1568 return false; |
| 1569 if (m_styleEngine->needsActiveStyleUpdate()) |
| 1570 return true; |
| 1569 if (!m_useElementsNeedingUpdate.isEmpty()) | 1571 if (!m_useElementsNeedingUpdate.isEmpty()) |
| 1570 return true; | 1572 return true; |
| 1571 if (needsStyleRecalc()) | 1573 if (needsStyleRecalc()) |
| 1572 return true; | 1574 return true; |
| 1573 if (needsStyleInvalidation()) | 1575 if (needsStyleInvalidation()) |
| 1574 return true; | 1576 return true; |
| 1575 // FIXME: The childNeedsDistributionRecalc bit means either self or children, | 1577 // FIXME: The childNeedsDistributionRecalc bit means either self or children, |
| 1576 // we should fix that. | 1578 // we should fix that. |
| 1577 if (childNeedsDistributionRecalc()) | 1579 if (childNeedsDistributionRecalc()) |
| 1578 return true; | 1580 return true; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 | 1613 |
| 1612 ++m_styleVersion; | 1614 ++m_styleVersion; |
| 1613 } | 1615 } |
| 1614 | 1616 |
| 1615 bool Document::hasPendingForcedStyleRecalc() const { | 1617 bool Document::hasPendingForcedStyleRecalc() const { |
| 1616 return hasPendingVisualUpdate() && !inStyleRecalc() && | 1618 return hasPendingVisualUpdate() && !inStyleRecalc() && |
| 1617 getStyleChangeType() >= SubtreeStyleChange; | 1619 getStyleChangeType() >= SubtreeStyleChange; |
| 1618 } | 1620 } |
| 1619 | 1621 |
| 1620 void Document::updateStyleInvalidationIfNeeded() { | 1622 void Document::updateStyleInvalidationIfNeeded() { |
| 1623 DCHECK(isActive()); |
| 1621 ScriptForbiddenScope forbidScript; | 1624 ScriptForbiddenScope forbidScript; |
| 1622 | 1625 |
| 1623 if (!isActive()) | |
| 1624 return; | |
| 1625 if (!childNeedsStyleInvalidation()) | 1626 if (!childNeedsStyleInvalidation()) |
| 1626 return; | 1627 return; |
| 1627 TRACE_EVENT0("blink", "Document::updateStyleInvalidationIfNeeded"); | 1628 TRACE_EVENT0("blink", "Document::updateStyleInvalidationIfNeeded"); |
| 1628 styleEngine().styleInvalidator().invalidate(*this); | 1629 styleEngine().styleInvalidator().invalidate(*this); |
| 1629 } | 1630 } |
| 1630 | 1631 |
| 1631 void Document::setupFontBuilder(ComputedStyle& documentStyle) { | 1632 void Document::setupFontBuilder(ComputedStyle& documentStyle) { |
| 1632 FontBuilder fontBuilder(*this); | 1633 FontBuilder fontBuilder(*this); |
| 1633 CSSFontSelector* selector = styleEngine().fontSelector(); | 1634 CSSFontSelector* selector = styleEngine().fontSelector(); |
| 1634 fontBuilder.createFontForDocument(selector, documentStyle); | 1635 fontBuilder.createFontForDocument(selector, documentStyle); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1868 | 1869 |
| 1869 unsigned startElementCount = styleEngine().styleForElementCount(); | 1870 unsigned startElementCount = styleEngine().styleForElementCount(); |
| 1870 | 1871 |
| 1871 InspectorInstrumentation::willRecalculateStyle(this); | 1872 InspectorInstrumentation::willRecalculateStyle(this); |
| 1872 PerformanceMonitor::willRecalculateStyle(this); | 1873 PerformanceMonitor::willRecalculateStyle(this); |
| 1873 | 1874 |
| 1874 DocumentAnimations::updateAnimationTimingIfNeeded(*this); | 1875 DocumentAnimations::updateAnimationTimingIfNeeded(*this); |
| 1875 evaluateMediaQueryListIfNeeded(); | 1876 evaluateMediaQueryListIfNeeded(); |
| 1876 updateUseShadowTreesIfNeeded(); | 1877 updateUseShadowTreesIfNeeded(); |
| 1877 updateDistribution(); | 1878 updateDistribution(); |
| 1879 updateActiveStyle(); |
| 1878 updateStyleInvalidationIfNeeded(); | 1880 updateStyleInvalidationIfNeeded(); |
| 1879 | 1881 |
| 1880 // FIXME: We should update style on our ancestor chain before proceeding | 1882 // FIXME: We should update style on our ancestor chain before proceeding |
| 1881 // however doing so currently causes several tests to crash, as | 1883 // however doing so currently causes several tests to crash, as |
| 1882 // LocalFrame::setDocument calls Document::attach before setting the | 1884 // LocalFrame::setDocument calls Document::attach before setting the |
| 1883 // LocalDOMWindow on the LocalFrame, or the SecurityOrigin on the | 1885 // LocalDOMWindow on the LocalFrame, or the SecurityOrigin on the |
| 1884 // document. The attach, in turn resolves style (here) and then when we | 1886 // document. The attach, in turn resolves style (here) and then when we |
| 1885 // resolve style on the parent chain, we may end up re-attaching our | 1887 // resolve style on the parent chain, we may end up re-attaching our |
| 1886 // containing iframe, which when asked HTMLFrameElementBase::isURLAllowed hits | 1888 // containing iframe, which when asked HTMLFrameElementBase::isURLAllowed hits |
| 1887 // a null-dereference due to security code always assuming the document has a | 1889 // a null-dereference due to security code always assuming the document has a |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1910 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateLayoutTree", | 1912 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateLayoutTree", |
| 1911 "elementCount", elementCount); | 1913 "elementCount", elementCount); |
| 1912 | 1914 |
| 1913 #if DCHECK_IS_ON() | 1915 #if DCHECK_IS_ON() |
| 1914 assertLayoutTreeUpdated(*this); | 1916 assertLayoutTreeUpdated(*this); |
| 1915 #endif | 1917 #endif |
| 1916 InspectorInstrumentation::didRecalculateStyle(this); | 1918 InspectorInstrumentation::didRecalculateStyle(this); |
| 1917 PerformanceMonitor::didRecalculateStyle(this); | 1919 PerformanceMonitor::didRecalculateStyle(this); |
| 1918 } | 1920 } |
| 1919 | 1921 |
| 1922 void Document::updateActiveStyle() { |
| 1923 DCHECK(isActive()); |
| 1924 DCHECK(isMainThread()); |
| 1925 TRACE_EVENT0("blink", "Document::updateActiveStyle"); |
| 1926 styleEngine().updateActiveStyle(); |
| 1927 } |
| 1928 |
| 1920 void Document::updateStyle() { | 1929 void Document::updateStyle() { |
| 1921 DCHECK(!view()->shouldThrottleRendering()); | 1930 DCHECK(!view()->shouldThrottleRendering()); |
| 1922 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); | 1931 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); |
| 1923 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Style.UpdateTime"); | 1932 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Style.UpdateTime"); |
| 1924 | 1933 |
| 1925 unsigned initialElementCount = styleEngine().styleForElementCount(); | 1934 unsigned initialElementCount = styleEngine().styleForElementCount(); |
| 1926 | 1935 |
| 1927 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 1936 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
| 1928 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); | 1937 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); |
| 1929 | 1938 |
| (...skipping 4510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6440 } | 6449 } |
| 6441 | 6450 |
| 6442 void showLiveDocumentInstances() { | 6451 void showLiveDocumentInstances() { |
| 6443 WeakDocumentSet& set = liveDocumentSet(); | 6452 WeakDocumentSet& set = liveDocumentSet(); |
| 6444 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6453 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6445 for (Document* document : set) | 6454 for (Document* document : set) |
| 6446 fprintf(stderr, "- Document %p URL: %s\n", document, | 6455 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6447 document->url().getString().utf8().data()); | 6456 document->url().getString().utf8().data()); |
| 6448 } | 6457 } |
| 6449 #endif | 6458 #endif |
| OLD | NEW |