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

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

Issue 147903002: CSS rem units should properly resolve on <body> (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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
« no previous file with comments | « LayoutTests/fast/css/rem-units-body-expected.txt ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 if (body) { 1612 if (body) {
1613 RefPtr<RenderStyle> bodyStyle = body->renderStyle(); 1613 RefPtr<RenderStyle> bodyStyle = body->renderStyle();
1614 if (!bodyStyle || body->needsStyleRecalc() || documentElement()->needsSt yleRecalc() || change == Force) 1614 if (!bodyStyle || body->needsStyleRecalc() || documentElement()->needsSt yleRecalc() || change == Force)
1615 bodyStyle = ensureStyleResolver().styleForElement(body, documentElem entStyle.get()); 1615 bodyStyle = ensureStyleResolver().styleForElement(body, documentElem entStyle.get());
1616 if (!writingModeSetOnDocumentElement()) 1616 if (!writingModeSetOnDocumentElement())
1617 rootWritingMode = bodyStyle->writingMode(); 1617 rootWritingMode = bodyStyle->writingMode();
1618 if (!directionSetOnDocumentElement()) 1618 if (!directionSetOnDocumentElement())
1619 rootDirection = bodyStyle->direction(); 1619 rootDirection = bodyStyle->direction();
1620 } 1620 }
1621 1621
1622 // Resolved rem units are stored in the matched properties cache so we need to make sure to
1623 // invalidate the cache if the documentElement needed to reattach or the fon t size changed
1624 // and then trigger a full document recalc. We also need to clear it here si nce the
1625 // call to styleForElement on the body above can cache bad values for rem un its if the
1626 // documentElement's style was dirty. We could keep track of which elements depend on
1627 // rem units like we do for viewport styles, but we assume root font size ch anges are
1628 // rare and just invalidate the cache for now.
1629 if (styleEngine()->usesRemUnits() && (documentElement()->needsAttach() || do cumentElement()->computedStyle()->fontSize() != documentElementStyle->fontSize() )) {
1630 ensureStyleResolver().invalidateMatchedPropertiesCache();
1631 documentElement()->setNeedsStyleRecalc();
1632 }
1633
1622 RefPtr<RenderStyle> documentStyle = renderView()->style(); 1634 RefPtr<RenderStyle> documentStyle = renderView()->style();
1623 if (documentStyle->writingMode() != rootWritingMode || documentStyle->direct ion() != rootDirection) { 1635 if (documentStyle->writingMode() != rootWritingMode || documentStyle->direct ion() != rootDirection) {
1624 RefPtr<RenderStyle> newStyle = RenderStyle::clone(documentStyle.get()); 1636 RefPtr<RenderStyle> newStyle = RenderStyle::clone(documentStyle.get());
1625 newStyle->setWritingMode(rootWritingMode); 1637 newStyle->setWritingMode(rootWritingMode);
1626 newStyle->setDirection(rootDirection); 1638 newStyle->setDirection(rootDirection);
1627 renderView()->setStyle(newStyle); 1639 renderView()->setStyle(newStyle);
1628 setStyleDependentState(newStyle.get()); 1640 setStyleDependentState(newStyle.get());
1629 } 1641 }
1630 1642
1631 if (body) { 1643 if (body) {
(...skipping 3663 matching lines...) Expand 10 before | Expand all | Expand 10 after
5295 if (!page->focusController().isActive() || !page->focusController().isFocuse d()) 5307 if (!page->focusController().isActive() || !page->focusController().isFocuse d())
5296 return false; 5308 return false;
5297 if (Frame* focusedFrame = page->focusController().focusedFrame()) { 5309 if (Frame* focusedFrame = page->focusController().focusedFrame()) {
5298 if (focusedFrame->tree().isDescendantOf(frame())) 5310 if (focusedFrame->tree().isDescendantOf(frame()))
5299 return true; 5311 return true;
5300 } 5312 }
5301 return false; 5313 return false;
5302 } 5314 }
5303 5315
5304 } // namespace WebCore 5316 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/rem-units-body-expected.txt ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698