added constrain font weight

This commit is contained in:
peterl%netscape.com 1999-09-10 05:51:44 +00:00
parent 914df12461
commit af1b7020f0
5 changed files with 94 additions and 0 deletions

View File

@ -158,6 +158,29 @@ PRInt32 nsStyleUtil::FindNextLargerFontSize(nscoord aFontSize, PRInt32 aBasePoin
return index;
}
PRInt32
nsStyleUtil::ConstrainFontWeight(PRInt32 aWeight)
{
aWeight = ((aWeight < 100) ? 100 : ((aWeight > 900) ? 900 : aWeight));
PRInt32 base = ((aWeight / 100) * 100);
PRInt32 step = (aWeight % 100);
PRBool negativeStep = PRBool(50 < step);
PRInt32 maxStep;
if (negativeStep) {
step = 100 - step;
maxStep = (base / 100);
base += 100;
}
else {
maxStep = ((900 - base) / 100);
}
if (maxStep < step) {
step = maxStep;
}
return (base + ((negativeStep) ? -step : step));
}
const nsStyleColor* nsStyleUtil::FindNonTransparentBackground(nsIStyleContext* aContext)
{
const nsStyleColor* result = nsnull;

View File

@ -158,6 +158,29 @@ PRInt32 nsStyleUtil::FindNextLargerFontSize(nscoord aFontSize, PRInt32 aBasePoin
return index;
}
PRInt32
nsStyleUtil::ConstrainFontWeight(PRInt32 aWeight)
{
aWeight = ((aWeight < 100) ? 100 : ((aWeight > 900) ? 900 : aWeight));
PRInt32 base = ((aWeight / 100) * 100);
PRInt32 step = (aWeight % 100);
PRBool negativeStep = PRBool(50 < step);
PRInt32 maxStep;
if (negativeStep) {
step = 100 - step;
maxStep = (base / 100);
base += 100;
}
else {
maxStep = ((900 - base) / 100);
}
if (maxStep < step) {
step = maxStep;
}
return (base + ((negativeStep) ? -step : step));
}
const nsStyleColor* nsStyleUtil::FindNonTransparentBackground(nsIStyleContext* aContext)
{
const nsStyleColor* result = nsnull;

View File

@ -37,6 +37,8 @@ public:
static PRInt32 FindNextLargerFontSize(nscoord aFontSize, PRInt32 aBasePointSize,
float aScalingFactor);
static PRInt32 ConstrainFontWeight(PRInt32 aWeight);
static const nsStyleColor* FindNonTransparentBackground(nsIStyleContext* aContext);
};

View File

@ -158,6 +158,29 @@ PRInt32 nsStyleUtil::FindNextLargerFontSize(nscoord aFontSize, PRInt32 aBasePoin
return index;
}
PRInt32
nsStyleUtil::ConstrainFontWeight(PRInt32 aWeight)
{
aWeight = ((aWeight < 100) ? 100 : ((aWeight > 900) ? 900 : aWeight));
PRInt32 base = ((aWeight / 100) * 100);
PRInt32 step = (aWeight % 100);
PRBool negativeStep = PRBool(50 < step);
PRInt32 maxStep;
if (negativeStep) {
step = 100 - step;
maxStep = (base / 100);
base += 100;
}
else {
maxStep = ((900 - base) / 100);
}
if (maxStep < step) {
step = maxStep;
}
return (base + ((negativeStep) ? -step : step));
}
const nsStyleColor* nsStyleUtil::FindNonTransparentBackground(nsIStyleContext* aContext)
{
const nsStyleColor* result = nsnull;

View File

@ -158,6 +158,29 @@ PRInt32 nsStyleUtil::FindNextLargerFontSize(nscoord aFontSize, PRInt32 aBasePoin
return index;
}
PRInt32
nsStyleUtil::ConstrainFontWeight(PRInt32 aWeight)
{
aWeight = ((aWeight < 100) ? 100 : ((aWeight > 900) ? 900 : aWeight));
PRInt32 base = ((aWeight / 100) * 100);
PRInt32 step = (aWeight % 100);
PRBool negativeStep = PRBool(50 < step);
PRInt32 maxStep;
if (negativeStep) {
step = 100 - step;
maxStep = (base / 100);
base += 100;
}
else {
maxStep = ((900 - base) / 100);
}
if (maxStep < step) {
step = maxStep;
}
return (base + ((negativeStep) ? -step : step));
}
const nsStyleColor* nsStyleUtil::FindNonTransparentBackground(nsIStyleContext* aContext)
{
const nsStyleColor* result = nsnull;