Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
32915417
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
32915417
编写于
1月 14, 2020
作者:
G
Gary Qian
提交者:
GitHub
1月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add FML_DCHECK to ensure layout before calling getters (#15635)
上级
ddaa9dc9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
1 deletion
+16
-1
third_party/txt/src/txt/paragraph_txt.cc
third_party/txt/src/txt/paragraph_txt.cc
+16
-1
未找到文件。
third_party/txt/src/txt/paragraph_txt.cc
浏览文件 @
32915417
...
...
@@ -236,7 +236,7 @@ ParagraphTxt::ParagraphTxt() {
ParagraphTxt
::~
ParagraphTxt
()
=
default
;
void
ParagraphTxt
::
SetText
(
std
::
vector
<
uint16_t
>
text
,
StyledRuns
runs
)
{
needs_layout_
=
true
;
SetDirty
(
true
)
;
if
(
text
.
size
()
==
0
)
return
;
text_
=
std
::
move
(
text
);
...
...
@@ -1277,37 +1277,45 @@ const ParagraphStyle& ParagraphTxt::GetParagraphStyle() const {
}
double
ParagraphTxt
::
GetAlphabeticBaseline
()
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
// Currently -fAscent
return
alphabetic_baseline_
;
}
double
ParagraphTxt
::
GetIdeographicBaseline
()
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
// TODO(garyq): Currently -fAscent + fUnderlinePosition. Verify this.
return
ideographic_baseline_
;
}
double
ParagraphTxt
::
GetMaxIntrinsicWidth
()
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
return
max_intrinsic_width_
;
}
double
ParagraphTxt
::
GetMinIntrinsicWidth
()
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
return
min_intrinsic_width_
;
}
size_t
ParagraphTxt
::
TextSize
()
const
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
return
text_
.
size
();
}
double
ParagraphTxt
::
GetHeight
()
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
return
final_line_count_
==
0
?
0
:
line_metrics_
[
final_line_count_
-
1
].
height
;
}
double
ParagraphTxt
::
GetMaxWidth
()
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
return
width_
;
}
double
ParagraphTxt
::
GetLongestLine
()
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
return
longest_line_
;
}
...
...
@@ -1608,6 +1616,7 @@ std::vector<Paragraph::TextBox> ParagraphTxt::GetRectsForRange(
size_t
end
,
RectHeightStyle
rect_height_style
,
RectWidthStyle
rect_width_style
)
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
// Struct that holds calculated metrics for each line.
struct
LineBoxMetrics
{
std
::
vector
<
Paragraph
::
TextBox
>
boxes
;
...
...
@@ -1818,6 +1827,7 @@ std::vector<Paragraph::TextBox> ParagraphTxt::GetRectsForRange(
Paragraph
::
PositionWithAffinity
ParagraphTxt
::
GetGlyphPositionAtCoordinate
(
double
dx
,
double
dy
)
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
if
(
final_line_count_
<=
0
)
return
PositionWithAffinity
(
0
,
DOWNSTREAM
);
...
...
@@ -1898,6 +1908,7 @@ Paragraph::PositionWithAffinity ParagraphTxt::GetGlyphPositionAtCoordinate(
// We don't cache this because since this returns all boxes, it is usually
// unnecessary to call this multiple times in succession.
std
::
vector
<
Paragraph
::
TextBox
>
ParagraphTxt
::
GetRectsForPlaceholders
()
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
// Struct that holds calculated metrics for each line.
struct
LineBoxMetrics
{
std
::
vector
<
Paragraph
::
TextBox
>
boxes
;
...
...
@@ -1936,6 +1947,7 @@ std::vector<Paragraph::TextBox> ParagraphTxt::GetRectsForPlaceholders() {
}
Paragraph
::
Range
<
size_t
>
ParagraphTxt
::
GetWordBoundary
(
size_t
offset
)
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
if
(
text_
.
size
()
==
0
)
return
Range
<
size_t
>
(
0
,
0
);
...
...
@@ -1959,10 +1971,12 @@ Paragraph::Range<size_t> ParagraphTxt::GetWordBoundary(size_t offset) {
}
size_t
ParagraphTxt
::
GetLineCount
()
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
return
final_line_count_
;
}
bool
ParagraphTxt
::
DidExceedMaxLines
()
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
return
did_exceed_max_lines_
;
}
...
...
@@ -1971,6 +1985,7 @@ void ParagraphTxt::SetDirty(bool dirty) {
}
std
::
vector
<
LineMetrics
>&
ParagraphTxt
::
GetLineMetrics
()
{
FML_DCHECK
(
!
needs_layout_
)
<<
"only valid after layout"
;
return
line_metrics_
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录