Commit b62e2e5d authored by Benjamin Beaudry's avatar Benjamin Beaudry Committed by Commit Bot

Encapsulate text range provider endpoints in helper class

This CL encapsulates both |start_| and |end_| ebdpoints of
AXPlatformNodeTextRangeProviderWin into an helper class with designated
getters and setters. In the follow-up CL:2432805, we are using the
setters to execute extra logic on the new endpoints.

The encapsulation will prevent anyone from setting new endpoints without
going through the setter.

Bug: N/A
Change-Id: Ia6d56391cdd0df42c0fecc87d6e575710dfda758
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2456513
Commit-Queue: Benjamin Beaudry <benjamin.beaudry@microsoft.com>
Reviewed-by: default avatarKurt Catti-Schmidt <kschmi@microsoft.com>
Reviewed-by: default avatarDaniel Libby <dlibby@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#815256}
parent 16d00437
......@@ -44,11 +44,11 @@ class AXPlatformNodeTextProviderTest : public AXPlatformNodeWinTest {
}
const AXNodePosition::AXPositionInstance& GetStart(
const AXPlatformNodeTextRangeProviderWin* text_range) {
return text_range->start_;
return text_range->start();
}
const AXNodePosition::AXPositionInstance& GetEnd(
const AXPlatformNodeTextRangeProviderWin* text_range) {
return text_range->end_;
return text_range->end();
}
};
......
......@@ -112,6 +112,8 @@ class AX_EXPORT __declspec(uuid("3071e40d-a10d-45ff-a59f-6e8e1138e2c1"))
base::string16 GetString(int max_count,
size_t* appended_newlines_count = nullptr);
AXPlatformNodeWin* owner() const;
const AXPositionInstance& start() const { return endpoints_.GetStart(); }
const AXPositionInstance& end() const { return endpoints_.GetEnd(); }
AXPlatformNodeDelegate* GetDelegate(
const AXPositionInstanceType* position) const;
AXPlatformNodeDelegate* GetDelegate(const AXTreeID tree_id,
......@@ -173,6 +175,9 @@ class AX_EXPORT __declspec(uuid("3071e40d-a10d-45ff-a59f-6e8e1138e2c1"))
bool HasCaretOrSelectionInPlainTextField(
const AXPositionInstance& position) const;
void SetStart(AXPositionInstance start);
void SetEnd(AXPositionInstance end);
static bool TextAttributeIsArrayType(TEXTATTRIBUTEID attribute_id);
static bool TextAttributeIsUiaReservedValue(
const base::win::VariantVector& vector);
......@@ -181,8 +186,23 @@ class AX_EXPORT __declspec(uuid("3071e40d-a10d-45ff-a59f-6e8e1138e2c1"))
const base::win::VariantVector& vector);
Microsoft::WRL::ComPtr<AXPlatformNodeWin> owner_;
AXPositionInstance start_;
AXPositionInstance end_;
class TextRangeEndpoints {
public:
TextRangeEndpoints();
~TextRangeEndpoints();
const AXPositionInstance& GetStart() const { return start_; }
const AXPositionInstance& GetEnd() const { return end_; }
void SetStart(AXPositionInstance new_start) {
start_ = std::move(new_start);
}
void SetEnd(AXPositionInstance new_end) { end_ = std::move(new_end); }
private:
AXPositionInstance start_;
AXPositionInstance end_;
};
TextRangeEndpoints endpoints_;
};
} // namespace ui
......
......@@ -165,12 +165,12 @@ class AXPlatformNodeTextRangeProviderTest : public ui::AXPlatformNodeWinTest {
public:
const AXNodePosition::AXPositionInstance& GetStart(
const AXPlatformNodeTextRangeProviderWin* text_range) {
return text_range->start_;
return text_range->start();
}
const AXNodePosition::AXPositionInstance& GetEnd(
const AXPlatformNodeTextRangeProviderWin* text_range) {
return text_range->end_;
return text_range->end();
}
ui::AXPlatformNodeWin* GetOwner(
......
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