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

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 assertions. 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..bdad2520f3986bba3977eb318da9d752405b70b2 100644
--- a/Source/core/css/resolver/StyleResolverState.cpp
+++ b/Source/core/css/resolver/StyleResolverState.cpp
@@ -29,20 +29,36 @@
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)
{
- if (!parentStyle && m_elementContext.parentNode())
- m_parentStyle = m_elementContext.parentNode()->renderStyle();
+ ASSERT(this->style());
+ ASSERT(this->parentStyle());
+ 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)
+{
+ ASSERT(this->style());
+ ASSERT(this->parentStyle());
ASSERT(document.isActive());
m_elementStyleResources.setDeviceScaleFactor(document.frameHost()->deviceScaleFactor());
}

Powered by Google App Engine
This is Rietveld 408576698