Title: [138639] trunk/Source/WebCore
- Revision
- 138639
- Author
- [email protected]
- Date
- 2013-01-02 13:13:56 -0800 (Wed, 02 Jan 2013)
Log Message
Clean up the loadXXXStyle() idiom in StyleResolver.
https://bugs.webkit.org/show_bug.cgi?id=105903
Reviewed by Darin Adler.
This patch refactors 'loadViewSourceStyle' in order to avoid the
necessity of each call site checking whether the relevant data has
been loaded. The new 'viewSourceStyle' will load the data if required,
and return a pointer which can be used directly.
No new tests, as this refactoring should exhibit no visible change in
behavior.
* css/StyleResolver.cpp:
(WebCore::viewSourceStyle):
Lazily populate the static 'defaultViewSourceStyle' with data. I
haven't removed the outer variable, as it's used directly in
StyleResolver::reportMemoryUsage.
(WebCore::StyleResolver::matchUARules):
(WebCore::StyleResolver::collectFeatures):
Use the new hotness rather than the old, lame method.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (138638 => 138639)
--- trunk/Source/WebCore/ChangeLog 2013-01-02 20:49:53 UTC (rev 138638)
+++ trunk/Source/WebCore/ChangeLog 2013-01-02 21:13:56 UTC (rev 138639)
@@ -1,3 +1,27 @@
+2013-01-02 Mike West <[email protected]>
+
+ Clean up the loadXXXStyle() idiom in StyleResolver.
+ https://bugs.webkit.org/show_bug.cgi?id=105903
+
+ Reviewed by Darin Adler.
+
+ This patch refactors 'loadViewSourceStyle' in order to avoid the
+ necessity of each call site checking whether the relevant data has
+ been loaded. The new 'viewSourceStyle' will load the data if required,
+ and return a pointer which can be used directly.
+
+ No new tests, as this refactoring should exhibit no visible change in
+ behavior.
+
+ * css/StyleResolver.cpp:
+ (WebCore::viewSourceStyle):
+ Lazily populate the static 'defaultViewSourceStyle' with data. I
+ haven't removed the outer variable, as it's used directly in
+ StyleResolver::reportMemoryUsage.
+ (WebCore::StyleResolver::matchUARules):
+ (WebCore::StyleResolver::collectFeatures):
+ Use the new hotness rather than the old, lame method.
+
2013-01-02 Sheriff Bot <[email protected]>
Unreviewed, rolling out r138627.
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (138638 => 138639)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2013-01-02 20:49:53 UTC (rev 138638)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2013-01-02 21:13:56 UTC (rev 138639)
@@ -537,11 +537,13 @@
// No need to initialize quirks sheet yet as there are no quirk rules for elements allowed in simple default style.
}
-static void loadViewSourceStyle()
+static RuleSet* viewSourceStyle()
{
- ASSERT(!defaultViewSourceStyle);
- defaultViewSourceStyle = RuleSet::create().leakPtr();
- defaultViewSourceStyle->addRulesFromSheet(parseUASheet(sourceUserAgentStyleSheet, sizeof(sourceUserAgentStyleSheet)), screenEval());
+ if (!defaultViewSourceStyle) {
+ defaultViewSourceStyle = RuleSet::create().leakPtr();
+ defaultViewSourceStyle->addRulesFromSheet(parseUASheet(sourceUserAgentStyleSheet, sizeof(sourceUserAgentStyleSheet)), screenEval());
+ }
+ return defaultViewSourceStyle;
}
static void ensureDefaultStyleSheetsForElement(Element* element)
@@ -1338,11 +1340,8 @@
matchUARules(result, defaultQuirksStyle);
// If document uses view source styles (in view source mode or in xml viewer mode), then we match rules from the view source style sheet.
- if (document()->isViewSource()) {
- if (!defaultViewSourceStyle)
- loadViewSourceStyle();
- matchUARules(result, defaultViewSourceStyle);
- }
+ if (document()->isViewSource())
+ matchUARules(result, viewSourceStyle());
}
static void setStylesForPaginationMode(Pagination::Mode paginationMode, RenderStyle* style)
@@ -5276,11 +5275,8 @@
// sharing candidates.
m_features.add(defaultStyle->features());
m_features.add(m_authorStyle->features());
- if (document()->isViewSource()) {
- if (!defaultViewSourceStyle)
- loadViewSourceStyle();
- m_features.add(defaultViewSourceStyle->features());
- }
+ if (document()->isViewSource())
+ m_features.add(viewSourceStyle()->features());
if (m_scopeResolver)
m_scopeResolver->collectFeaturesTo(m_features);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes