Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Unmaintained
KDE Libraries
Commits
b0fc9528
Commit
b0fc9528
authored
Jul 04, 2014
by
Andrea Iacovitti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Determine minimum font size once, when computing other font sizes.
parent
b201d93f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
29 deletions
+25
-29
khtml/css/cssstyleselector.cpp
khtml/css/cssstyleselector.cpp
+24
-29
khtml/css/cssstyleselector.h
khtml/css/cssstyleselector.h
+1
-0
No files found.
khtml/css/cssstyleselector.cpp
View file @
b0fc9528
...
...
@@ -513,7 +513,7 @@ void CSSStyleSelector::computeFontSizesFor(int logicalDpiY, int zoomFactor, QVec
float
scale
=
1.0
;
static
const
float
fontFactors
[]
=
{
3.0
f
/
5.0
f
,
3.0
f
/
4.0
f
,
8.0
f
/
9.0
f
,
1.0
f
,
6.0
f
/
5.0
f
,
3.0
f
/
2.0
f
,
2.0
f
,
3.0
f
};
static
const
float
smallFontFactors
[]
=
{
3.0
f
/
4.0
f
,
5.0
f
/
6.0
f
,
8.0
f
/
9.0
f
,
1.0
f
,
6.0
f
/
5.0
f
,
3.0
f
/
2.0
f
,
2.0
f
,
3.0
f
};
float
mediumFontSize
,
minFontSize
,
factor
;
float
mediumFontSize
,
factor
;
if
(
!
khtml
::
printpainter
)
{
scale
*=
zoomFactor
/
100.0
;
#ifdef APPLE_CHANGES
...
...
@@ -522,18 +522,18 @@ void CSSStyleSelector::computeFontSizesFor(int logicalDpiY, int zoomFactor, QVec
else
#endif
mediumFontSize
=
settings
->
mediumFontSize
()
*
toPix
;
minFontSize
=
settings
->
minFontSize
()
*
toPix
;
m_
minFontSize
=
settings
->
minFontSize
()
*
toPix
;
}
else
{
// ### depending on something / configurable ?
mediumFontSize
=
12
;
minFontSize
=
6
;
m_
minFontSize
=
6
;
}
const
float
*
factors
=
scale
*
mediumFontSize
>=
12.5
?
fontFactors
:
smallFontFactors
;
for
(
int
i
=
0
;
i
<
MAXFONTSIZES
;
i
++
)
{
factor
=
scale
*
factors
[
i
];
fontSizes
[
i
]
=
int
(
qMax
(
mediumFontSize
*
factor
+
.5
f
,
minFontSize
)
)
;
//kDebug( 6080 ) << "index: " << i << " factor: " << factors[i] << " font pix size: " <<
int(
qMax(
mediumFontSize*factor
+.5f,
minFontSize)
)
;
fontSizes
[
i
]
=
qMax
(
qRound
(
mediumFontSize
*
factor
),
m_
minFontSize
);
//kDebug( 6080 ) << "index: " << i << " factor: " << factors[i] << " font pix size: " << qMax(
qRound(
mediumFontSize*factor
), m_
minFontSize);
}
}
...
...
@@ -3433,13 +3433,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
{
FontDef
fontDef
=
style
->
htmlFont
().
fontDef
;
int
oldSize
;
float
size
=
0
;
float
toPix
=
logicalDpiY
/
72.0
f
;
if
(
toPix
<
96.0
f
/
72.0
f
)
toPix
=
96.0
f
/
72.0
f
;
float
minFontSize
=
settings
->
minFontSize
()
*
toPix
;
int
size
=
0
;
if
(
parentNode
)
{
oldSize
=
parentStyle
->
font
().
pixelSize
();
...
...
@@ -3481,28 +3475,29 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
}
else
{
int
type
=
primitiveValue
->
primitiveType
();
if
(
type
>
CSSPrimitiveValue
::
CSS_PERCENTAGE
&&
type
<
CSSPrimitiveValue
::
CSS_DEG
)
{
if
(
!
khtml
::
printpainter
&&
type
!=
CSSPrimitiveValue
::
CSS_EMS
&&
type
!=
CSSPrimitiveValue
::
CSS_EXS
&&
view
&&
view
->
part
())
size
=
primitiveValue
->
computeLengthFloat
(
parentStyle
,
logicalDpiY
)
*
view
->
part
()
->
fontScaleFactor
()
/
100.0
;
else
size
=
primitiveValue
->
computeLengthFloat
(
parentStyle
,
logicalDpiY
);
}
else
if
(
type
==
CSSPrimitiveValue
::
CSS_PERCENTAGE
)
size
=
primitiveValue
->
floatValue
(
CSSPrimitiveValue
::
CSS_PERCENTAGE
)
*
parentStyle
->
font
().
pixelSize
()
/
100.0
;
else
if
(
type
>
CSSPrimitiveValue
::
CSS_PERCENTAGE
&&
type
<
CSSPrimitiveValue
::
CSS_DEG
)
{
if
(
!
khtml
::
printpainter
&&
type
!=
CSSPrimitiveValue
::
CSS_EMS
&&
type
!=
CSSPrimitiveValue
::
CSS_EXS
&&
view
&&
view
->
part
())
{
size
=
qRound
(
primitiveValue
->
computeLengthFloat
(
parentStyle
,
logicalDpiY
)
*
view
->
part
()
->
fontScaleFactor
()
/
100.0
);
}
else
{
size
=
qRound
(
primitiveValue
->
computeLengthFloat
(
parentStyle
,
logicalDpiY
));
}
}
else
if
(
type
==
CSSPrimitiveValue
::
CSS_PERCENTAGE
)
{
size
=
qRound
(
primitiveValue
->
floatValue
(
CSSPrimitiveValue
::
CSS_PERCENTAGE
)
*
parentStyle
->
font
().
pixelSize
()
/
100.0
);
}
else
{
return
;
}
}
// we never want to get smaller than the minimum font size to keep fonts readable
// do not however maximize zero as that is commonly used for fancy layouting purposes
if
(
size
&&
size
<
minFontSize
)
size
=
minFontSize
;
// we never want to get smaller than the minimum font size to keep fonts readable
// do not however maximize zero as that is commonly used for fancy layouting purposes
if
(
size
)
{
size
=
qMax
(
size
,
m_minFontSize
);
}
}
//kDebug( 6080 ) << "computed raw font size: " << size;
fontDef
.
size
=
qRound
(
size
)
;
fontDef
.
size
=
size
;
fontDirty
|=
style
->
setFontDef
(
fontDef
);
return
;
}
...
...
khtml/css/cssstyleselector.h
View file @
b0fc9528
...
...
@@ -331,6 +331,7 @@ public:
RenderStyle
*
m_rootDefaultStyle
;
QVector
<
int
>
m_fontSizes
;
QVector
<
int
>
m_fixedFontSizes
;
int
m_minFontSize
;
bool
fontDirty
;
DOM
::
CSSFontSelector
*
m_fontSelector
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment