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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index e6f0a2152cfab98a07f826d7dee7798685d4885b..c02b9af14527461626f3cecb0451dbaf32c1933c 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -1619,6 +1619,18 @@ void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
rootDirection = bodyStyle->direction();
}
+ // Resolved rem units are stored in the matched properties cache so we need to make sure to
+ // invalidate the cache if the documentElement needed to reattach or the font size changed
+ // and then trigger a full document recalc. We also need to clear it here since the
+ // call to styleForElement on the body above can cache bad values for rem units if the
+ // documentElement's style was dirty. We could keep track of which elements depend on
+ // rem units like we do for viewport styles, but we assume root font size changes are
+ // rare and just invalidate the cache for now.
+ if (styleEngine()->usesRemUnits() && (documentElement()->needsAttach() || documentElement()->computedStyle()->fontSize() != documentElementStyle->fontSize())) {
+ ensureStyleResolver().invalidateMatchedPropertiesCache();
+ documentElement()->setNeedsStyleRecalc();
+ }
+
RefPtr<RenderStyle> documentStyle = renderView()->style();
if (documentStyle->writingMode() != rootWritingMode || documentStyle->direction() != rootDirection) {
RefPtr<RenderStyle> newStyle = RenderStyle::clone(documentStyle.get());
« 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