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

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

Issue 686723002: Improve RAII of StyleResolverState. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix unused var + minor diff noise. Created 6 years, 2 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
Index: Source/core/css/resolver/StyleResolverState.cpp
diff --git a/Source/core/css/resolver/StyleResolverState.cpp b/Source/core/css/resolver/StyleResolverState.cpp
index b71a93d26e0c468e25faaac22a6ba6c964247016..abb4517b9c091065279b9c9375219018385c39d5 100644
--- a/Source/core/css/resolver/StyleResolverState.cpp
+++ b/Source/core/css/resolver/StyleResolverState.cpp
@@ -29,20 +29,32 @@
namespace blink {
-StyleResolverState::StyleResolverState(Document& document, Element* element, RenderStyle* parentStyle)
- : m_elementContext(element ? ElementResolveContext(*element) : ElementResolveContext(document))
+StyleResolverState::StyleResolverState(Document& document, const ElementResolveContext& elementContext, PassRefPtr<RenderStyle> style, PassRefPtr<RenderStyle> parentStyle)
+ : m_elementContext(elementContext)
, m_document(document)
- , m_style(nullptr)
- , m_cssToLengthConversionData(0, rootElementStyle(), document.renderView())
- , m_parentStyle(parentStyle)
+ , m_style(style)
+ , m_cssToLengthConversionData(m_style.get(), rootElementStyle(), document.renderView())
+ , m_parentStyle(parentStyle ? parentStyle : RenderStyle::clone(m_style.get()))
, m_applyPropertyToRegularStyle(true)
, m_applyPropertyToVisitedLinkStyle(false)
- , m_fontBuilder(document)
+ , m_fontBuilder(document, m_style.get())
, m_styleMap(*this, m_elementStyleResources)
{
rune 2014/10/30 15:23:50 ASSERT(style) ASSERT(parentStyle) ?
andersr 2014/10/31 13:02:15 Done.
- if (!parentStyle && m_elementContext.parentNode())
- m_parentStyle = m_elementContext.parentNode()->renderStyle();
+ ASSERT(document.isActive());
+ m_elementStyleResources.setDeviceScaleFactor(document.frameHost()->deviceScaleFactor());
+}
+StyleResolverState::StyleResolverState(Document& document, Element* element, PassRefPtr<RenderStyle> style, RenderStyle* parentStyle)
+ : m_elementContext(element ? ElementResolveContext(*element, parentStyle) : ElementResolveContext(document))
+ , m_document(document)
+ , m_style(style)
+ , m_cssToLengthConversionData(m_style.get(), rootElementStyle(), document.renderView())
+ , m_parentStyle(m_elementContext.parentStyle() ? m_elementContext.parentStyle() : RenderStyle::clone(m_style.get()))
+ , m_applyPropertyToRegularStyle(true)
+ , m_applyPropertyToVisitedLinkStyle(false)
+ , m_fontBuilder(document, m_style.get())
+ , m_styleMap(*this, m_elementStyleResources)
+{
rune 2014/10/30 15:23:50 ASSERT(style) ASSERT(parentStyle) ?
andersr 2014/10/31 13:02:15 Done.
ASSERT(document.isActive());
m_elementStyleResources.setDeviceScaleFactor(document.frameHost()->deviceScaleFactor());
}

Powered by Google App Engine
This is Rietveld 408576698