Commit c4255857 authored by Emil A Eklund's avatar Emil A Eklund Committed by Commit Bot

[LayoutNG] Optimize NGPhysicalFragment::BorderWidths

Change NGPhysicalFragment::BorderWidths to simplify code and to avoid an
unnecessary cast from float to LayoutUnit per edge.

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Idd2446d08c896c095a4189d1229cdd2f875c0068
Reviewed-on: https://chromium-review.googlesource.com/944514Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540389}
parent b2552be9
......@@ -169,6 +169,10 @@ void AppendFragmentToString(const NGPhysicalFragment* fragment,
builder->Append("\n");
}
LayoutUnit BorderWidth(unsigned edges, unsigned edge, float border_width) {
return (edges & edge) ? LayoutUnit(border_width) : LayoutUnit();
}
} // namespace
// static
......@@ -253,14 +257,10 @@ bool NGPhysicalFragment::IsPlacedByLayoutNG() const {
NGPixelSnappedPhysicalBoxStrut NGPhysicalFragment::BorderWidths() const {
unsigned edges = BorderEdges();
NGPhysicalBoxStrut box_strut(
LayoutUnit((edges & NGBorderEdges::kTop) ? Style().BorderTopWidth()
: .0f),
LayoutUnit((edges & NGBorderEdges::kRight) ? Style().BorderRightWidth()
: .0f),
LayoutUnit((edges & NGBorderEdges::kBottom) ? Style().BorderBottomWidth()
: .0f),
LayoutUnit((edges & NGBorderEdges::kLeft) ? Style().BorderLeftWidth()
: .0f));
BorderWidth(edges, NGBorderEdges::kTop, Style().BorderTopWidth()),
BorderWidth(edges, NGBorderEdges::kRight, Style().BorderRightWidth()),
BorderWidth(edges, NGBorderEdges::kBottom, Style().BorderBottomWidth()),
BorderWidth(edges, NGBorderEdges::kLeft, Style().BorderLeftWidth()));
return box_strut.SnapToDevicePixels();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment