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

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

Issue 686723002: Improve RAII of StyleResolverState. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: When baseRenderStyle!=0: 1) don't inherit, and 2) use defaultStyleForElement as fallback parent. 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.h
diff --git a/Source/core/css/resolver/StyleResolverState.h b/Source/core/css/resolver/StyleResolverState.h
index 10b02d855fcb197cb62e8f8ed6a98e1fa566cd5a..08e6acc161ba0287a2041331b781fc31b3bf45ef 100644
--- a/Source/core/css/resolver/StyleResolverState.h
+++ b/Source/core/css/resolver/StyleResolverState.h
@@ -45,13 +45,14 @@ class StyleResolverState {
STACK_ALLOCATED();
WTF_MAKE_NONCOPYABLE(StyleResolverState);
public:
- StyleResolverState(Document&, Element*, RenderStyle* parentStyle = 0);
+ StyleResolverState(const ElementResolveContext&);
+ StyleResolverState(Document&, Element*, PassRefPtr<RenderStyle>, RenderStyle* parentStyle = nullptr);
~StyleResolverState();
- // In FontFaceSet and CanvasRenderingContext2D, we don't have an element to grab the document from.
- // This is why we have to store the document separately.
- Document& document() const { return *m_document; }
+ static PassRefPtr<RenderStyle> defaultStyleForElement(Document&);
+
// These are all just pass-through methods to ElementResolveContext.
+ Document& document() const { return m_elementContext.document(); }
Element* element() const { return m_elementContext.element(); }
const ContainerNode* parentNode() const { return m_elementContext.parentNode(); }
const RenderStyle* rootElementStyle() const { return m_elementContext.rootElementStyle(); }
@@ -60,12 +61,6 @@ public:
const ElementResolveContext& elementContext() const { return m_elementContext; }
- void setStyle(PassRefPtr<RenderStyle> style)
- {
- m_style = style;
- m_cssToLengthConversionData.setStyle(m_style.get());
- m_fontBuilder.setStyle(m_style.get());
- }
const RenderStyle* style() const { return m_style.get(); }
RenderStyle* style() { return m_style.get(); }
PassRefPtr<RenderStyle> takeStyle() { return m_style.release(); }
@@ -76,7 +71,6 @@ public:
const CSSAnimationUpdate* animationUpdate() { return m_animationUpdate.get(); }
PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> takeAnimationUpdate();
- void setParentStyle(PassRefPtr<RenderStyle> parentStyle) { m_parentStyle = parentStyle; }
const RenderStyle* parentStyle() const { return m_parentStyle.get(); }
RenderStyle* parentStyle() { return m_parentStyle.get(); }
@@ -93,9 +87,6 @@ public:
// Holds all attribute names found while applying "content" properties that contain an "attr()" value.
Vector<AtomicString>& contentAttrValues() { return m_contentAttrValues; }
- void setLineHeightValue(CSSValue* value) { m_lineHeightValue = value; }
- CSSValue* lineHeightValue() { return m_lineHeightValue; }
-
void cacheUserAgentBorderAndBackground()
{
// RenderTheme only needs the cached style if it has an appearance,
@@ -137,7 +128,6 @@ public:
private:
ElementResolveContext m_elementContext;
- RawPtrWillBeMember<Document> m_document;
// m_style is the primary output for each element's style resolve.
RefPtr<RenderStyle> m_style;
@@ -153,8 +143,6 @@ private:
bool m_applyPropertyToRegularStyle;
bool m_applyPropertyToVisitedLinkStyle;
- RawPtrWillBeMember<CSSValue> m_lineHeightValue;
-
FontBuilder m_fontBuilder;
OwnPtr<CachedUAStyle> m_cachedUAStyle;

Powered by Google App Engine
This is Rietveld 408576698