Diff
Modified: trunk/Source/WebCore/ChangeLog (157671 => 157672)
--- trunk/Source/WebCore/ChangeLog 2013-10-19 16:41:44 UTC (rev 157671)
+++ trunk/Source/WebCore/ChangeLog 2013-10-19 16:48:42 UTC (rev 157672)
@@ -1,3 +1,13 @@
+2013-10-19 Andreas Kling <[email protected]>
+
+ StyleResolver should deal in PassRef<RenderStyle> where possible.
+ <https://webkit.org/b/123061>
+
+ Make StyleResolver functions that returned or took RenderStyles
+ by PassRefPtr use PassRef instead where possible.
+
+ Reviewed by Anders Carlsson.
+
2013-10-19 Brady Eidson <[email protected]>
Global rename of the class "IDBBackingStore" to "IDBBackingStoreLevelDB"
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (157671 => 157672)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2013-10-19 16:41:44 UTC (rev 157671)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2013-10-19 16:48:42 UTC (rev 157672)
@@ -783,7 +783,7 @@
return parentNode && parentNode->isShadowRoot();
}
-PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderStyle* defaultParent,
+PassRef<RenderStyle> StyleResolver::styleForElement(Element* element, RenderStyle* defaultParent,
StyleSharingBehavior sharingBehavior, RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling)
{
// Once an element has a renderer, we don't try to destroy it, since otherwise the renderer
@@ -795,17 +795,16 @@
s_styleNotYetAvailable->font().update(m_fontSelector);
}
element->document().setHasNodesWithPlaceholderStyle();
- return s_styleNotYetAvailable;
+ return *s_styleNotYetAvailable;
}
State& state = m_state;
initElement(element);
state.initForStyleResolve(document(), element, defaultParent, regionForStyling);
if (sharingBehavior == AllowStyleSharing) {
- RenderStyle* sharedStyle = locateSharedStyle();
- if (sharedStyle) {
+ if (RenderStyle* sharedStyle = locateSharedStyle()) {
state.clear();
- return sharedStyle;
+ return *sharedStyle;
}
}
@@ -855,7 +854,7 @@
return state.takeStyle();
}
-PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle* elementStyle, const StyleKeyframe* keyframe, KeyframeValue& keyframeValue)
+PassRef<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle* elementStyle, const StyleKeyframe* keyframe, KeyframeValue& keyframeValue)
{
MatchResult result;
result.addMatchedProperties(keyframe->properties());
@@ -1021,7 +1020,7 @@
return state.takeStyle();
}
-PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
+PassRef<RenderStyle> StyleResolver::styleForPage(int pageIndex)
{
m_state.initForStyleResolve(document(), document().documentElement()); // m_rootElementStyle will be set to the document style.
@@ -1057,7 +1056,7 @@
return m_state.takeStyle();
}
-PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
+PassRef<RenderStyle> StyleResolver::defaultStyleForElement()
{
m_state.setStyle(RenderStyle::create());
// Make sure our fonts are initialized if we don't inherit them from our parent style.
@@ -1778,7 +1777,7 @@
{
initElement(0);
m_state.initForStyleResolve(document(), 0, style);
- m_state.setStyle(style);
+ m_state.setStyle(*style);
applyPropertyToCurrentStyle(id, value);
}
Modified: trunk/Source/WebCore/css/StyleResolver.h (157671 => 157672)
--- trunk/Source/WebCore/css/StyleResolver.h 2013-10-19 16:41:44 UTC (rev 157671)
+++ trunk/Source/WebCore/css/StyleResolver.h 2013-10-19 16:48:42 UTC (rev 157672)
@@ -167,15 +167,15 @@
void addHostRule(StyleRuleHost* rule, bool hasDocumentSecurityOrigin, const ContainerNode* scope) { ensureScopeResolver()->addHostRule(rule, hasDocumentSecurityOrigin, scope); }
#endif
- PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, StyleSharingBehavior = AllowStyleSharing,
+ PassRef<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, StyleSharingBehavior = AllowStyleSharing,
RuleMatchingBehavior = MatchAllRules, RenderRegion* regionForStyling = 0);
void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&);
PassRefPtr<RenderStyle> pseudoStyleForElement(Element*, const PseudoStyleRequest&, RenderStyle* parentStyle);
- PassRefPtr<RenderStyle> styleForPage(int pageIndex);
- PassRefPtr<RenderStyle> defaultStyleForElement();
+ PassRef<RenderStyle> styleForPage(int pageIndex);
+ PassRef<RenderStyle> defaultStyleForElement();
RenderStyle* style() const { return m_state.style(); }
RenderStyle* parentStyle() const { return m_state.parentStyle(); }
@@ -212,7 +212,7 @@
StyledElement* findSiblingForStyleSharing(Node*, unsigned& count) const;
bool canShareStyleWithElement(StyledElement*) const;
- PassRefPtr<RenderStyle> styleForKeyframe(const RenderStyle*, const StyleKeyframe*, KeyframeValue&);
+ PassRef<RenderStyle> styleForKeyframe(const RenderStyle*, const StyleKeyframe*, KeyframeValue&);
public:
// These methods will give back the set of rules that matched for a given element (or a pseudo-element).
@@ -420,12 +420,12 @@
Document& document() const { return m_element->document(); }
Element* element() const { return m_element; }
StyledElement* styledElement() const { return m_styledElement; }
- void setStyle(PassRefPtr<RenderStyle> style) { m_style = style; }
+ void setStyle(PassRef<RenderStyle> style) { m_style = std::move(style); }
RenderStyle* style() const { return m_style.get(); }
- PassRefPtr<RenderStyle> takeStyle() { return m_style.release(); }
+ PassRef<RenderStyle> takeStyle() { return m_style.releaseNonNull(); }
const ContainerNode* parentNode() const { return m_parentNode; }
- void setParentStyle(PassRefPtr<RenderStyle> parentStyle) { m_parentStyle = parentStyle; }
+ void setParentStyle(PassRef<RenderStyle> parentStyle) { m_parentStyle = std::move(parentStyle); }
RenderStyle* parentStyle() const { return m_parentStyle.get(); }
RenderStyle* rootElementStyle() const { return m_rootElementStyle; }
Modified: trunk/Source/WebCore/dom/Document.cpp (157671 => 157672)
--- trunk/Source/WebCore/dom/Document.cpp 2013-10-19 16:41:44 UTC (rev 157671)
+++ trunk/Source/WebCore/dom/Document.cpp 2013-10-19 16:48:42 UTC (rev 157672)
@@ -1852,7 +1852,8 @@
bool Document::isPageBoxVisible(int pageIndex)
{
- return ensureStyleResolver().styleForPage(pageIndex)->visibility() != HIDDEN; // display property doesn't apply to @page.
+ Ref<RenderStyle> pageStyle(ensureStyleResolver().styleForPage(pageIndex));
+ return pageStyle->visibility() != HIDDEN; // display property doesn't apply to @page.
}
void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft)