Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfx_cssnumbervalue.cpp
Go to the documentation of this file.
1
// Copyright 2017 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7
#
include
"core/fxcrt/css/cfx_cssnumbervalue.h"
8
9
#
include
<
math
.
h
>
10
11
CFX_CSSNumberValue::
CFX_CSSNumberValue
(
Unit
unit,
float
value)
12
:
CFX_CSSValue
(
PrimitiveType
::
kNumber
)
, unit_(unit), value_(value) {
13
if
(unit_ ==
Unit
::
kNumber
&& fabs(value_) < 0.001f)
14
value_ = 0.0f;
15
}
16
17
CFX_CSSNumberValue::~
CFX_CSSNumberValue
() =
default
;
18
19
float
CFX_CSSNumberValue::
Apply
(
float
percentBase)
const
{
20
switch
(unit_) {
21
case
Unit
::
kPixels
:
22
case
Unit
::
kNumber
:
23
return
value_ * 72 / 96;
24
case
Unit
::
kEMS
:
25
case
Unit
::
kEXS
:
26
return
value_ * percentBase;
27
case
Unit
::
kPercent
:
28
return
value_ * percentBase / 100.0f;
29
case
Unit
::
kCentiMeters
:
30
return
value_ * 28.3464f;
31
case
Unit
::
kMilliMeters
:
32
return
value_ * 2.8346f;
33
case
Unit
::
kInches
:
34
return
value_ * 72.0f;
35
case
Unit
::
kPicas
:
36
return
value_ / 12.0f;
37
case
Unit
::
kPoints
:
38
return
value_;
39
}
40
return
value_;
41
}
CFX_CSSNumberValue::Unit
Unit
Definition
cfx_cssnumbervalue.h:14
CFX_CSSNumberValue::Unit::kEMS
@ kEMS
CFX_CSSNumberValue::Unit::kPercent
@ kPercent
CFX_CSSNumberValue::Unit::kMilliMeters
@ kMilliMeters
CFX_CSSNumberValue::Unit::kNumber
@ kNumber
CFX_CSSNumberValue::Unit::kEXS
@ kEXS
CFX_CSSNumberValue::Unit::kPoints
@ kPoints
CFX_CSSNumberValue::Unit::kCentiMeters
@ kCentiMeters
CFX_CSSNumberValue::Unit::kPixels
@ kPixels
CFX_CSSNumberValue::Unit::kPicas
@ kPicas
CFX_CSSNumberValue::Unit::kInches
@ kInches
CFX_CSSNumberValue::CFX_CSSNumberValue
CFX_CSSNumberValue(Unit unit, float value)
Definition
cfx_cssnumbervalue.cpp:11
CFX_CSSNumberValue::Apply
float Apply(float percentBase) const
Definition
cfx_cssnumbervalue.cpp:19
CFX_CSSNumberValue::~CFX_CSSNumberValue
~CFX_CSSNumberValue() override
CFX_CSSValue
Definition
cfx_cssvalue.h:13
CFX_CSSValue::CFX_CSSValue
CFX_CSSValue(PrimitiveType type)
Definition
cfx_cssvalue.cpp:9
CFX_CSSValue::PrimitiveType
PrimitiveType
Definition
cfx_cssvalue.h:15
CFX_CSSValue::PrimitiveType::kNumber
@ kNumber
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fxcrt
css
cfx_cssnumbervalue.cpp
Generated on Sat Sep 21 2024 00:55:11 for Qt by
1.12.0