зеркало из https://github.com/mozilla/gecko-dev.git
Bug 699703 - Need reframe before calling SetSelectionAfterTableEdit. r=masayuki
HTMLEditor::TabInTable inserts row element, then it selects a cell. But when enabling lazy frame construction for editable node, it selects invalid cell and table. Because HTMLEditor::SetSelectionAfterTableEdit doesn't select cell correctly on InsertTableRow(). HTMLEditor::SetSelectionAfterTableEdit uses HTMLEditor::GetCellAt, so it depends on frame. So we need flush frame before calling it. Also, a comment of HTMLEditor::InsertTableRow is invalid now because we don't use nsresult version of CreateElementWithDefualts. MozReview-Commit-ID: 698TvmMZgwB --HG-- extra : rebase_source : 95df12f1f870a2c68d02b24b8758dfe6d381a416
This commit is contained in:
Родитель
094c496d8d
Коммит
9b683468d5
|
@ -1003,6 +1003,11 @@ public:
|
|||
return !mDispatchInputEvent;
|
||||
}
|
||||
|
||||
bool Destroyed() const
|
||||
{
|
||||
return mDidPreDestroy;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetTransactionManager() returns transaction manager associated with the
|
||||
* editor. This may return nullptr if undo/redo hasn't been enabled.
|
||||
|
|
|
@ -657,6 +657,10 @@ HTMLEditor::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent)
|
|||
nsresult rv = NS_OK;
|
||||
if (HTMLEditUtils::IsTableElement(blockParent)) {
|
||||
rv = TabInTable(aKeyboardEvent->IsShift(), &handled);
|
||||
// TabInTable might cause reframe
|
||||
if (Destroyed()) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (handled) {
|
||||
ScrollSelectionIntoView(false);
|
||||
}
|
||||
|
@ -1020,7 +1024,7 @@ HTMLEditor::TypedText(const nsAString& aString,
|
|||
return TextEditor::TypedText(aString, aAction);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
HTMLEditor::TabInTable(bool inIsShift,
|
||||
bool* outHandled)
|
||||
{
|
||||
|
|
|
@ -433,7 +433,7 @@ protected:
|
|||
*/
|
||||
bool SetCaretInTableCell(nsIDOMElement* aElement);
|
||||
|
||||
NS_IMETHOD TabInTable(bool inIsShift, bool* outHandled);
|
||||
nsresult TabInTable(bool inIsShift, bool* outHandled);
|
||||
already_AddRefed<Element> CreateBR(nsINode* aNode, int32_t aOffset,
|
||||
EDirection aSelect = eNone);
|
||||
NS_IMETHOD CreateBR(
|
||||
|
|
|
@ -217,9 +217,14 @@ HTMLEditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
|
|||
NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
|
||||
|
||||
HTMLEditor* htmlEditor = mEditorBase->AsHTMLEditor();
|
||||
RefPtr<HTMLEditor> htmlEditor = mEditorBase->AsHTMLEditor();
|
||||
MOZ_ASSERT(htmlEditor);
|
||||
htmlEditor->DoInlineTableEditingAction(element);
|
||||
// DoInlineTableEditingAction might cause reframe
|
||||
// Editor is destroyed.
|
||||
if (htmlEditor->Destroyed()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return EditorEventListener::MouseClick(aMouseEvent);
|
||||
}
|
||||
|
|
|
@ -174,6 +174,11 @@ HTMLEditor::DoInlineTableEditingAction(nsIDOMElement* aElement)
|
|||
else
|
||||
return NS_OK;
|
||||
|
||||
// InsertTableRow might causes reframe
|
||||
if (Destroyed()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (hideUI) {
|
||||
HideInlineTableEditingUI();
|
||||
if (hideResizersWithInlineTableUI)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "HTMLEditUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/EditorUtils.h"
|
||||
#include "mozilla/FlushType.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsAString.h"
|
||||
|
@ -690,9 +691,16 @@ HTMLEditor::InsertTableRow(int32_t aNumber,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
// XXX This might be the result of the last call of
|
||||
// CreateElementWithDefaults(), otherwise, NS_OK.
|
||||
return rv;
|
||||
|
||||
// SetSelectionAfterTableEdit from AutoSelectionSetterAfterTableEdit will
|
||||
// access frame selection, so we need reframe.
|
||||
// Because GetCellAt depends on frame.
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
if (ps) {
|
||||
ps->FlushPendingNotifications(FlushType::Frames);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Editor helper only
|
||||
|
|
Загрузка…
Ссылка в новой задаче