DescriptionMake TextDecoration an enum class.
This patch makes TextDecoration an enum class for better type safety.
However, TextDecoration is a bit flag, so it is often used with bitwise
operators. Enum classes do not have bitwise operators by default, so we
define our own explicitly as needed.
Furthermore, a lot of code involves testing if a bit is set/active in a
TextDecoration. Previously, we could do something like:
if (text_decoration & TextDecoration::kUnderline)
to check if underline is applied. This worked because TextDecoration
could be implicitly converted to a bool. However, enum classes cannot.
With an enum class, it is more verbose and unintuitive:
if ((text_decoration & TextDecoration::kUnderline) !=
TextDecoration::kNone)
Hence, we also provide a helper function called EnumHasFlags that
performs this check:
if (EnumHasFlags(text_decoration, TextDecoration::kUnderline))
BUG=684966
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Review-Url: https://codereview.chromium.org/2845773002
Cr-Commit-Position: refs/heads/master@{#471219}
Committed: https://chromium.googlesource.com/chromium/src/+/9dc275c518d70c4fb4652fdfb5b908d060b53296
Patch Set 1 #
Total comments: 6
Patch Set 2 : Address comments #
Total comments: 7
Patch Set 3 : Rebase #Patch Set 4 : Rebase #Patch Set 5 : Rebase #Patch Set 6 : Rebase #Patch Set 7 : Rebase #Messages
Total messages: 58 (41 generated)
|