Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: Source/core/dom/Document.cpp

Issue 889563002: Make RenderObject::style() return a const object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix a crashers (everything is building!) Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 fontBuilder.setFontDescription(documentStyle->fontDescription()); 1629 fontBuilder.setFontDescription(documentStyle->fontDescription());
1630 RefPtrWillBeRawPtr<CSSFontSelector> selector = m_styleEngine->fontSelector() ; 1630 RefPtrWillBeRawPtr<CSSFontSelector> selector = m_styleEngine->fontSelector() ;
1631 fontBuilder.createFontForDocument(selector, documentStyle); 1631 fontBuilder.createFontForDocument(selector, documentStyle);
1632 } 1632 }
1633 1633
1634 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change) 1634 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
1635 { 1635 {
1636 ASSERT(inStyleRecalc()); 1636 ASSERT(inStyleRecalc());
1637 ASSERT(documentElement()); 1637 ASSERT(documentElement());
1638 1638
1639 RefPtr<RenderStyle> documentElementStyle = documentElement()->renderStyle(); 1639 RefPtr<RenderStyle> documentElementStyle = documentElement()->mutableRenderS tyle();
1640 if (!documentElementStyle || documentElement()->needsStyleRecalc() || change == Force) 1640 if (!documentElementStyle || documentElement()->needsStyleRecalc() || change == Force)
1641 documentElementStyle = ensureStyleResolver().styleForElement(documentEle ment()); 1641 documentElementStyle = ensureStyleResolver().styleForElement(documentEle ment());
1642 1642
1643 WritingMode rootWritingMode = documentElementStyle->writingMode(); 1643 WritingMode rootWritingMode = documentElementStyle->writingMode();
1644 TextDirection rootDirection = documentElementStyle->direction(); 1644 TextDirection rootDirection = documentElementStyle->direction();
1645 1645
1646 HTMLElement* body = this->body(); 1646 HTMLElement* body = this->body();
1647 RefPtr<RenderStyle> bodyStyle; 1647 RefPtr<RenderStyle> bodyStyle;
1648 if (body) { 1648 if (body) {
1649 bodyStyle = body->renderStyle(); 1649 bodyStyle = body->mutableRenderStyle();
1650 if (!bodyStyle || body->needsStyleRecalc() || documentElement()->needsSt yleRecalc() || change == Force) 1650 if (!bodyStyle || body->needsStyleRecalc() || documentElement()->needsSt yleRecalc() || change == Force)
1651 bodyStyle = ensureStyleResolver().styleForElement(body, documentElem entStyle.get()); 1651 bodyStyle = ensureStyleResolver().styleForElement(body, documentElem entStyle.get());
1652 rootWritingMode = bodyStyle->writingMode(); 1652 rootWritingMode = bodyStyle->writingMode();
1653 rootDirection = bodyStyle->direction(); 1653 rootDirection = bodyStyle->direction();
1654 } 1654 }
1655 1655
1656 RefPtr<RenderStyle> overflowStyle; 1656 RefPtr<RenderStyle> overflowStyle;
1657 if (Element* element = viewportDefiningElement(documentElementStyle.get())) { 1657 if (Element* element = viewportDefiningElement(documentElementStyle.get())) {
1658 if (element == body) { 1658 if (element == body) {
1659 overflowStyle = bodyStyle; 1659 overflowStyle = bodyStyle;
(...skipping 26 matching lines...) Expand all
1686 overflowX = OAUTO; 1686 overflowX = OAUTO;
1687 if (overflowY == OVISIBLE) 1687 if (overflowY == OVISIBLE)
1688 overflowY = OAUTO; 1688 overflowY = OAUTO;
1689 // Column-gap is (ab)used by the current paged overflow implementation ( in lack of other 1689 // Column-gap is (ab)used by the current paged overflow implementation ( in lack of other
1690 // ways to specify gaps between pages), so we have to propagate it too. 1690 // ways to specify gaps between pages), so we have to propagate it too.
1691 columnGap = overflowStyle->columnGap(); 1691 columnGap = overflowStyle->columnGap();
1692 } 1692 }
1693 1693
1694 WebScrollBlocksOn scrollBlocksOn = documentElementStyle->scrollBlocksOn(); 1694 WebScrollBlocksOn scrollBlocksOn = documentElementStyle->scrollBlocksOn();
1695 1695
1696 RefPtr<RenderStyle> documentStyle = renderView()->style(); 1696 RefPtr<RenderStyle> documentStyle = renderView()->deprecatedMutableStyle();
1697 if (documentStyle->writingMode() != rootWritingMode 1697 if (documentStyle->writingMode() != rootWritingMode
1698 || documentStyle->direction() != rootDirection 1698 || documentStyle->direction() != rootDirection
1699 || documentStyle->overflowX() != overflowX 1699 || documentStyle->overflowX() != overflowX
1700 || documentStyle->overflowY() != overflowY 1700 || documentStyle->overflowY() != overflowY
1701 || documentStyle->columnGap() != columnGap 1701 || documentStyle->columnGap() != columnGap
1702 || documentStyle->scrollBlocksOn() != scrollBlocksOn) { 1702 || documentStyle->scrollBlocksOn() != scrollBlocksOn) {
1703 RefPtr<RenderStyle> newStyle = RenderStyle::clone(documentStyle.get()); 1703 RefPtr<RenderStyle> newStyle = RenderStyle::clone(documentStyle.get());
1704 newStyle->setWritingMode(rootWritingMode); 1704 newStyle->setWritingMode(rootWritingMode);
1705 newStyle->setDirection(rootDirection); 1705 newStyle->setDirection(rootDirection);
1706 newStyle->setColumnGap(columnGap); 1706 newStyle->setColumnGap(columnGap);
1707 newStyle->setOverflowX(overflowX); 1707 newStyle->setOverflowX(overflowX);
1708 newStyle->setOverflowY(overflowY); 1708 newStyle->setOverflowY(overflowY);
1709 newStyle->setScrollBlocksOn(scrollBlocksOn); 1709 newStyle->setScrollBlocksOn(scrollBlocksOn);
1710 renderView()->setStyle(newStyle); 1710 renderView()->setStyle(newStyle);
1711 setupFontBuilder(newStyle.get()); 1711 setupFontBuilder(newStyle.get());
1712 } 1712 }
1713 1713
1714 if (body) { 1714 if (body) {
1715 if (RenderStyle* style = body->renderStyle()) { 1715 if (const RenderStyle* style = body->renderStyle()) {
1716 if (style->direction() != rootDirection || style->writingMode() != r ootWritingMode) 1716 if (style->direction() != rootDirection || style->writingMode() != r ootWritingMode)
1717 body->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonF orTracing::create(StyleChangeReason::WritingModeChange)); 1717 body->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonF orTracing::create(StyleChangeReason::WritingModeChange));
1718 } 1718 }
1719 } 1719 }
1720 1720
1721 if (RenderStyle* style = documentElement()->renderStyle()) { 1721 if (const RenderStyle* style = documentElement()->renderStyle()) {
1722 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode) 1722 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode)
1723 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChan geReasonForTracing::create(StyleChangeReason::WritingModeChange)); 1723 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChan geReasonForTracing::create(StyleChangeReason::WritingModeChange));
1724 } 1724 }
1725 } 1725 }
1726 1726
1727 void Document::updateRenderTree(StyleRecalcChange change) 1727 void Document::updateRenderTree(StyleRecalcChange change)
1728 { 1728 {
1729 ASSERT(isMainThread()); 1729 ASSERT(isMainThread());
1730 1730
1731 ScriptForbiddenScope forbidScript; 1731 ScriptForbiddenScope forbidScript;
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 2416
2417 HTMLHeadElement* Document::head() const 2417 HTMLHeadElement* Document::head() const
2418 { 2418 {
2419 Node* de = documentElement(); 2419 Node* de = documentElement();
2420 if (!de) 2420 if (!de)
2421 return 0; 2421 return 0;
2422 2422
2423 return Traversal<HTMLHeadElement>::firstChild(*de); 2423 return Traversal<HTMLHeadElement>::firstChild(*de);
2424 } 2424 }
2425 2425
2426 Element* Document::viewportDefiningElement(RenderStyle* rootStyle) const 2426 Element* Document::viewportDefiningElement(const RenderStyle* rootStyle) const
2427 { 2427 {
2428 // If a BODY element sets non-visible overflow, it is to be propagated to th e viewport, as long 2428 // If a BODY element sets non-visible overflow, it is to be propagated to th e viewport, as long
2429 // as the following conditions are all met: 2429 // as the following conditions are all met:
2430 // (1) The root element is HTML. 2430 // (1) The root element is HTML.
2431 // (2) It is the primary BODY element (we only assert for this, expecting ca llers to behave). 2431 // (2) It is the primary BODY element (we only assert for this, expecting ca llers to behave).
2432 // (3) The root element has visible overflow. 2432 // (3) The root element has visible overflow.
2433 // Otherwise it's the root element's properties that are to be propagated. 2433 // Otherwise it's the root element's properties that are to be propagated.
2434 Element* rootElement = documentElement(); 2434 Element* rootElement = documentElement();
2435 Element* bodyElement = body(); 2435 Element* bodyElement = body();
2436 if (!rootElement) 2436 if (!rootElement)
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after
4212 } 4212 }
4213 4213
4214 m_encodingData = newData; 4214 m_encodingData = newData;
4215 4215
4216 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is sues/detail?id=319643 4216 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is sues/detail?id=319643
4217 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering( ); 4217 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering( );
4218 if (shouldUseVisualOrdering != m_visuallyOrdered) { 4218 if (shouldUseVisualOrdering != m_visuallyOrdered) {
4219 m_visuallyOrdered = shouldUseVisualOrdering; 4219 m_visuallyOrdered = shouldUseVisualOrdering;
4220 // FIXME: How is possible to not have a renderer here? 4220 // FIXME: How is possible to not have a renderer here?
4221 if (renderView()) 4221 if (renderView())
4222 renderView()->style()->setRTLOrdering(m_visuallyOrdered ? VisualOrde r : LogicalOrder); 4222 renderView()->deprecatedMutableStyle()->setRTLOrdering(m_visuallyOrd ered ? VisualOrder : LogicalOrder);
4223 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre ate(StyleChangeReason::VisuallyOrdered)); 4223 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre ate(StyleChangeReason::VisuallyOrdered));
4224 } 4224 }
4225 } 4225 }
4226 4226
4227 KURL Document::completeURL(const String& url) const 4227 KURL Document::completeURL(const String& url) const
4228 { 4228 {
4229 return completeURLWithOverride(url, m_baseURL); 4229 return completeURLWithOverride(url, m_baseURL);
4230 } 4230 }
4231 4231
4232 KURL Document::completeURLWithOverride(const String& url, const KURL& baseURLOve rride) const 4232 KURL Document::completeURLWithOverride(const String& url, const KURL& baseURLOve rride) const
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after
5778 #ifndef NDEBUG 5778 #ifndef NDEBUG
5779 using namespace blink; 5779 using namespace blink;
5780 void showLiveDocumentInstances() 5780 void showLiveDocumentInstances()
5781 { 5781 {
5782 WeakDocumentSet& set = liveDocumentSet(); 5782 WeakDocumentSet& set = liveDocumentSet();
5783 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5783 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5784 for (Document* document : set) 5784 for (Document* document : set)
5785 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5785 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5786 } 5786 }
5787 #endif 5787 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698