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
0fef6992
Commit
0fef6992
authored
Nov 22, 2014
by
Andrea Iacovitti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support 'ch' font-relative length unit type.
parent
ac3b045f
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1298 additions
and
1246 deletions
+1298
-1246
khtml/css/css_valueimpl.cpp
khtml/css/css_valueimpl.cpp
+16
-4
khtml/css/cssparser.cpp
khtml/css/cssparser.cpp
+2
-0
khtml/css/cssstyleselector.cpp
khtml/css/cssstyleselector.cpp
+9
-9
khtml/css/parser.cpp
khtml/css/parser.cpp
+418
-409
khtml/css/parser.h
khtml/css/parser.h
+24
-23
khtml/css/parser.y
khtml/css/parser.y
+3
-1
khtml/css/tokenizer.cpp
khtml/css/tokenizer.cpp
+782
-777
khtml/css/tokenizer.flex
khtml/css/tokenizer.flex
+1
-0
khtml/dom/css_value.h
khtml/dom/css_value.h
+24
-23
khtml/ecma/kjs_css.cpp
khtml/ecma/kjs_css.cpp
+1
-0
khtml/rendering/font.cpp
khtml/rendering/font.cpp
+14
-0
khtml/rendering/font.h
khtml/rendering/font.h
+4
-0
No files found.
khtml/css/css_valueimpl.cpp
View file @
0fef6992
...
...
@@ -1089,12 +1089,21 @@ double CSSPrimitiveValueImpl::computeLengthFloat( khtml::RenderStyle *style, int
case
CSSPrimitiveValue
::
CSS_EMS
:
factor
=
style
->
font
().
pixelSize
();
break
;
case
CSSPrimitiveValue
::
CSS_EXS
:
{
QFontMetrics
fm
=
style
->
fontMetrics
();
case
CSSPrimitiveValue
::
CSS_EXS
:
{
const
QFontMetrics
fm
=
style
->
fontMetrics
();
factor
=
fm
.
xHeight
();
break
;
}
case
CSSPrimitiveValue
::
CSS_CHS
:
{
const
int
zw
=
style
->
htmlFont
().
zeroCharWidth
();
if
(
zw
!=
-
1
)
{
factor
=
zw
;
}
else
{
// assume 0.5em
return
((
double
)
0.5
*
style
->
font
().
pixelSize
());
}
break
;
}
case
CSSPrimitiveValue
::
CSS_PX
:
break
;
case
CSSPrimitiveValue
::
CSS_CM
:
...
...
@@ -1214,6 +1223,9 @@ DOM::DOMString CSSPrimitiveValueImpl::cssText() const
case
CSSPrimitiveValue
::
CSS_EXS
:
text
=
DOMString
(
QString
::
number
(
m_value
.
num
)
+
"ex"
);
break
;
case
CSSPrimitiveValue
::
CSS_CHS
:
text
=
DOMString
(
QString
::
number
(
m_value
.
num
)
+
"ch"
);
break
;
case
CSSPrimitiveValue
::
CSS_PX
:
text
=
DOMString
(
QString
::
number
(
m_value
.
num
)
+
"px"
);
break
;
...
...
khtml/css/cssparser.cpp
View file @
0fef6992
...
...
@@ -449,6 +449,7 @@ bool CSSParser::validUnit( Value *value, int unitflags, bool strict )
case
Value
::
Q_EMS
:
case
CSSPrimitiveValue
::
CSS_EMS
:
case
CSSPrimitiveValue
::
CSS_EXS
:
case
CSSPrimitiveValue
::
CSS_CHS
:
case
CSSPrimitiveValue
::
CSS_PX
:
case
CSSPrimitiveValue
::
CSS_CM
:
case
CSSPrimitiveValue
::
CSS_MM
:
...
...
@@ -2928,6 +2929,7 @@ int DOM::CSSParser::lex( void *_yylval )
case
HERZ
:
case
EMS
:
case
EXS
:
case
CHS
:
case
PXS
:
case
CMS
:
case
MMS
:
...
...
khtml/css/cssstyleselector.cpp
View file @
0fef6992
...
...
@@ -3475,8 +3475,9 @@ 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
())
{
// Scale for the font zoom factor only for types other than "em", "ex", "ch", since those are
// already based on the font size.
if
(
!
khtml
::
printpainter
&&
!
(
type
>=
CSSPrimitiveValue
::
CSS_EMS
&&
type
<=
CSSPrimitiveValue
::
CSS_CHS
)
&&
view
&&
view
->
part
())
{
size
=
qRound
(
primitiveValue
->
computeLengthFloat
(
parentStyle
,
logicalDpiY
)
*
view
->
part
()
->
fontScaleFactor
()
/
100.0
);
}
else
{
size
=
qRound
(
primitiveValue
->
computeLengthFloat
(
parentStyle
,
logicalDpiY
));
...
...
@@ -3561,14 +3562,13 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
if
(
primitiveValue
->
getIdent
()
==
CSS_VAL_NORMAL
)
lineHeight
=
Length
(
-
100.0
,
Percent
);
else
if
(
type
>
CSSPrimitiveValue
::
CSS_PERCENTAGE
&&
type
<
CSSPrimitiveValue
::
CSS_DEG
)
{
// Scale for the font zoom factor only for types other than "em"
and "ex
", since those are
// Scale for the font zoom factor only for types other than "em"
, "ex", "ch
", since those are
// already based on the font size.
if
(
!
khtml
::
printpainter
&&
type
!=
CSSPrimitiveValue
::
CSS_EMS
&&
type
!=
CSSPrimitiveValue
::
CSS_EXS
&&
view
&&
view
->
part
())
lineHeight
=
Length
(
primitiveValue
->
computeLength
(
style
,
logicalDpiY
)
*
view
->
part
()
->
fontScaleFactor
()
/
100
,
Fixed
);
else
lineHeight
=
Length
(
primitiveValue
->
computeLength
(
style
,
logicalDpiY
),
Fixed
);
if
(
!
khtml
::
printpainter
&&
!
(
type
>=
CSSPrimitiveValue
::
CSS_EMS
&&
type
<=
CSSPrimitiveValue
::
CSS_CHS
)
&&
view
&&
view
->
part
())
{
lineHeight
=
Length
(
primitiveValue
->
computeLength
(
style
,
logicalDpiY
)
*
view
->
part
()
->
fontScaleFactor
()
/
100
,
Fixed
);
}
else
{
lineHeight
=
Length
(
primitiveValue
->
computeLength
(
style
,
logicalDpiY
),
Fixed
);
}
}
else
if
(
type
==
CSSPrimitiveValue
::
CSS_PERCENTAGE
)
lineHeight
=
Length
(
(
style
->
font
().
pixelSize
()
*
int
(
primitiveValue
->
floatValue
(
CSSPrimitiveValue
::
CSS_PERCENTAGE
))
)
/
100
,
Fixed
);
else
if
(
type
==
CSSPrimitiveValue
::
CSS_NUMBER
)
...
...
khtml/css/parser.cpp
View file @
0fef6992
This diff is collapsed.
Click to expand it.
khtml/css/parser.h
View file @
0fef6992
...
...
@@ -68,29 +68,30 @@
QEMS
=
286
,
EMS
=
287
,
EXS
=
288
,
PXS
=
289
,
CMS
=
290
,
MMS
=
291
,
INS
=
292
,
PTS
=
293
,
PCS
=
294
,
DEGS
=
295
,
RADS
=
296
,
GRADS
=
297
,
MSECS
=
298
,
SECS
=
299
,
HERZ
=
300
,
KHERZ
=
301
,
DPI
=
302
,
DPCM
=
303
,
DIMEN
=
304
,
PERCENTAGE
=
305
,
FLOAT
=
306
,
INTEGER
=
307
,
URI
=
308
,
FUNCTION
=
309
,
NOTFUNCTION
=
310
,
UNICODERANGE
=
311
CHS
=
289
,
PXS
=
290
,
CMS
=
291
,
MMS
=
292
,
INS
=
293
,
PTS
=
294
,
PCS
=
295
,
DEGS
=
296
,
RADS
=
297
,
GRADS
=
298
,
MSECS
=
299
,
SECS
=
300
,
HERZ
=
301
,
KHERZ
=
302
,
DPI
=
303
,
DPCM
=
304
,
DIMEN
=
305
,
PERCENTAGE
=
306
,
FLOAT
=
307
,
INTEGER
=
308
,
URI
=
309
,
FUNCTION
=
310
,
NOTFUNCTION
=
311
,
UNICODERANGE
=
312
};
#endif
...
...
khtml/css/parser.y
View file @
0fef6992
...
...
@@ -108,7 +108,7 @@ int DOM::getValueID(const char *tagStr, int len)
#define YYLTYPE_IS_TRIVIAL 1
%}
%expect
39
%expect
40
%pure_parser
...
...
@@ -214,6 +214,7 @@ static int cssyylex( YYSTYPE *yylval ) {
%token <val> QEMS
%token <val> EMS
%token <val> EXS
%token <val> CHS
%token <val> PXS
%token <val> CMS
%token <val> MMS
...
...
@@ -1231,6 +1232,7 @@ unary_term:
| EMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_EMS; }
| QEMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = Value::Q_EMS; }
| EXS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_EXS; }
| CHS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_CHS; }
| DPI maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPI; }
| DPCM maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPCM; }
;
...
...
khtml/css/tokenizer.cpp
View file @
0fef6992
This diff is collapsed.
Click to expand it.
khtml/css/tokenizer.flex
View file @
0fef6992
...
...
@@ -67,6 +67,7 @@ nth ([\+-]?[0-9]*n[ \t\r\n\f]*[\+-][ \t\r\n\f]*[0-9]+)|([\+-]?[0-9]*
{num}em {yyTok = EMS; return yyTok;}
{num}__qem {yyTok = QEMS; return yyTok;} /* quirky ems */
{num}ex {yyTok = EXS; return yyTok;}
{num}ch {yyTok = CHS; return yyTok;}
{num}px {yyTok = PXS; return yyTok;}
{num}cm {yyTok = CMS; return yyTok;}
{num}mm {yyTok = MMS; return yyTok;}
...
...
khtml/dom/css_value.h
View file @
0fef6992
...
...
@@ -392,29 +392,30 @@ public:
CSS_PERCENTAGE
=
2
,
CSS_EMS
=
3
,
CSS_EXS
=
4
,
CSS_PX
=
5
,
CSS_CM
=
6
,
CSS_MM
=
7
,
CSS_IN
=
8
,
CSS_PT
=
9
,
CSS_PC
=
10
,
CSS_DEG
=
11
,
CSS_RAD
=
12
,
CSS_GRAD
=
13
,
CSS_MS
=
14
,
CSS_S
=
15
,
CSS_HZ
=
16
,
CSS_KHZ
=
17
,
CSS_DIMENSION
=
18
,
CSS_STRING
=
19
,
CSS_URI
=
20
,
CSS_IDENT
=
21
,
CSS_ATTR
=
22
,
CSS_COUNTER
=
23
,
CSS_RECT
=
24
,
CSS_RGBCOLOR
=
25
,
CSS_DPI
=
26
,
CSS_DPCM
=
27
,
CSS_CHS
=
5
,
CSS_PX
=
6
,
CSS_CM
=
7
,
CSS_MM
=
8
,
CSS_IN
=
9
,
CSS_PT
=
10
,
CSS_PC
=
11
,
CSS_DEG
=
12
,
CSS_RAD
=
13
,
CSS_GRAD
=
14
,
CSS_MS
=
15
,
CSS_S
=
16
,
CSS_HZ
=
17
,
CSS_KHZ
=
18
,
CSS_DIMENSION
=
19
,
CSS_STRING
=
20
,
CSS_URI
=
21
,
CSS_IDENT
=
22
,
CSS_ATTR
=
23
,
CSS_COUNTER
=
24
,
CSS_RECT
=
25
,
CSS_RGBCOLOR
=
26
,
CSS_DPI
=
27
,
CSS_DPCM
=
28
,
CSS_PAIR
=
100
,
// We envision this being exposed as a means of getting computed style values for pairs
CSS_HTML_RELATIVE
=
255
};
...
...
khtml/ecma/kjs_css.cpp
View file @
0fef6992
...
...
@@ -1212,6 +1212,7 @@ const ClassInfo CSSPrimitiveValueConstructor::info = { "CSSPrimitiveValueConstru
CSS_PERCENTAGE DOM::CSSPrimitiveValue::CSS_PERCENTAGE DontDelete|ReadOnly
CSS_EMS DOM::CSSPrimitiveValue::CSS_EMS DontDelete|ReadOnly
CSS_EXS DOM::CSSPrimitiveValue::CSS_EXS DontDelete|ReadOnly
CSS_CHS DOM::CSSPrimitiveValue::CSS_CHS DontDelete|ReadOnly
CSS_PX DOM::CSSPrimitiveValue::CSS_PX DontDelete|ReadOnly
CSS_CM DOM::CSSPrimitiveValue::CSS_CM DontDelete|ReadOnly
CSS_MM DOM::CSSPrimitiveValue::CSS_MM DontDelete|ReadOnly
...
...
khtml/rendering/font.cpp
View file @
0fef6992
...
...
@@ -580,6 +580,13 @@ CachedFontInstance::CachedFontInstance(CachedFontFamily* p, int sz):
descent
=
fm
.
descent
();
height
=
fm
.
height
();
lineSpacing
=
fm
.
lineSpacing
();
const
QChar
zeroChar
((
ushort
)
48
);
if
(
!
fm
.
inFont
(
zeroChar
))
{
m_zeroCharWidth
=
-
1
;
}
else
{
m_zeroCharWidth
=
(
int
)
cachedCharWidth
(
zeroChar
);
}
}
void
CachedFontInstance
::
invalidate
()
...
...
@@ -602,6 +609,13 @@ void CachedFontInstance::invalidate()
descent
=
fm
.
descent
();
height
=
fm
.
height
();
lineSpacing
=
fm
.
lineSpacing
();
const
QChar
zeroChar
((
ushort
)
48
);
if
(
!
fm
.
inFont
(
zeroChar
))
{
m_zeroCharWidth
=
-
1
;
}
else
{
m_zeroCharWidth
=
(
int
)
cachedCharWidth
(
zeroChar
);
}
}
CachedFontInstance
::~
CachedFontInstance
()
...
...
khtml/rendering/font.h
View file @
0fef6992
...
...
@@ -82,6 +82,7 @@ public:
int
descent
;
int
height
;
int
lineSpacing
;
int
m_zeroCharWidth
;
mutable
bool
invalidated
;
~
CachedFontInstance
();
...
...
@@ -241,6 +242,9 @@ public:
int
height
()
const
{
return
cfi
->
height
;
}
int
lineSpacing
()
const
{
return
cfi
->
lineSpacing
;
}
float
xHeight
()
const
{
return
cfi
->
fm
.
xHeight
();
}
// return -1 if '0' char glyph not in font
int
zeroCharWidth
()
const
{
return
cfi
->
m_zeroCharWidth
;
}
//FIXME: IMPLEMENT ME
unsigned
unitsPerEm
()
const
{
return
0
;
}
int
spaceWidth
()
const
{
return
0
;
}
...
...
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