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

Unified Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 705783002: Decouple font unit conversion in computeLengthDouble from RenderStyle. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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
Index: Source/core/css/resolver/StyleResolver.cpp
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp
index edcebea5a1767097fc33503f849559530ad1c158..8ffa3da5f3c083ca026f19cea0dd66efe99f56eb 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -589,8 +589,9 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
state.setParentStyle(defaultStyleForElement());
} else {
if (state.parentStyle()) {
- state.setStyle(RenderStyle::create());
- state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
+ RefPtr<RenderStyle> style = RenderStyle::create();
+ style->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
+ state.setStyle(style);
Timothy Loh 2014/11/06 16:24:01 state.setStyle(style.release())?
andersr 2014/11/07 10:43:11 Done.
} else {
state.setStyle(defaultStyleForElement());
state.setParentStyle(RenderStyle::clone(state.style()));
@@ -776,8 +777,9 @@ bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
if (baseRenderStyle) {
state.setStyle(RenderStyle::clone(baseRenderStyle));
} else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) {
- state.setStyle(RenderStyle::create());
- state.style()->inheritFrom(state.parentStyle());
+ RefPtr<RenderStyle> style = RenderStyle::create();
+ style->inheritFrom(state.parentStyle());
+ state.setStyle(style);
Timothy Loh 2014/11/06 16:24:01 style.release()
andersr 2014/11/07 10:43:11 Done.
} else {
state.setStyle(defaultStyleForElement());
state.setParentStyle(RenderStyle::clone(state.style()));
@@ -855,10 +857,11 @@ PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
resetDirectionAndWritingModeOnDocument(document());
StyleResolverState state(document(), document().documentElement()); // m_rootElementStyle will be set to the document style.
- state.setStyle(RenderStyle::create());
+ RefPtr<RenderStyle> style = RenderStyle::create();
const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootElementStyle() : document().renderStyle();
ASSERT(rootElementStyle);
- state.style()->inheritFrom(rootElementStyle);
+ style->inheritFrom(rootElementStyle);
+ state.setStyle(style);
Timothy Loh 2014/11/06 16:24:01 style.release()
andersr 2014/11/07 10:43:11 Done.
PageRuleCollector collector(rootElementStyle, pageIndex);
@@ -906,11 +909,12 @@ void StyleResolver::collectViewportRules()
PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
{
- StyleResolverState state(document(), 0);
- state.setStyle(RenderStyle::create());
- state.fontBuilder().setInitial(state.style()->effectiveZoom());
- state.style()->font().update(document().styleEngine()->fontSelector());
- return state.takeStyle();
+ RefPtr<RenderStyle> style = RenderStyle::create();
+ FontBuilder fontBuilder(document());
+ fontBuilder.setStyle(style.get());
+ fontBuilder.setInitial(style->effectiveZoom());
+ style->font().update(document().styleEngine()->fontSelector());
+ return style;
Timothy Loh 2014/11/06 16:24:01 style.release()
andersr 2014/11/07 10:43:11 Done.
}
PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode)
@@ -926,6 +930,8 @@ PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode)
void StyleResolver::updateFont(StyleResolverState& state)
{
state.fontBuilder().createFont(document().styleEngine()->fontSelector(), state.parentStyle(), state.style());
+ state.setConversionFontSizes(CSSToLengthFontSizes(state.style(), state.rootElementStyle()));
+ state.setConversionZoom(state.style()->effectiveZoom());
}
PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Element* element, unsigned rulesToInclude)
@@ -1419,6 +1425,9 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
// Unfortunately the link status is treated like an inherited property. We need to explicitly restore it.
state.style()->setInsideLink(linkStatus);
+
+ updateFont(state);
Timothy Loh 2014/11/06 16:24:01 This call is for animations, right?
andersr 2014/11/06 16:35:27 Yes.
+
return;
}
applyInheritedOnly = true;

Powered by Google App Engine
This is Rietveld 408576698