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

Unified Diff: Source/core/css/CSSProperty.h

Issue 16161005: Reduce CSSProperty's StylePropertyMetadata memory footprint by half when used inside a ImmutableSty… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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/CSSProperty.h
diff --git a/Source/core/css/CSSProperty.h b/Source/core/css/CSSProperty.h
index 7b508141c6ff725071eda61793a030322a3a8583..64cbc9dd872febcbd1edfd7db0a9d33a6b7fc2ed 100644
--- a/Source/core/css/CSSProperty.h
+++ b/Source/core/css/CSSProperty.h
@@ -26,14 +26,15 @@
#include "core/platform/text/TextDirection.h"
#include "core/platform/text/WritingMode.h"
#include "core/rendering/style/RenderStyleConstants.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
namespace WebCore {
-union StylePropertyMetadata {
- StylePropertyMetadata(CSSPropertyID propertyID, CSSPropertyID shorthandID, bool important, bool implicit, bool inherited)
+struct StylePropertyMetadata {
+ StylePropertyMetadata(CSSPropertyID propertyID, bool isSetFromShorthand, int shorthandID, bool important, bool implicit, bool inherited)
: m_propertyID(propertyID)
+ , m_isSetFromShorthand(isSetFromShorthand)
, m_shorthandID(shorthandID)
, m_important(important)
, m_implicit(implicit)
@@ -41,20 +42,20 @@ union StylePropertyMetadata {
{
}
- unsigned m_bits;
- struct {
- unsigned m_propertyID : 14;
- unsigned m_shorthandID : 14; // If this property was set as part of a shorthand, gives the shorthand.
- unsigned m_important : 1;
- unsigned m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand.
- unsigned m_inherited : 1;
- };
+ CSSPropertyID shorthandID() const;
+
+ unsigned m_propertyID : 10;
+ unsigned m_isSetFromShorthand : 1;
+ unsigned m_shorthandID : 2; // If this property was set as part of an ambiguous shorthand, gives the shorthand.
+ unsigned m_important : 1;
+ unsigned m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand.
+ unsigned m_inherited : 1;
};
class CSSProperty {
public:
- CSSProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> value, bool important = false, CSSPropertyID shorthandID = CSSPropertyInvalid, bool implicit = false)
- : m_metadata(propertyID, shorthandID, important, implicit, isInheritedProperty(propertyID))
+ CSSProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> value, bool important = false, bool isSetFromShorthand = false, int shorthandID = 0, bool implicit = false)
+ : m_metadata(propertyID, isSetFromShorthand, shorthandID, important, implicit, isInheritedProperty(propertyID))
, m_value(value)
{
ASSERT((propertyID == CSSPropertyVariable) == (m_value && m_value->isVariableValue()));
@@ -69,7 +70,8 @@ public:
}
CSSPropertyID id() const { return static_cast<CSSPropertyID>(m_metadata.m_propertyID); }
- CSSPropertyID shorthandID() const { return static_cast<CSSPropertyID>(m_metadata.m_shorthandID); }
+ bool isSetFromShorthand() const { return m_metadata.m_isSetFromShorthand; };
+ CSSPropertyID shorthandID() const { return m_metadata.shorthandID(); };
bool isImportant() const { return m_metadata.m_important; }
CSSValue* value() const { return m_value.get(); }

Powered by Google App Engine
This is Rietveld 408576698