зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 86581d5ccbbb (bug 1436272) for failing /builds/worker/workspace/build/src/editor/libeditor/EditorBase.cpp a=backout on a CLOSED TREE
This commit is contained in:
Родитель
8243da60c5
Коммит
0b674adee4
|
@ -1387,10 +1387,9 @@ nsTextEditorState::PrepareEditor(const nsAString *aValue)
|
|||
// editor's Init() call.
|
||||
|
||||
// Get the DOM document
|
||||
nsCOMPtr<nsIDocument> doc = shell->GetDocument();
|
||||
if (NS_WARN_IF(!doc)) {
|
||||
nsCOMPtr<nsIDOMDocument> domdoc = do_QueryInterface(shell->GetDocument());
|
||||
if (!domdoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// What follows is a bit of a hack. The editor uses the public DOM APIs
|
||||
// for its content manipulations, and it causes it to fail some security
|
||||
|
@ -1401,7 +1400,7 @@ nsTextEditorState::PrepareEditor(const nsAString *aValue)
|
|||
// already does the relevant security checks.
|
||||
AutoNoJSAPI nojsapi;
|
||||
|
||||
rv = newTextEditor->Init(*doc, GetRootNode(), mSelCon, editorFlags,
|
||||
rv = newTextEditor->Init(domdoc, GetRootNode(), mSelCon, editorFlags,
|
||||
defaultValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
|
|
@ -448,17 +448,16 @@ nsEditingSession::SetupEditorOnWindow(mozIDOMWindowProxy* aWindow)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(contentViewer, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = contentViewer->GetDocument();
|
||||
if (NS_WARN_IF(!doc)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCOMPtr<nsIDOMDocument> domDoc =
|
||||
do_QueryInterface(contentViewer->GetDocument());
|
||||
NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE);
|
||||
|
||||
// Set up as a doc state listener
|
||||
// Important! We must have this to broadcast the "obs_documentCreated" message
|
||||
rv = htmlEditor->AddDocumentStateListener(mComposerCommandsUpdater);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = htmlEditor->Init(*doc, nullptr /* root content */,
|
||||
rv = htmlEditor->Init(domDoc, nullptr /* root content */,
|
||||
nullptr, mEditorFlags, EmptyString());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -216,15 +216,19 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(EditorBase)
|
|||
NS_IMPL_CYCLE_COLLECTING_RELEASE(EditorBase)
|
||||
|
||||
|
||||
nsresult
|
||||
EditorBase::Init(nsIDocument& aDocument,
|
||||
Element* aRoot,
|
||||
NS_IMETHODIMP
|
||||
EditorBase::Init(nsIDOMDocument* aDOMDocument,
|
||||
nsIContent* aRoot,
|
||||
nsISelectionController* aSelectionController,
|
||||
uint32_t aFlags,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
MOZ_ASSERT(mAction == EditAction::none,
|
||||
"Initializing during an edit action is an error");
|
||||
MOZ_ASSERT(aDOMDocument);
|
||||
if (!aDOMDocument) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// First only set flags, but other stuff shouldn't be initialized now.
|
||||
// Don't move this call after initializing mDocument.
|
||||
|
@ -236,7 +240,7 @@ EditorBase::Init(nsIDocument& aDocument,
|
|||
SetFlags(aFlags);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "SetFlags() failed");
|
||||
|
||||
mDocument = &aDocument;
|
||||
mDocument = do_QueryInterface(aDOMDocument);
|
||||
// HTML editors currently don't have their own selection controller,
|
||||
// so they'll pass null as aSelCon, and we'll get the selection controller
|
||||
// off of the presshell.
|
||||
|
@ -252,9 +256,8 @@ EditorBase::Init(nsIDocument& aDocument,
|
|||
"Selection controller should be available at this point");
|
||||
|
||||
//set up root element if we are passed one.
|
||||
if (aRoot) {
|
||||
mRootElement = aRoot;
|
||||
}
|
||||
if (aRoot)
|
||||
mRootElement = do_QueryInterface(aRoot);
|
||||
|
||||
mUpdateCount=0;
|
||||
|
||||
|
@ -1350,6 +1353,14 @@ EditorBase::RemoveAttribute(Element* aElement,
|
|||
return DoTransaction(transaction);
|
||||
}
|
||||
|
||||
bool
|
||||
EditorBase::OutputsMozDirty()
|
||||
{
|
||||
// Return true for Composer (!IsInteractionAllowed()) or mail
|
||||
// (IsMailEditor()), but false for webpages.
|
||||
return !IsInteractionAllowed() || IsMailEditor();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EditorBase::MarkNodeDirty(nsIDOMNode* aNode)
|
||||
{
|
||||
|
@ -2498,7 +2509,7 @@ EditorBase::CommitComposition()
|
|||
IMEStateManager::NotifyIME(REQUEST_TO_COMMIT_COMPOSITION, pc) : NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
EditorBase::GetPreferredIMEState(IMEState* aState)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aState);
|
||||
|
@ -5403,6 +5414,12 @@ EditorBase::SwitchTextDirectionTo(uint32_t aDirection)
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
EditorBase::IsModifiableNode(nsIDOMNode* aNode)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
EditorBase::IsModifiableNode(nsINode* aNode)
|
||||
{
|
||||
|
@ -5550,6 +5567,16 @@ EditorBase::SetSuppressDispatchingInputEvent(bool aSuppress)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EditorBase::GetIsInEditAction(bool* aIsInEditAction)
|
||||
{
|
||||
// NOTE: If you need to override this method, you need to make
|
||||
// IsInEditAction() virtual.
|
||||
MOZ_ASSERT(aIsInEditAction, "aIsInEditAction must not be null");
|
||||
*aIsInEditAction = IsInEditAction();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int32_t
|
||||
EditorBase::GetIMESelectionStartOffsetIn(nsINode* aTextNode)
|
||||
{
|
||||
|
|
|
@ -220,23 +220,6 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(EditorBase, nsIEditor)
|
||||
|
||||
/**
|
||||
* Init is to tell the implementation of nsIEditor to begin its services
|
||||
* @param aDoc The dom document interface being observed
|
||||
* @param aRoot This is the root of the editable section of this
|
||||
* document. If it is null then we get root
|
||||
* from document body.
|
||||
* @param aSelCon this should be used to get the selection location
|
||||
* (will be null for HTML editors)
|
||||
* @param aFlags A bitmask of flags for specifying the behavior
|
||||
* of the editor.
|
||||
*/
|
||||
virtual nsresult Init(nsIDocument& doc,
|
||||
Element* aRoot,
|
||||
nsISelectionController* aSelCon,
|
||||
uint32_t aFlags,
|
||||
const nsAString& aInitialValue);
|
||||
|
||||
bool IsInitialized() const { return !!mDocument; }
|
||||
already_AddRefed<nsIDOMDocument> GetDOMDocument();
|
||||
already_AddRefed<nsIDocument> GetDocument();
|
||||
|
@ -474,11 +457,6 @@ public:
|
|||
WidgetCompositionEvent* aCompositionChangeEvet) = 0;
|
||||
void EndIMEComposition();
|
||||
|
||||
/**
|
||||
* Get preferred IME status of current widget.
|
||||
*/
|
||||
virtual nsresult GetPreferredIMEState(widget::IMEState* aState);
|
||||
|
||||
/**
|
||||
* Commit composition if there is.
|
||||
* Note that when there is a composition, this requests to commit composition
|
||||
|
@ -492,11 +470,6 @@ public:
|
|||
|
||||
RangeUpdater& RangeUpdaterRef() { return mRangeUpdater; }
|
||||
|
||||
/**
|
||||
* Finalizes selection and caret for the editor.
|
||||
*/
|
||||
nsresult FinalizeSelection();
|
||||
|
||||
protected:
|
||||
nsresult DetermineCurrentDirection();
|
||||
void FireInputEvent();
|
||||
|
@ -1316,17 +1289,6 @@ public:
|
|||
return mDidPreDestroy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if markNodeDirty() has any effect. Returns false if
|
||||
* markNodeDirty() is a no-op.
|
||||
*/
|
||||
bool OutputsMozDirty() const
|
||||
{
|
||||
// Return true for Composer (!IsInteractionAllowed()) or mail
|
||||
// (IsMailEditor()), but false for webpages.
|
||||
return !IsInteractionAllowed() || IsMailEditor();
|
||||
}
|
||||
|
||||
/**
|
||||
* GetTransactionManager() returns transaction manager associated with the
|
||||
* editor. This may return nullptr if undo/redo hasn't been enabled.
|
||||
|
|
|
@ -231,13 +231,15 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(HTMLEditor)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
|
||||
NS_INTERFACE_MAP_END_INHERITING(TextEditor)
|
||||
|
||||
nsresult
|
||||
HTMLEditor::Init(nsIDocument& aDoc,
|
||||
Element* aRoot,
|
||||
NS_IMETHODIMP
|
||||
HTMLEditor::Init(nsIDOMDocument* aDoc,
|
||||
nsIContent* aRoot,
|
||||
nsISelectionController* aSelCon,
|
||||
uint32_t aFlags,
|
||||
const nsAString& aInitialValue)
|
||||
{
|
||||
NS_PRECONDITION(aDoc && !aSelCon, "bad arg");
|
||||
NS_ENSURE_TRUE(aDoc, NS_ERROR_NULL_POINTER);
|
||||
MOZ_ASSERT(aInitialValue.IsEmpty(), "Non-empty initial values not supported");
|
||||
|
||||
nsresult rulesRv = NS_OK;
|
||||
|
@ -253,7 +255,8 @@ HTMLEditor::Init(nsIDocument& aDoc,
|
|||
}
|
||||
|
||||
// Init mutation observer
|
||||
aDoc.AddMutationObserverUnlessExists(this);
|
||||
nsCOMPtr<nsINode> document = do_QueryInterface(aDoc);
|
||||
document->AddMutationObserverUnlessExists(this);
|
||||
|
||||
if (!mRootElement) {
|
||||
UpdateRootElement();
|
||||
|
@ -3086,8 +3089,7 @@ HTMLEditor::DeleteNode(nsIDOMNode* aNode)
|
|||
{
|
||||
// do nothing if the node is read-only
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
if (NS_WARN_IF(!IsModifiableNode(content) &&
|
||||
!IsMozEditorBogusNode(content))) {
|
||||
if (NS_WARN_IF(!IsModifiableNode(aNode) && !IsMozEditorBogusNode(content))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -3247,6 +3249,13 @@ HTMLEditor::ContentRemoved(nsIDocument* aDocument,
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
HTMLEditor::IsModifiableNode(nsIDOMNode* aNode)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return IsModifiableNode(node);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLEditor::IsModifiableNode(nsINode* aNode)
|
||||
{
|
||||
|
@ -4827,7 +4836,7 @@ HTMLEditor::IsAcceptableInputEvent(WidgetGUIEvent* aGUIEvent)
|
|||
return IsActiveInDOMWindow();
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
HTMLEditor::GetPreferredIMEState(IMEState* aState)
|
||||
{
|
||||
// HTML editor don't prefer the CSS ime-mode because IE didn't do so too.
|
||||
|
|
|
@ -106,15 +106,15 @@ public:
|
|||
bool GetReturnInParagraphCreatesNewParagraph();
|
||||
Element* GetSelectionContainer();
|
||||
|
||||
// nsIEditor overrides
|
||||
NS_IMETHOD GetPreferredIMEState(widget::IMEState* aState) override;
|
||||
|
||||
// nsISelectionListener overrides
|
||||
NS_IMETHOD NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
|
||||
nsISelection* aSelection,
|
||||
int16_t aReason) override;
|
||||
|
||||
// TextEditor overrides
|
||||
virtual nsresult Init(nsIDocument& aDoc, Element* aRoot,
|
||||
nsISelectionController* aSelCon, uint32_t aFlags,
|
||||
const nsAString& aValue) override;
|
||||
NS_IMETHOD BeginningOfDocument() override;
|
||||
virtual nsresult HandleKeyPressEvent(
|
||||
WidgetKeyboardEvent* aKeyboardEvent) override;
|
||||
|
@ -221,10 +221,11 @@ public:
|
|||
// Overrides of EditorBase interface methods
|
||||
virtual nsresult EndUpdateViewBatch() override;
|
||||
|
||||
NS_IMETHOD Init(nsIDOMDocument* aDoc, nsIContent* aRoot,
|
||||
nsISelectionController* aSelCon, uint32_t aFlags,
|
||||
const nsAString& aValue) override;
|
||||
NS_IMETHOD PreDestroy(bool aDestroyingFrames) override;
|
||||
|
||||
virtual nsresult GetPreferredIMEState(widget::IMEState* aState) override;
|
||||
|
||||
/**
|
||||
* @param aElement Must not be null.
|
||||
*/
|
||||
|
@ -390,6 +391,7 @@ public:
|
|||
const EditorRawDOMPoint& aPointToInsert,
|
||||
EditorRawDOMPoint* aPointAfterInsertedString =
|
||||
nullptr) override;
|
||||
NS_IMETHOD_(bool) IsModifiableNode(nsIDOMNode* aNode) override;
|
||||
virtual bool IsModifiableNode(nsINode* aNode) override;
|
||||
|
||||
NS_IMETHOD SelectAll() override;
|
||||
|
|
|
@ -113,13 +113,16 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TextEditor)
|
|||
NS_INTERFACE_MAP_END_INHERITING(EditorBase)
|
||||
|
||||
|
||||
nsresult
|
||||
TextEditor::Init(nsIDocument& aDoc,
|
||||
Element* aRoot,
|
||||
NS_IMETHODIMP
|
||||
TextEditor::Init(nsIDOMDocument* aDoc,
|
||||
nsIContent* aRoot,
|
||||
nsISelectionController* aSelCon,
|
||||
uint32_t aFlags,
|
||||
const nsAString& aInitialValue)
|
||||
{
|
||||
NS_PRECONDITION(aDoc, "bad arg");
|
||||
NS_ENSURE_TRUE(aDoc, NS_ERROR_NULL_POINTER);
|
||||
|
||||
if (mRules) {
|
||||
mRules->DetachEditor();
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@ public:
|
|||
using EditorBase::RemoveAttributeOrEquivalent;
|
||||
using EditorBase::SetAttributeOrEquivalent;
|
||||
|
||||
virtual nsresult Init(nsIDocument& aDoc, Element* aRoot,
|
||||
nsISelectionController* aSelCon, uint32_t aFlags,
|
||||
const nsAString& aValue) override;
|
||||
NS_IMETHOD Init(nsIDOMDocument* aDoc, nsIContent* aRoot,
|
||||
nsISelectionController* aSelCon, uint32_t aFlags,
|
||||
const nsAString& aValue) override;
|
||||
|
||||
nsresult DocumentIsEmpty(bool* aIsEmpty);
|
||||
NS_IMETHOD GetDocumentIsEmpty(bool* aDocumentIsEmpty) override;
|
||||
|
|
|
@ -25,9 +25,14 @@ namespace mozilla {
|
|||
class EditorBase;
|
||||
class HTMLEditor;
|
||||
class TextEditor;
|
||||
namespace widget {
|
||||
struct IMEState;
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
%}
|
||||
|
||||
native IMEState(mozilla::widget::IMEState);
|
||||
|
||||
[scriptable, builtinclass, uuid(094be624-f0bf-400f-89e2-6a84baab9474)]
|
||||
interface nsIEditor : nsISupports
|
||||
{
|
||||
|
@ -48,6 +53,28 @@ interface nsIEditor : nsISupports
|
|||
|
||||
readonly attribute nsISelection selection;
|
||||
|
||||
/**
|
||||
* Finalizes selection and caret for the editor.
|
||||
*/
|
||||
[noscript] void finalizeSelection();
|
||||
|
||||
/**
|
||||
* Init is to tell the implementation of nsIEditor to begin its services
|
||||
* @param aDoc The dom document interface being observed
|
||||
* @param aRoot This is the root of the editable section of this
|
||||
* document. If it is null then we get root
|
||||
* from document body.
|
||||
* @param aSelCon this should be used to get the selection location
|
||||
* (will be null for HTML editors)
|
||||
* @param aFlags A bitmask of flags for specifying the behavior
|
||||
* of the editor.
|
||||
*/
|
||||
[noscript] void init(in nsIDOMDocument doc,
|
||||
in nsIContent aRoot,
|
||||
in nsISelectionController aSelCon,
|
||||
in unsigned long aFlags,
|
||||
in AString initialValue);
|
||||
|
||||
void setAttributeOrEquivalent(in nsIDOMElement element,
|
||||
in AString sourceAttrName,
|
||||
in AString sourceAttrValue,
|
||||
|
@ -451,6 +478,12 @@ interface nsIEditor : nsISupports
|
|||
*/
|
||||
void deleteNode(in nsIDOMNode child);
|
||||
|
||||
/**
|
||||
* Returns true if markNodeDirty() has any effect. Returns false if
|
||||
* markNodeDirty() is a no-op.
|
||||
*/
|
||||
[notxpcom] boolean outputsMozDirty();
|
||||
|
||||
/**
|
||||
* markNodeDirty() sets a special dirty attribute on the node.
|
||||
* Usually this will be called immediately after creating a new node.
|
||||
|
@ -517,14 +550,29 @@ interface nsIEditor : nsISupports
|
|||
/* Run unit tests. Noop in optimized builds */
|
||||
void debugUnitTests(out long outNumTests, out long outNumTestsFailed);
|
||||
|
||||
/* checks if a node is read-only or not */
|
||||
[notxpcom] boolean isModifiableNode(in nsIDOMNode aNode);
|
||||
|
||||
/* Set true if you want to suppress dispatching input event. */
|
||||
attribute boolean suppressDispatchingInputEvent;
|
||||
|
||||
/**
|
||||
* True if an edit action is being handled (in other words, between calls of
|
||||
* nsIEditorObserver::BeforeEditAction() and nsIEditorObserver::EditAction()
|
||||
* or nsIEditorObserver::CancelEditAction(). Otherwise, false.
|
||||
*/
|
||||
[noscript] readonly attribute boolean isInEditAction;
|
||||
|
||||
/**
|
||||
* forceCompositionEnd() force the composition end
|
||||
*/
|
||||
void forceCompositionEnd();
|
||||
|
||||
/**
|
||||
* Get preferred IME status of current widget.
|
||||
*/
|
||||
[noscript] IMEState getPreferredIMEState();
|
||||
|
||||
/**
|
||||
* whether this editor has active IME transaction
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче