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()); |