Prepares AXTextAttributes struct for use in AXRange

This struct is now ready to be used for retrieving the attributes that apply on a specific range.
The kUnsetValue variable was made public so that a particular attribute could be checked if it is unset.
Some stylistic changes were carried out in the process.

[email protected], [email protected]

AX-Relnotes: n/a.
Change-Id: Ib0382c8dda61c1239880ca7b85e2b078e4bca652
Bug: 491027
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3067427
Commit-Queue: Nektarios Paisios <[email protected]>
Reviewed-by: Aaron Leventhal <[email protected]>
Reviewed-by: Abigail Klein <[email protected]>
Cr-Commit-Position: refs/heads/master@{#907973}
diff --git a/ui/accessibility/ax_text_attributes.h b/ui/accessibility/ax_text_attributes.h
index 3ce02c0..5cdb6bb 100644
--- a/ui/accessibility/ax_text_attributes.h
+++ b/ui/accessibility/ax_text_attributes.h
@@ -11,18 +11,21 @@
 
 namespace ui {
 
-// A compact representation of text styles on an AXNode. This data represents
-// a snapshot at a given time and is not intended to be held for periods of
-// time. For this reason, it is a move-only class, to encourage deliberate
-// short-term usage.
-struct AX_BASE_EXPORT AXTextAttributes {
-  AXTextAttributes();
+// A compact representation of text attributes, such as spelling markers and
+// style information, on an `AXNode`. This data represents a snapshot at a given
+// time and is not intended to be held for periods of time. For this reason, it
+// is a move-only class, to encourage deliberate short-term usage.
+struct AX_BASE_EXPORT AXTextAttributes final {
+  // For numeric attributes, the value to be used when a particular attribute is
+  // not set on the `AXNode`, or its value is otherwise unknown.
+  static constexpr int kUnsetValue = -1;
 
-  // Move-only class, explicitly delete copy-construction and assignment
+  AXTextAttributes();
+  ~AXTextAttributes();
+
   AXTextAttributes(const AXTextAttributes& other) = delete;
   AXTextAttributes& operator=(const AXTextAttributes&) = delete;
 
-  // Move constructor and assignment
   AXTextAttributes(AXTextAttributes&& other);
   AXTextAttributes& operator=(AXTextAttributes&& other);
 
@@ -32,17 +35,17 @@
 
   bool IsUnset() const;
 
-  int32_t background_color;
-  int32_t color;
-  int32_t invalid_state;
-  int32_t overline_style;
-  int32_t strikethrough_style;
-  int32_t text_direction;
-  int32_t text_position;
-  int32_t text_style;
-  int32_t underline_style;
-  float font_size;
-  float font_weight;
+  int32_t background_color = kUnsetValue;
+  int32_t color = kUnsetValue;
+  int32_t invalid_state = kUnsetValue;
+  int32_t overline_style = kUnsetValue;
+  int32_t strikethrough_style = kUnsetValue;
+  int32_t text_direction = kUnsetValue;
+  int32_t text_position = kUnsetValue;
+  int32_t text_style = kUnsetValue;
+  int32_t underline_style = kUnsetValue;
+  float font_size = kUnsetValue;
+  float font_weight = kUnsetValue;
   std::string font_family;
 };