This commit is contained in:
vladimir@pobox.com 2008-04-20 01:24:42 -07:00
Родитель e59600e719
Коммит f7a5c34236
9 изменённых файлов: 19 добавлений и 127 удалений

Просмотреть файл

@ -1499,8 +1499,8 @@ nsPresContext::IsChrome() const
}
/* virtual */ PRBool
nsPresContext::HasAuthorSpecifiedRules(nsIFrame *aFrame, PRUint32 ruleTypeMask) const
nsPresContext::HasAuthorSpecifiedBorderOrBackground(nsIFrame *aFrame) const
{
return nsRuleNode::
HasAuthorSpecifiedRules(aFrame->GetStyleContext(), ruleTypeMask);
HasAuthorSpecifiedBorderOrBackground(aFrame->GetStyleContext());
}

Просмотреть файл

@ -137,11 +137,6 @@ enum nsLayoutPhase {
};
#endif
/* Used by nsPresContext::HasAuthorSpecifiedRules */
#define NS_AUTHOR_SPECIFIED_BACKGROUND (1 << 0)
#define NS_AUTHOR_SPECIFIED_BORDER (1 << 1)
#define NS_AUTHOR_SPECIFIED_PADDING (1 << 2)
// An interface for presentation contexts. Presentation contexts are
// objects that provide an outer context for a presentation shell.
@ -746,7 +741,7 @@ public:
PRBool IsChrome() const;
// Public API for native theme code to get style internals.
virtual PRBool HasAuthorSpecifiedRules(nsIFrame *aFrame, PRUint32 ruleTypeMask) const;
virtual PRBool HasAuthorSpecifiedBorderOrBackground(nsIFrame *aFrame) const;
// Is it OK to let the page specify colors and backgrounds?
PRBool UseDocumentColors() const {

Просмотреть файл

@ -1,17 +0,0 @@
<!DOCTYPE HTML>
<html>
<style>
div {
border: 1px solid black;
}
select {
}
<body>
<div><select><option>Hello</option></select></div>
</body>
</html>

Просмотреть файл

@ -1,18 +0,0 @@
<!DOCTYPE HTML>
<html>
<style>
div {
border: 1px solid black;
}
select {
padding: 10px;
}
<body>
<div><select><option>Hello</option></select></div>
</body>
</html>

Просмотреть файл

@ -26,7 +26,3 @@
!= checkbox-native.html checkbox-nonnative.html
== checkbox-still-native-when-styled.html checkbox-still-native-when-styled-ref.html
== native-theme-disabled-cascade-levels.html native-theme-disabled-cascade-levels-ref.html
# mac ignores padding on most native widgets and has done so for a while
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") != 427122-1.html 427122-1-ref.html

Просмотреть файл

@ -5159,35 +5159,20 @@ nsRuleNode::Sweep()
}
/* static */ PRBool
nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
PRUint32 ruleTypeMask)
nsRuleNode::HasAuthorSpecifiedBorderOrBackground(nsStyleContext* aStyleContext)
{
nsRuleDataColor colorData;
nsRuleDataMargin marginData;
PRUint32 nValues = 0;
PRUint32 inheritBits = 0;
if (ruleTypeMask & NS_AUTHOR_SPECIFIED_BACKGROUND)
inheritBits |= NS_STYLE_INHERIT_BIT(Background);
if (ruleTypeMask & NS_AUTHOR_SPECIFIED_BORDER)
inheritBits |= NS_STYLE_INHERIT_BIT(Border);
if (ruleTypeMask & NS_AUTHOR_SPECIFIED_PADDING)
inheritBits |= NS_STYLE_INHERIT_BIT(Padding);
/* We're relying on the use of |aStyleContext| not mutating it! */
nsRuleData ruleData(inheritBits,
nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Background) |
NS_STYLE_INHERIT_BIT(Border),
aStyleContext->PresContext(), aStyleContext);
ruleData.mColorData = &colorData;
ruleData.mMarginData = &marginData;
nsCSSValue* backgroundValues[] = {
nsCSSValue* values[] = {
&colorData.mBackColor,
&colorData.mBackImage
};
nsCSSValue* borderValues[] = {
&colorData.mBackImage,
&marginData.mBorderColor.mTop,
&marginData.mBorderStyle.mTop,
&marginData.mBorderWidth.mTop,
@ -5200,37 +5185,8 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
&marginData.mBorderColor.mLeft,
&marginData.mBorderStyle.mLeft,
&marginData.mBorderWidth.mLeft
// XXX add &marginData.mBorder{Start,End}{Width,Color,Style}
};
nsCSSValue* paddingValues[] = {
&marginData.mPadding.mTop,
&marginData.mPadding.mRight,
&marginData.mPadding.mBottom,
&marginData.mPadding.mLeft,
&marginData.mPaddingStart,
&marginData.mPaddingEnd
};
nsCSSValue* values[NS_ARRAY_LENGTH(backgroundValues) +
NS_ARRAY_LENGTH(borderValues) +
NS_ARRAY_LENGTH(paddingValues)];
if (ruleTypeMask & NS_AUTHOR_SPECIFIED_BACKGROUND) {
memcpy(&values[nValues], backgroundValues, NS_ARRAY_LENGTH(backgroundValues) * sizeof(nsCSSValue*));
nValues += NS_ARRAY_LENGTH(backgroundValues);
}
if (ruleTypeMask & NS_AUTHOR_SPECIFIED_BORDER) {
memcpy(&values[nValues], borderValues, NS_ARRAY_LENGTH(borderValues) * sizeof(nsCSSValue*));
nValues += NS_ARRAY_LENGTH(borderValues);
}
if (ruleTypeMask & NS_AUTHOR_SPECIFIED_PADDING) {
memcpy(&values[nValues], paddingValues, NS_ARRAY_LENGTH(paddingValues) * sizeof(nsCSSValue*));
nValues += NS_ARRAY_LENGTH(paddingValues);
}
// We need to be careful not to count styles covered up by
// user-important or UA-important declarations.
for (nsRuleNode* ruleNode = aStyleContext->GetRuleNode(); ruleNode;
@ -5245,13 +5201,13 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
// This is a rule whose effect we want to ignore, so if any of
// the properties we care about were set, set them to the dummy
// value that they'll never otherwise get.
for (PRUint32 i = 0; i < nValues; ++i)
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(values); ++i)
if (values[i]->GetUnit() != eCSSUnit_Null)
values[i]->SetDummyValue();
} else {
// If any of the values we care about was set by the above rule,
// we have author style.
for (PRUint32 i = 0; i < nValues; ++i)
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(values); ++i)
if (values[i]->GetUnit() != eCSSUnit_Null &&
values[i]->GetUnit() != eCSSUnit_Dummy) // see above
return PR_TRUE;

Просмотреть файл

@ -722,7 +722,7 @@ public:
NS_HIDDEN_(PRBool) Sweep();
static PRBool
HasAuthorSpecifiedRules(nsStyleContext* aStyleContext, PRUint32 ruleTypeMask);
HasAuthorSpecifiedBorderOrBackground(nsStyleContext* aStyleContext);
};
#endif

Просмотреть файл

@ -461,15 +461,6 @@ nsNativeThemeWin::GetTheme(PRUint8 aWidgetType)
if (!mThemeDLL)
return NULL;
if (!mIsVistaOrLater) {
// On XP or earlier, render dropdowns as textfields;
// doing it the right way works fine with the MS themes,
// but breaks on a lot of custom themes (presumably because MS
// apps do the textfield border business as well).
if (aWidgetType == NS_THEME_DROPDOWN)
aWidgetType = NS_THEME_TEXTFIELD;
}
switch (aWidgetType) {
case NS_THEME_BUTTON:
case NS_THEME_RADIO:
@ -641,12 +632,6 @@ nsresult
nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
PRInt32& aPart, PRInt32& aState)
{
if (!mIsVistaOrLater) {
// See GetTheme
if (aWidgetType == NS_THEME_DROPDOWN)
aWidgetType = NS_THEME_TEXTFIELD;
}
switch (aWidgetType) {
case NS_THEME_BUTTON: {
aPart = BP_BUTTON;
@ -1542,15 +1527,6 @@ nsNativeThemeWin::GetWidgetPadding(nsIDeviceContext* aContext,
}
if (mIsVistaOrLater) {
if (aWidgetType == NS_THEME_TEXTFIELD ||
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
aWidgetType == NS_THEME_DROPDOWN)
{
/* If we have author-specified padding for these elements, don't do the fixups below */
if (aFrame->PresContext()->HasAuthorSpecifiedRules(aFrame, NS_AUTHOR_SPECIFIED_PADDING))
return PR_FALSE;
}
/* textfields need an extra pixel on all sides, otherwise they
* wrap their content too tightly. The actual border is drawn 1px
* inside the specified rectangle, so Gecko will end up making the
@ -1561,7 +1537,13 @@ nsNativeThemeWin::GetWidgetPadding(nsIDeviceContext* aContext,
aResult->top = aResult->bottom = 1;
aResult->left = aResult->right = 1;
return PR_TRUE;
} else if (IsHTMLContent(aFrame) && aWidgetType == NS_THEME_DROPDOWN) {
}
}
// Some things only apply to widgets in HTML content, since
// they're drawn differently
if (IsHTMLContent(aFrame)) {
if (aWidgetType == NS_THEME_DROPDOWN) {
/* For content menulist controls, we need an extra pixel so
* that we have room to draw our focus rectangle stuff.
* Otherwise, the focus rect might overlap the control's

Просмотреть файл

@ -166,9 +166,7 @@ nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame,
aWidgetType == NS_THEME_LISTBOX ||
aWidgetType == NS_THEME_DROPDOWN) &&
aFrame->GetContent()->IsNodeOfType(nsINode::eHTML) &&
aPresContext->HasAuthorSpecifiedRules(aFrame,
NS_AUTHOR_SPECIFIED_BORDER |
NS_AUTHOR_SPECIFIED_BACKGROUND);
aPresContext->HasAuthorSpecifiedBorderOrBackground(aFrame);
}
// scrollbar button: