diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-12-10 16:19:40 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-12-10 16:01:50 +0000 |
commit | 51f6c2793adab2d864b3d2b360000ef8db1d3e92 (patch) | |
tree | 835b3b4446b012c75e80177cef9fbe6972cc7dbe /chromium/ui/accessibility/ax_position.h | |
parent | 6036726eb981b6c4b42047513b9d3f4ac865daac (diff) | |
download | qtwebengine-chromium-51f6c2793adab2d864b3d2b360000ef8db1d3e92.tar.gz |
BASELINE: Update Chromium to 71.0.3578.93
Change-Id: I6a32086c33670e1b033f8b10e6bf1fd4da1d105d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/ui/accessibility/ax_position.h')
-rw-r--r-- | chromium/ui/accessibility/ax_position.h | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/chromium/ui/accessibility/ax_position.h b/chromium/ui/accessibility/ax_position.h index 6115ded53bb..0f3e6296a32 100644 --- a/chromium/ui/accessibility/ax_position.h +++ b/chromium/ui/accessibility/ax_position.h @@ -20,6 +20,7 @@ #include "base/strings/utf_string_conversions.h" #include "ui/accessibility/ax_enum_util.h" #include "ui/accessibility/ax_enums.mojom.h" +#include "ui/accessibility/ax_tree_id.h" namespace ui { @@ -63,7 +64,7 @@ bool operator!=(const AXPosition<AXPositionType, AXNodeType>& first, // distinguish between "before text" and "after text" positions. To do this, if // the child index is 0 and the anchor is a leaf node, then it's an "after text" // position. If the child index is |BEFORE_TEXT| and the anchor is a leaf node, -// then his is a "before text" position. +// then this is a "before text" position. // It doesn't make sense to have a "before text" position on a text position, // because it is identical to setting its offset to the first character. // @@ -80,13 +81,13 @@ bool operator!=(const AXPosition<AXPositionType, AXNodeType>& first, // // This class can be copied using the |Clone| method. It is designed to be // immutable. + template <class AXPositionType, class AXNodeType> class AXPosition { public: using AXPositionInstance = std::unique_ptr<AXPosition<AXPositionType, AXNodeType>>; - static const int INVALID_TREE_ID = -1; static const int32_t INVALID_ANCHOR_ID = -1; static const int BEFORE_TEXT = -1; static const int INVALID_INDEX = -2; @@ -94,13 +95,13 @@ class AXPosition { static AXPositionInstance CreateNullPosition() { AXPositionInstance new_position(new AXPositionType()); - new_position->Initialize(AXPositionKind::NULL_POSITION, INVALID_TREE_ID, + new_position->Initialize(AXPositionKind::NULL_POSITION, AXTreeIDUnknown(), INVALID_ANCHOR_ID, INVALID_INDEX, INVALID_OFFSET, ax::mojom::TextAffinity::kDownstream); return new_position; } - static AXPositionInstance CreateTreePosition(int tree_id, + static AXPositionInstance CreateTreePosition(AXTreeID tree_id, int32_t anchor_id, int child_index) { AXPositionInstance new_position(new AXPositionType()); @@ -111,7 +112,7 @@ class AXPosition { } static AXPositionInstance CreateTextPosition( - int tree_id, + AXTreeID tree_id, int32_t anchor_id, int text_offset, ax::mojom::TextAffinity affinity) { @@ -139,9 +140,9 @@ class AXPosition { } else { str_child_index = base::IntToString(child_index_); } - str = "TreePosition tree_id=" + base::IntToString(tree_id_) + - " anchor_id=" + base::IntToString(anchor_id_) + " child_index=" + - str_child_index; + str = "TreePosition tree_id=" + tree_id_.ToString() + + " anchor_id=" + base::IntToString(anchor_id_) + + " child_index=" + str_child_index; break; } case AXPositionKind::TEXT_POSITION: { @@ -151,7 +152,7 @@ class AXPosition { } else { str_text_offset = base::IntToString(text_offset_); } - str = "TextPosition tree_id=" + base::IntToString(tree_id_) + + str = "TextPosition tree_id=" + tree_id_.ToString() + " anchor_id=" + base::IntToString(anchor_id_) + " text_offset=" + str_text_offset + " affinity=" + ui::ToString(static_cast<ax::mojom::TextAffinity>(affinity_)); @@ -176,13 +177,12 @@ class AXPosition { return str + " annotated_text=" + annotated_text; } - int tree_id() const { return tree_id_; } + AXTreeID tree_id() const { return tree_id_; } int32_t anchor_id() const { return anchor_id_; } AXNodeType* GetAnchor() const { - if (tree_id_ == INVALID_TREE_ID || anchor_id_ == INVALID_ANCHOR_ID) + if (tree_id_ == AXTreeIDUnknown() || anchor_id_ == INVALID_ANCHOR_ID) return nullptr; - DCHECK_GE(tree_id_, 0); DCHECK_GE(anchor_id_, 0); return GetNodeInTree(tree_id_, anchor_id_); } @@ -513,10 +513,10 @@ class AXPosition { if (child_index < 0 || child_index >= AnchorChildCount()) return CreateNullPosition(); - int tree_id = INVALID_TREE_ID; + AXTreeID tree_id = AXTreeIDUnknown(); int32_t child_id = INVALID_ANCHOR_ID; AnchorChild(child_index, &tree_id, &child_id); - DCHECK_NE(tree_id, INVALID_TREE_ID); + DCHECK_NE(tree_id, AXTreeIDUnknown()); DCHECK_NE(child_id, INVALID_ANCHOR_ID); switch (kind_) { case AXPositionKind::NULL_POSITION: @@ -543,10 +543,10 @@ class AXPosition { if (IsNullPosition()) return CreateNullPosition(); - int tree_id = INVALID_TREE_ID; + AXTreeID tree_id = AXTreeIDUnknown(); int32_t parent_id = INVALID_ANCHOR_ID; AnchorParent(&tree_id, &parent_id); - if (tree_id == INVALID_TREE_ID || parent_id == INVALID_ANCHOR_ID) + if (tree_id == AXTreeIDUnknown() || parent_id == INVALID_ANCHOR_ID) return CreateNullPosition(); switch (kind_) { @@ -1153,7 +1153,7 @@ class AXPosition { const AXPosition<AXPositionType, AXNodeType>& other) = default; virtual void Initialize(AXPositionKind kind, - int tree_id, + AXTreeID tree_id, int32_t anchor_id, int child_index, int text_offset, @@ -1173,7 +1173,7 @@ class AXPosition { (text_offset_ < 0 || text_offset_ > MaxTextOffset()))) { // Reset to the null position. kind_ = AXPositionKind::NULL_POSITION; - tree_id_ = INVALID_TREE_ID; + tree_id_ = AXTreeIDUnknown(); anchor_id_ = INVALID_ANCHOR_ID; child_index_ = INVALID_INDEX; text_offset_ = INVALID_OFFSET; @@ -1267,12 +1267,13 @@ class AXPosition { // Abstract methods. virtual void AnchorChild(int child_index, - int* tree_id, + AXTreeID* tree_id, int32_t* child_id) const = 0; virtual int AnchorChildCount() const = 0; virtual int AnchorIndexInParent() const = 0; - virtual void AnchorParent(int* tree_id, int32_t* parent_id) const = 0; - virtual AXNodeType* GetNodeInTree(int tree_id, int32_t node_id) const = 0; + virtual void AnchorParent(AXTreeID* tree_id, int32_t* parent_id) const = 0; + virtual AXNodeType* GetNodeInTree(AXTreeID tree_id, + int32_t node_id) const = 0; // Returns the length of text that this anchor node takes up in its parent. // On some platforms, embedded objects are represented in their parent with a // single embedded object character. @@ -1285,7 +1286,7 @@ class AXPosition { private: AXPositionKind kind_; - int tree_id_; + AXTreeID tree_id_; int32_t anchor_id_; // For text positions, |child_index_| is initially set to |-1| and only @@ -1299,8 +1300,6 @@ class AXPosition { }; template <class AXPositionType, class AXNodeType> -const int AXPosition<AXPositionType, AXNodeType>::INVALID_TREE_ID; -template <class AXPositionType, class AXNodeType> const int32_t AXPosition<AXPositionType, AXNodeType>::INVALID_ANCHOR_ID; template <class AXPositionType, class AXNodeType> const int AXPosition<AXPositionType, AXNodeType>::BEFORE_TEXT; |