Bug 1717178 - part 3: Get rid of nsIHTMLObjectResizer.refreshResizers() because of unused r=m_kato

Depends on D118798

Differential Revision: https://phabricator.services.mozilla.com/D118799
This commit is contained in:
Masayuki Nakano 2021-06-28 12:08:49 +00:00
parent ab7d00e972
commit 4ac1a649ab
4 changed files with 26 additions and 19 deletions

View File

@ -542,6 +542,8 @@ nsresult HTMLEditor::EndMoving() {
}
nsresult HTMLEditor::SetFinalPosition(int32_t aX, int32_t aY) {
MOZ_ASSERT(IsEditActionDataAvailable());
nsresult rv = EndMoving();
if (NS_FAILED(rv)) {
NS_WARNING("HTMLEditor::EndMoving() failed");
@ -601,9 +603,9 @@ nsresult HTMLEditor::SetFinalPosition(int32_t aX, int32_t aY) {
mPositionedObjectX = newX;
mPositionedObjectY = newY;
rv = RefreshResizers();
rv = RefreshResizersInternal();
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"HTMLEditor::RefreshResizers() failed");
"HTMLEditor::RefreshResizersInternal() failed");
return rv;
}

View File

@ -677,6 +677,12 @@ class HTMLEditor final : public EditorBase,
MOZ_CAN_RUN_SCRIPT nsresult InsertHTMLAsAction(
const nsAString& aInString, nsIPrincipal* aPrincipal = nullptr);
/**
* Refresh positions of resizers. If you change size of target of resizers,
* you need to refresh position of resizers with calling this.
*/
MOZ_CAN_RUN_SCRIPT nsresult RefreshResizers();
protected: // May be called by friends.
/****************************************************************************
* Some friend classes are allowed to call the following protected methods.
@ -4095,7 +4101,7 @@ class HTMLEditor final : public EditorBase,
* RefreshResizersInternal() moves resizers to proper position. This does
* nothing if there is no resizing target.
*/
MOZ_CAN_RUN_SCRIPT nsresult RefreshResizersInternal();
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult RefreshResizersInternal();
ManualNACPtr CreateResizer(int16_t aLocation, nsIContent& aParentContent);
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult

View File

@ -248,7 +248,7 @@ nsresult HTMLEditor::SetAllResizersPosition() {
return NS_OK;
}
NS_IMETHODIMP HTMLEditor::RefreshResizers() {
nsresult HTMLEditor::RefreshResizers() {
AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
if (NS_WARN_IF(!editActionData.CanHandle())) {
return NS_ERROR_NOT_INITIALIZED;
@ -261,6 +261,8 @@ NS_IMETHODIMP HTMLEditor::RefreshResizers() {
}
nsresult HTMLEditor::RefreshResizersInternal() {
MOZ_ASSERT(IsEditActionDataAvailable());
// Don't warn even if resizers are not visible since script cannot check
// if they are visible and this is non-virtual method. So, the cost of
// calling this can be ignored.
@ -296,12 +298,14 @@ nsresult HTMLEditor::RefreshResizersInternal() {
RefPtr<Element> resizingShadow = mResizingShadow.get();
rv = SetShadowPosition(*resizingShadow, resizedObject, mResizedObjectX,
mResizedObjectY);
if (NS_FAILED(rv)) {
NS_WARNING("HTMLEditor::SetShadowPosition() failed");
return rv;
}
if (NS_WARN_IF(resizedObject != mResizedObject)) {
return NS_ERROR_FAILURE;
}
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"HTMLEditor::SetShadowPosition() failed");
return rv;
return NS_OK;
}
nsresult HTMLEditor::ShowResizersInternal(Element& aResizedElement) {
@ -1448,11 +1452,14 @@ nsresult HTMLEditor::SetFinalSizeWithTransaction(int32_t aX, int32_t aY) {
mResizedObjectWidth = width;
mResizedObjectHeight = height;
DebugOnly<nsresult> rvIgnored = RefreshResizersInternal();
nsresult rv = RefreshResizersInternal();
if (rv == NS_ERROR_EDITOR_DESTROYED) {
return NS_ERROR_EDITOR_DESTROYED;
}
NS_WARNING_ASSERTION(
NS_SUCCEEDED(rvIgnored),
NS_SUCCEEDED(rv),
"HTMLEditor::RefreshResizersInternal() failed, but ignored");
return NS_WARN_IF(Destroyed()) ? NS_ERROR_EDITOR_DESTROYED : NS_OK;
return NS_OK;
}
NS_IMETHODIMP HTMLEditor::GetObjectResizingEnabled(

View File

@ -26,7 +26,7 @@ interface nsIHTMLObjectResizer : nsISupports
/**
* a boolean indicating if object resizing is enabled in the editor
*/
[can_run_script] // Setter only.
[setter_can_run_script]
attribute boolean objectResizingEnabled;
/**
@ -34,13 +34,5 @@ interface nsIHTMLObjectResizer : nsISupports
* visible resizers, this does not throw exception, just does nothing.
*/
void hideResizers();
/**
* Refresh positions of resizers. If you change size of target of resizers,
* you need to refresh position of resizers with calling this.
* FYI: Current user in script is only BlueGriffon.
*/
[can_run_script]
void refreshResizers();
};