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

Unified Diff: third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp

Issue 2552893006: Move pure functions in CSSComputedStyleDeclaration.cpp into their own private namespace. (Closed)
Patch Set: Remove extra static keywords Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp b/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp
index 84dc880550e34b7967c20f9b6bf99ebe737f8d36..9de792e16fe00fc1835b379c5e855c2e6f77904b 100644
--- a/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp
+++ b/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp
@@ -45,10 +45,12 @@
namespace blink {
+namespace {
+
// List of all properties we know how to compute, omitting shorthands.
// NOTE: Do not use this list, use computableProperties() instead
// to respect runtime enabling of CSS properties.
-static const CSSPropertyID staticComputableProperties[] = {
+const CSSPropertyID computedPropertyArray[] = {
CSSPropertyAnimationDelay, CSSPropertyAnimationDirection,
CSSPropertyAnimationDuration, CSSPropertyAnimationFillMode,
CSSPropertyAnimationIterationCount, CSSPropertyAnimationName,
@@ -175,94 +177,29 @@ static const CSSPropertyID staticComputableProperties[] = {
CSSPropertyScrollSnapDestination, CSSPropertyTranslate, CSSPropertyRotate,
CSSPropertyScale, CSSPropertyCaretColor};
-static const Vector<CSSPropertyID>& computableProperties() {
+const Vector<CSSPropertyID>& computableProperties() {
DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
- if (properties.isEmpty())
+ if (properties.isEmpty()) {
CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(
- staticComputableProperties,
- WTF_ARRAY_LENGTH(staticComputableProperties), properties);
- return properties;
-}
-
-CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(
- Node* n,
- bool allowVisitedStyle,
- const String& pseudoElementName)
- : m_node(n),
- m_pseudoElementSpecifier(CSSSelector::parsePseudoId(pseudoElementName)),
- m_allowVisitedStyle(allowVisitedStyle) {}
-
-CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration() {}
-
-String CSSComputedStyleDeclaration::cssText() const {
- StringBuilder result;
- const Vector<CSSPropertyID>& properties = computableProperties();
-
- for (unsigned i = 0; i < properties.size(); i++) {
- if (i)
- result.append(' ');
- result.append(getPropertyName(properties[i]));
- result.append(": ");
- result.append(getPropertyValue(properties[i]));
- result.append(';');
+ computedPropertyArray, WTF_ARRAY_LENGTH(computedPropertyArray),
+ properties);
}
-
- return result.toString();
-}
-
-void CSSComputedStyleDeclaration::setCSSText(const String&,
- ExceptionState& exceptionState) {
- exceptionState.throwDOMException(
- NoModificationAllowedError,
- "These styles are computed, and therefore read-only.");
+ return properties;
}
-static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize) {
+CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize) {
DCHECK_NE(keywordSize, 0);
DCHECK_LE(keywordSize, 8);
return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1);
}
-inline static CSSPrimitiveValue* zoomAdjustedPixelValue(
- double value,
- const ComputedStyle& style) {
+inline CSSPrimitiveValue* zoomAdjustedPixelValue(double value,
+ const ComputedStyle& style) {
return CSSPrimitiveValue::create(adjustFloatForAbsoluteZoom(value, style),
CSSPrimitiveValue::UnitType::Pixels);
}
-const CSSValue*
-CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const {
- if (!m_node)
- return nullptr;
-
- m_node->document().updateStyleAndLayoutIgnorePendingStylesheets();
-
- const ComputedStyle* style =
- m_node->ensureComputedStyle(m_pseudoElementSpecifier);
- if (!style)
- return nullptr;
-
- if (int keywordSize = style->getFontDescription().keywordSize())
- return CSSIdentifierValue::create(
- cssIdentifierForFontSizeKeyword(keywordSize));
-
- return zoomAdjustedPixelValue(style->getFontDescription().computedPixelSize(),
- *style);
-}
-
-bool CSSComputedStyleDeclaration::isMonospaceFont() const {
- if (!m_node)
- return false;
-
- const ComputedStyle* style =
- m_node->ensureComputedStyle(m_pseudoElementSpecifier);
- if (!style)
- return false;
-
- return style->getFontDescription().isMonospace();
-}
-
-static void logUnimplementedPropertyID(CSSPropertyID propertyID) {
+void logUnimplementedPropertyID(CSSPropertyID propertyID) {
DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ());
if (!propertyIDSet.add(propertyID).isNewEntry)
return;
@@ -271,9 +208,9 @@ static void logUnimplementedPropertyID(CSSPropertyID propertyID) {
<< getPropertyName(propertyID) << "'.";
}
-static bool isLayoutDependent(CSSPropertyID propertyID,
- const ComputedStyle* style,
- LayoutObject* layoutObject) {
+bool isLayoutDependent(CSSPropertyID propertyID,
+ const ComputedStyle* style,
+ LayoutObject* layoutObject) {
if (!layoutObject)
return false;
@@ -338,6 +275,73 @@ static bool isLayoutDependent(CSSPropertyID propertyID,
}
}
+} // namespace
+
+CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(
+ Node* n,
+ bool allowVisitedStyle,
+ const String& pseudoElementName)
+ : m_node(n),
+ m_pseudoElementSpecifier(CSSSelector::parsePseudoId(pseudoElementName)),
+ m_allowVisitedStyle(allowVisitedStyle) {}
+
+CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration() {}
+
+String CSSComputedStyleDeclaration::cssText() const {
+ StringBuilder result;
+ const Vector<CSSPropertyID>& properties = computableProperties();
+
+ for (unsigned i = 0; i < properties.size(); i++) {
+ if (i)
+ result.append(' ');
+ result.append(getPropertyName(properties[i]));
+ result.append(": ");
+ result.append(getPropertyValue(properties[i]));
+ result.append(';');
+ }
+
+ return result.toString();
+}
+
+void CSSComputedStyleDeclaration::setCSSText(const String&,
+ ExceptionState& exceptionState) {
+ exceptionState.throwDOMException(
+ NoModificationAllowedError,
+ "These styles are computed, and therefore read-only.");
+}
+
+const CSSValue*
+CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const {
+ if (!m_node)
+ return nullptr;
+
+ m_node->document().updateStyleAndLayoutIgnorePendingStylesheets();
+
+ const ComputedStyle* style =
+ m_node->ensureComputedStyle(m_pseudoElementSpecifier);
+ if (!style)
+ return nullptr;
+
+ if (int keywordSize = style->getFontDescription().keywordSize()) {
+ return CSSIdentifierValue::create(
+ cssIdentifierForFontSizeKeyword(keywordSize));
+ }
+
+ return zoomAdjustedPixelValue(style->getFontDescription().computedPixelSize(),
+ *style);
+}
+
+bool CSSComputedStyleDeclaration::isMonospaceFont() const {
+ if (!m_node)
+ return false;
+
+ const ComputedStyle* style =
+ m_node->ensureComputedStyle(m_pseudoElementSpecifier);
+ if (!style)
+ return false;
+
+ return style->getFontDescription().isMonospace();
+}
const ComputedStyle* CSSComputedStyleDeclaration::computeComputedStyle() const {
Node* styledNode = this->styledNode();
ASSERT(styledNode);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698