mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1688832: part 4) Add AccessibleCaretManager::SelectionStringifyer
. r=TYLin
Will help to simplify `AccessibleCaretManager::Dispatch...`. Differential Revision: https://phabricator.services.mozilla.com/D102920
This commit is contained in:
parent
3d4ea57f64
commit
acee8474e0
@ -77,7 +77,7 @@ std::ostream& operator<<(
|
||||
#undef AC_PROCESS_ENUM_TO_STREAM
|
||||
|
||||
AccessibleCaretManager::AccessibleCaretManager(PresShell* aPresShell)
|
||||
: mPresShell(aPresShell) {
|
||||
: mSelectionStringifyer{mLayoutFlusher}, mPresShell{aPresShell} {
|
||||
if (!mPresShell) {
|
||||
return;
|
||||
}
|
||||
@ -838,13 +838,16 @@ already_AddRefed<nsFrameSelection> AccessibleCaretManager::GetFrameSelection()
|
||||
}
|
||||
|
||||
nsAutoString AccessibleCaretManager::StringifiedSelection() const {
|
||||
nsAutoString str;
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (selection) {
|
||||
selection->Stringify(str, mLayoutFlusher.mAllowFlushing
|
||||
? Selection::FlushFrames::Yes
|
||||
: Selection::FlushFrames::No);
|
||||
}
|
||||
return mSelectionStringifyer.Stringify(*selection);
|
||||
}
|
||||
|
||||
nsAutoString AccessibleCaretManager::SelectionStringifyer::Stringify(
|
||||
Selection& aSelection) const {
|
||||
nsAutoString str;
|
||||
aSelection.Stringify(str, mLayoutFlusher.mAllowFlushing
|
||||
? Selection::FlushFrames::Yes
|
||||
: Selection::FlushFrames::No);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -245,8 +245,39 @@ class AccessibleCaretManager {
|
||||
dom::Selection* GetSelection() const;
|
||||
already_AddRefed<nsFrameSelection> GetFrameSelection() const;
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsAutoString StringifiedSelection() const;
|
||||
class LayoutFlusher final {
|
||||
public:
|
||||
~LayoutFlusher();
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT void MaybeFlush(const PresShell& aPresShell);
|
||||
|
||||
// Set to false to disallow flushing layout in some callbacks such as
|
||||
// OnReflow(), OnScrollStart(), OnScrollStart(), or
|
||||
// OnScrollPositionChanged().
|
||||
bool mAllowFlushing = true;
|
||||
|
||||
private:
|
||||
// Whether we're flushing layout, used for sanity-checking.
|
||||
bool mFlushing = false;
|
||||
};
|
||||
|
||||
LayoutFlusher mLayoutFlusher;
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT nsAutoString StringifiedSelection() const;
|
||||
|
||||
class SelectionStringifyer final {
|
||||
public:
|
||||
explicit SelectionStringifyer(LayoutFlusher& aLayoutFlusher)
|
||||
: mLayoutFlusher{aLayoutFlusher} {}
|
||||
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsAutoString
|
||||
Stringify(dom::Selection& aSelection) const;
|
||||
|
||||
private:
|
||||
LayoutFlusher mLayoutFlusher;
|
||||
};
|
||||
|
||||
SelectionStringifyer mSelectionStringifyer;
|
||||
|
||||
// Get the union of all the child frame scrollable overflow rects for aFrame,
|
||||
// which is used as a helper function to restrict the area where the caret can
|
||||
@ -352,24 +383,6 @@ class AccessibleCaretManager {
|
||||
// Set to true in OnScrollStart() and set to false in OnScrollEnd().
|
||||
bool mIsScrollStarted = false;
|
||||
|
||||
class LayoutFlusher final {
|
||||
public:
|
||||
~LayoutFlusher();
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT void MaybeFlush(const PresShell& aPresShell);
|
||||
|
||||
// Set to false to disallow flushing layout in some callbacks such as
|
||||
// OnReflow(), OnScrollStart(), OnScrollStart(), or
|
||||
// OnScrollPositionChanged().
|
||||
bool mAllowFlushing = true;
|
||||
|
||||
private:
|
||||
// Whether we're flushing layout, used for sanity-checking.
|
||||
bool mFlushing = false;
|
||||
};
|
||||
|
||||
LayoutFlusher mLayoutFlusher;
|
||||
|
||||
// Set to True if one of the caret's position is changed in last update.
|
||||
bool mIsCaretPositionChanged = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user