Bug 1797148: Simplify checkVisibility API (on nsISelectionController and nsIFrame) into a single nsTextFrame::HasVisibleText method. r=masayuki

Before this patch, we had two `checkVisibilty` methods on the
nsISelectionController interface, backed by several layers of implementation,
ultimately backed by a single function on nsTextFrame (which didn't actually
do anything meaningful with any of the parameters).

As it turns out, this API only had one caller, in HTMLEditUtils.cpp.

This patch converts that caller to directly query nsTextFrame (if the given
node's primary frame is indeed a nsTextFrame).  The direct function-call is
renamed to HasVisibleText(), to be a bit clearer about it being text-specific
and also to avoid confusion with the (unrelated) recently-specified HTML
checkVisibility() API.

With these changes, we can remove the API from the nsISelectionController
interface and its implementations.

This patch also updates the HTMLEditUtils::IsInVisibleTextFrames documentation
(with s/all/any/) to reflect the reality of what the nsTextFrame impl actually
does.

Differential Revision: https://phabricator.services.mozilla.com/D160563
This commit is contained in:
Daniel Holbert
2022-10-28 17:56:04 +00:00
parent 2aed64e73d
commit dbc431214c
10 changed files with 18 additions and 166 deletions

View File

@@ -376,12 +376,6 @@ class TextInputSelectionController final : public nsSupportsWeakReference,
NS_IMETHOD ScrollPage(bool aForward) override;
NS_IMETHOD ScrollLine(bool aForward) override;
NS_IMETHOD ScrollCharacter(bool aRight) override;
NS_IMETHOD CheckVisibility(nsINode* node, int16_t startOffset,
int16_t EndOffset, bool* _retval) override;
virtual nsresult CheckVisibilityContent(nsIContent* aNode,
int16_t aStartOffset,
int16_t aEndOffset,
bool* aRetval) override;
void SelectionWillTakeFocus() override;
void SelectionWillLoseFocus() override;
@@ -781,37 +775,6 @@ void TextInputSelectionController::SelectionWillLoseFocus() {
}
}
NS_IMETHODIMP
TextInputSelectionController::CheckVisibility(nsINode* node,
int16_t startOffset,
int16_t EndOffset,
bool* _retval) {
if (!mPresShellWeak) {
return NS_ERROR_NOT_INITIALIZED;
}
nsresult rv;
nsCOMPtr<nsISelectionController> presShell =
do_QueryReferent(mPresShellWeak, &rv);
if (!presShell) {
return NS_ERROR_FAILURE;
}
return presShell->CheckVisibility(node, startOffset, EndOffset, _retval);
}
nsresult TextInputSelectionController::CheckVisibilityContent(
nsIContent* aNode, int16_t aStartOffset, int16_t aEndOffset,
bool* aRetval) {
if (!mPresShellWeak) {
return NS_ERROR_NOT_INITIALIZED;
}
nsCOMPtr<nsISelectionController> presShell = do_QueryReferent(mPresShellWeak);
if (NS_WARN_IF(!presShell)) {
return NS_ERROR_FAILURE;
}
return presShell->CheckVisibilityContent(aNode, aStartOffset, aEndOffset,
aRetval);
}
/*****************************************************************************
* mozilla::TextInputListener
*****************************************************************************/