https://bugs.webkit.org/show_bug.cgi?id=75665
Reviewed by Darin Fisher.
Unlike gcc and clang, MSVC pads each consecutive member variables of the same type
in bitfields. e.g. if you have:
sturct AB {
unsigned m_1 : 31;
bool m_2 : 1;
}
then MSVC pads m_1 and allocates sizeof(unsigned) * 2 for AB whereas gcc and clang
only allocate sizeof(unsigned) * 1 for AB.
Fix the bloat by turning all bitfields in CSSRule either signed or unsigned integers.
* css/CSSRule.cpp:
* css/CSSRule.h:
(WebCore::CSSRule::sourceLine):
(WebCore::CSSRule::setSourceLine):
(WebCore::CSSRule::hasCachedSelectorText):
(WebCore::CSSRule::setHasCachedSelectorText):
* css/CSSStyleRule.cpp:
(WebCore::CSSStyleRule::CSSStyleRule):
(WebCore::CSSStyleRule::cleanup):
(WebCore::CSSStyleRule::selectorText):
(WebCore::CSSStyleRule::setSelectorText):
* css/CSSStyleRule.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@104254
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-01-05 Ryosuke Niwa <rniwa@webkit.org>
+
+ sizeof(CSSRule) is 20 instead of 12 on Windows
+ https://bugs.webkit.org/show_bug.cgi?id=75665
+
+ Reviewed by Darin Fisher.
+
+ Unlike gcc and clang, MSVC pads each consecutive member variables of the same type
+ in bitfields. e.g. if you have:
+
+ sturct AB {
+ unsigned m_1 : 31;
+ bool m_2 : 1;
+ }
+
+ then MSVC pads m_1 and allocates sizeof(unsigned) * 2 for AB whereas gcc and clang
+ only allocate sizeof(unsigned) * 1 for AB.
+
+ Fix the bloat by turning all bitfields in CSSRule either signed or unsigned integers.
+
+ * css/CSSRule.cpp:
+ * css/CSSRule.h:
+ (WebCore::CSSRule::sourceLine):
+ (WebCore::CSSRule::setSourceLine):
+ (WebCore::CSSRule::hasCachedSelectorText):
+ (WebCore::CSSRule::setHasCachedSelectorText):
+ * css/CSSStyleRule.cpp:
+ (WebCore::CSSStyleRule::CSSStyleRule):
+ (WebCore::CSSStyleRule::cleanup):
+ (WebCore::CSSStyleRule::selectorText):
+ (WebCore::CSSStyleRule::setSelectorText):
+ * css/CSSStyleRule.h:
+
2012-01-05 David Grogan <dgrogan@chromium.org>
IndexedDB: fix cursor prefetch crash
FD6F252D13F5EF0E0065165F /* MediaElementAudioSourceNode.h in Headers */,
E44613AD0CD6331000FADA75 /* MediaError.h in Headers */,
4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */,
- 07A6D1EC1491137700051D0C /* MediaFragmentURIParser.h in Headers */,
+ 07A6D1EC1491137700051D0C /* MediaFragmentURIParser.h in Headers */,
A8EA800E0A19516E00A8EF5F /* MediaList.h in Headers */,
E44613E40CD681A200FADA75 /* MediaPlayer.h in Headers */,
076F0D0E12B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.h in Headers */,
97205AB71239291000B17380 /* MediaDocument.cpp in Sources */,
FD6F252C13F5EF0E0065165F /* MediaElementAudioSourceNode.cpp in Sources */,
4E1959210A39DABA00220FE5 /* MediaFeatureNames.cpp in Sources */,
- 07A6D1EB1491137700051D0C /* MediaFragmentURIParser.cpp in Sources */,
+ 07A6D1EB1491137700051D0C /* MediaFragmentURIParser.cpp in Sources */,
A8EA80090A19516E00A8EF5F /* MediaList.cpp in Sources */,
E44613E30CD6819F00FADA75 /* MediaPlayer.cpp in Sources */,
072C8B11131C518600A4FCE9 /* MediaPlayerPrivateAVFoundation.cpp in Sources */,
namespace WebCore {
+struct SameSizeAsCSSRule : public RefCounted<SameSizeAsCSSRule> {
+ unsigned bitfields;
+ void* pointerUnion;
+};
+
+COMPILE_ASSERT(sizeof(CSSRule) == sizeof(SameSizeAsCSSRule), CSSRule_should_stay_small);
+
void CSSRule::setCssText(const String& /*cssText*/, ExceptionCode& /*ec*/)
{
notImplemented();
~CSSRule() { }
- // Only used by CSSStyleRule but kept here to maximize struct packing.
- signed m_sourceLine : 26;
- mutable bool m_hasCachedSelectorText : 1;
+ int sourceLine() const { return m_sourceLine; }
+ void setSourceLine(int sourceLine) { m_sourceLine = sourceLine; }
+ bool hasCachedSelectorText() const { return m_hasCachedSelectorText; }
+ void setHasCachedSelectorText(bool hasCachedSelectorText) const { m_hasCachedSelectorText = hasCachedSelectorText; }
private:
- bool m_parentIsRule : 1;
+ // Only used by CSSStyleRule but kept here to maximize struct packing.
+ signed m_sourceLine : 26;
+ mutable unsigned m_hasCachedSelectorText : 1;
+ unsigned m_parentIsRule : 1;
unsigned m_type : 4;
union {
CSSRule* m_parentRule;
namespace WebCore {
-CSSStyleRule::CSSStyleRule(CSSStyleSheet* parent, int sourceLine, CSSRule::Type type)
+CSSStyleRule::CSSStyleRule(CSSStyleSheet* parent, int line, CSSRule::Type type)
: CSSRule(parent, type)
{
- m_sourceLine = sourceLine;
+ setSourceLine(line);
// m_sourceLine is a bitfield, so let's catch any overflow early in debug mode.
- ASSERT(m_sourceLine == sourceLine);
+ ASSERT(sourceLine() == line);
}
CSSStyleRule::~CSSStyleRule()
inline void CSSStyleRule::cleanup()
{
- if (m_hasCachedSelectorText) {
+ if (hasCachedSelectorText()) {
selectorTextCache().remove(this);
- m_hasCachedSelectorText = false;
+ setHasCachedSelectorText(false);
}
}
String CSSStyleRule::selectorText() const
{
- if (m_hasCachedSelectorText) {
+ if (hasCachedSelectorText()) {
ASSERT(selectorTextCache().contains(this));
return selectorTextCache().get(this);
}
ASSERT(!selectorTextCache().contains(this));
String text = generateSelectorText();
selectorTextCache().set(this, text);
- m_hasCachedSelectorText = true;
+ setHasCachedSelectorText(true);
return text;
}
String oldSelectorText = this->selectorText();
m_selectorList.adopt(selectorList);
- if (m_hasCachedSelectorText) {
+ if (hasCachedSelectorText()) {
ASSERT(selectorTextCache().contains(this));
selectorTextCache().set(this, generateSelectorText());
}
void addSubresourceStyleURLs(ListHashSet<KURL>& urls);
- int sourceLine() { return m_sourceLine; }
+ using CSSRule::sourceLine;
protected:
CSSStyleRule(CSSStyleSheet* parent, int sourceLine, CSSRule::Type = CSSRule::STYLE_RULE);