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 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1361 | 1361 |
1362 return documentElement(); | 1362 return documentElement(); |
1363 } | 1363 } |
1364 | 1364 |
1365 return body(); | 1365 return body(); |
1366 } | 1366 } |
1367 | 1367 |
1368 // We use HashMap::set over HashMap::add here as we want to | 1368 // We use HashMap::set over HashMap::add here as we want to |
1369 // replace the ComputedStyle but not the Element if the Element is | 1369 // replace the ComputedStyle but not the Element if the Element is |
1370 // already present. | 1370 // already present. |
1371 void Document::addStyleReattachData(Element& element, | 1371 void Document::addStyleReattachData(Node& node, |
1372 StyleReattachData& styleReattachData) { | 1372 StyleReattachData& styleReattachData) { |
1373 m_styleReattachDataMap.set(&element, styleReattachData); | 1373 m_styleReattachDataMap.set(&node, styleReattachData); |
1374 } | 1374 } |
1375 | 1375 |
1376 StyleReattachData Document::getStyleReattachData(Element& element) { | 1376 StyleReattachData Document::getStyleReattachData(Node& node) { |
1377 return m_styleReattachDataMap.get(&element); | 1377 return m_styleReattachDataMap.get(&node); |
1378 } | 1378 } |
1379 | 1379 |
1380 /* | 1380 /* |
1381 * Performs three operations: | 1381 * Performs three operations: |
1382 * 1. Convert control characters to spaces | 1382 * 1. Convert control characters to spaces |
1383 * 2. Trim leading and trailing spaces | 1383 * 2. Trim leading and trailing spaces |
1384 * 3. Collapse internal whitespace. | 1384 * 3. Collapse internal whitespace. |
1385 */ | 1385 */ |
1386 template <typename CharacterType> | 1386 template <typename CharacterType> |
1387 static inline String canonicalizedTitle(Document* document, | 1387 static inline String canonicalizedTitle(Document* document, |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1793 | 1793 |
1794 // Resolved rem units are stored in the matched properties cache so we need to | 1794 // Resolved rem units are stored in the matched properties cache so we need to |
1795 // make sure to invalidate the cache if the documentElement needed to reattach | 1795 // make sure to invalidate the cache if the documentElement needed to reattach |
1796 // or the font size changed and then trigger a full document recalc. We also | 1796 // or the font size changed and then trigger a full document recalc. We also |
1797 // need to clear it here since the call to styleForElement on the body above | 1797 // need to clear it here since the call to styleForElement on the body above |
1798 // can cache bad values for rem units if the documentElement's style was | 1798 // can cache bad values for rem units if the documentElement's style was |
1799 // dirty. We could keep track of which elements depend on rem units like we do | 1799 // dirty. We could keep track of which elements depend on rem units like we do |
1800 // for viewport styles, but we assume root font size changes are rare and just | 1800 // for viewport styles, but we assume root font size changes are rare and just |
1801 // invalidate the cache for now. | 1801 // invalidate the cache for now. |
1802 if (styleEngine().usesRemUnits() && | 1802 if (styleEngine().usesRemUnits() && |
1803 (documentElement()->needsAttach() || | 1803 (documentElement()->needsReattachLayoutTree() || |
1804 !documentElement()->computedStyle() || | 1804 !documentElement()->computedStyle() || |
1805 documentElement()->computedStyle()->fontSize() != | 1805 documentElement()->computedStyle()->fontSize() != |
1806 documentElementStyle->fontSize())) { | 1806 documentElementStyle->fontSize())) { |
1807 ensureStyleResolver().invalidateMatchedPropertiesCache(); | 1807 ensureStyleResolver().invalidateMatchedPropertiesCache(); |
1808 documentElement()->setNeedsStyleRecalc( | 1808 documentElement()->setNeedsStyleRecalc( |
1809 SubtreeStyleChange, | 1809 SubtreeStyleChange, |
1810 StyleChangeReasonForTracing::create(StyleChangeReason::FontSizeChange)); | 1810 StyleChangeReasonForTracing::create(StyleChangeReason::FontSizeChange)); |
1811 } | 1811 } |
1812 | 1812 |
1813 EOverflowAnchor overflowAnchor = AnchorAuto; | 1813 EOverflowAnchor overflowAnchor = AnchorAuto; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2044 StyleResolver& resolver = ensureStyleResolver(); | 2044 StyleResolver& resolver = ensureStyleResolver(); |
2045 | 2045 |
2046 bool shouldRecordStats; | 2046 bool shouldRecordStats; |
2047 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink,blink_style", &shouldRecordStats); | 2047 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink,blink_style", &shouldRecordStats); |
2048 styleEngine().setStatsEnabled(shouldRecordStats); | 2048 styleEngine().setStatsEnabled(shouldRecordStats); |
2049 | 2049 |
2050 if (Element* documentElement = this->documentElement()) { | 2050 if (Element* documentElement = this->documentElement()) { |
2051 inheritHtmlAndBodyElementStyles(change); | 2051 inheritHtmlAndBodyElementStyles(change); |
2052 if (documentElement->shouldCallRecalcStyle(change)) | 2052 if (documentElement->shouldCallRecalcStyle(change)) |
2053 documentElement->recalcStyle(change); | 2053 documentElement->recalcStyle(change); |
2054 DCHECK(!documentElement->needsStyleRecalc()); | |
2055 DCHECK(!documentElement->childNeedsStyleRecalc()); | |
2056 if (documentElement->needsReattachLayoutTree() || | |
2057 documentElement->childNeedsReattachLayoutTree()) | |
2058 documentElement->rebuildLayoutTree(); | |
2054 } | 2059 } |
2055 | 2060 |
2056 view()->recalcOverflowAfterStyleChange(); | 2061 view()->recalcOverflowAfterStyleChange(); |
2057 | 2062 |
2058 // Only retain the HashMap for the duration of StyleRecalc and | 2063 // Only retain the HashMap for the duration of StyleRecalc and |
2059 // LayoutTreeConstruction. | 2064 // LayoutTreeConstruction. |
2060 m_styleReattachDataMap.clear(); | 2065 m_styleReattachDataMap.clear(); |
2061 clearChildNeedsStyleRecalc(); | 2066 clearChildNeedsStyleRecalc(); |
2062 clearChildNeedsReattachLayoutTree(); | 2067 clearChildNeedsReattachLayoutTree(); |
2063 | 2068 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2361 DCHECK_EQ(m_lifecycle.state(), DocumentLifecycle::Inactive); | 2366 DCHECK_EQ(m_lifecycle.state(), DocumentLifecycle::Inactive); |
2362 DCHECK(!m_axObjectCache || this != &axObjectCacheOwner()); | 2367 DCHECK(!m_axObjectCache || this != &axObjectCacheOwner()); |
2363 | 2368 |
2364 m_layoutView = new LayoutView(this); | 2369 m_layoutView = new LayoutView(this); |
2365 setLayoutObject(m_layoutView); | 2370 setLayoutObject(m_layoutView); |
2366 | 2371 |
2367 m_layoutView->setIsInWindow(true); | 2372 m_layoutView->setIsInWindow(true); |
2368 m_layoutView->setStyle(StyleResolver::styleForDocument(*this)); | 2373 m_layoutView->setStyle(StyleResolver::styleForDocument(*this)); |
2369 m_layoutView->compositor()->setNeedsCompositingUpdate( | 2374 m_layoutView->compositor()->setNeedsCompositingUpdate( |
2370 CompositingUpdateAfterCompositingInputChange); | 2375 CompositingUpdateAfterCompositingInputChange); |
2376 setNeedsReattachLayoutTree(); | |
nainar
2016/11/29 06:13:39
This is as ContainerNode::attachLayoutTree() asser
| |
2377 ContainerNode::attachLayoutTree(); | |
2371 | 2378 |
2372 ContainerNode::attachLayoutTree(); | 2379 DCHECK(!needsReattachLayoutTree()); |
2373 | 2380 |
2374 // The TextAutosizer can't update layout view info while the Document is | 2381 // The TextAutosizer can't update layout view info while the Document is |
2375 // detached, so update now in case anything changed. | 2382 // detached, so update now in case anything changed. |
2376 if (TextAutosizer* autosizer = textAutosizer()) | 2383 if (TextAutosizer* autosizer = textAutosizer()) |
2377 autosizer->updatePageInfo(); | 2384 autosizer->updatePageInfo(); |
2378 | 2385 |
2379 m_frame->documentAttached(); | 2386 m_frame->documentAttached(); |
2380 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); | 2387 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); |
2381 | 2388 |
2382 if (view()) | 2389 if (view()) |
(...skipping 4163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6546 } | 6553 } |
6547 | 6554 |
6548 void showLiveDocumentInstances() { | 6555 void showLiveDocumentInstances() { |
6549 WeakDocumentSet& set = liveDocumentSet(); | 6556 WeakDocumentSet& set = liveDocumentSet(); |
6550 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6557 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6551 for (Document* document : set) | 6558 for (Document* document : set) |
6552 fprintf(stderr, "- Document %p URL: %s\n", document, | 6559 fprintf(stderr, "- Document %p URL: %s\n", document, |
6553 document->url().getString().utf8().data()); | 6560 document->url().getString().utf8().data()); |
6554 } | 6561 } |
6555 #endif | 6562 #endif |
OLD | NEW |