2016-07-09 05:42:33 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_HTMLEditor_h
|
|
|
|
#define mozilla_HTMLEditor_h
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
2018-01-26 08:38:05 +03:00
|
|
|
#include "mozilla/ComposerCommandsUpdater.h"
|
2016-07-08 08:03:31 +03:00
|
|
|
#include "mozilla/CSSEditUtils.h"
|
2017-08-02 22:37:44 +03:00
|
|
|
#include "mozilla/ManualNAC.h"
|
2016-09-26 15:03:25 +03:00
|
|
|
#include "mozilla/StyleSheet.h"
|
2016-07-09 05:54:50 +03:00
|
|
|
#include "mozilla/TextEditor.h"
|
2017-02-08 12:14:24 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2016-07-09 05:42:33 +03:00
|
|
|
#include "mozilla/dom/Element.h"
|
|
|
|
#include "mozilla/dom/File.h"
|
|
|
|
|
|
|
|
#include "nsAttrName.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsICSSLoaderObserver.h"
|
|
|
|
#include "nsIDocumentObserver.h"
|
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "nsIEditorMailSupport.h"
|
|
|
|
#include "nsIEditorStyleSheets.h"
|
|
|
|
#include "nsIHTMLAbsPosEditor.h"
|
|
|
|
#include "nsIHTMLEditor.h"
|
|
|
|
#include "nsIHTMLInlineTableEditor.h"
|
|
|
|
#include "nsIHTMLObjectResizer.h"
|
|
|
|
#include "nsITableEditor.h"
|
|
|
|
#include "nsPoint.h"
|
|
|
|
#include "nsStubMutationObserver.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
|
|
|
|
class nsDocumentFragment;
|
2018-04-06 08:53:05 +03:00
|
|
|
class nsHTMLDocument;
|
2016-07-09 05:42:33 +03:00
|
|
|
class nsITransferable;
|
|
|
|
class nsIClipboard;
|
|
|
|
class nsTableWrapperFrame;
|
|
|
|
class nsRange;
|
|
|
|
|
|
|
|
namespace mozilla {
|
2017-08-08 04:57:19 +03:00
|
|
|
class AutoSelectionSetterAfterTableEdit;
|
2018-09-20 13:03:24 +03:00
|
|
|
class AutoSetTemporaryAncestorLimiter;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
class EmptyEditableFunctor;
|
2018-01-26 09:14:04 +03:00
|
|
|
class ResizerSelectionListener;
|
Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled. However, currently, we call smaller
jobs as edit action. For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed. However, for the InputEvent.inputType,
we need inserText information. So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.
And also this renames related stuff:
EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo
MozReview-Commit-ID: cvSkPUjFm1
--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 14:12:34 +03:00
|
|
|
enum class EditSubAction : int32_t;
|
2016-07-09 05:42:33 +03:00
|
|
|
struct PropItem;
|
|
|
|
template <class T>
|
|
|
|
class OwningNonNull;
|
|
|
|
namespace dom {
|
2018-09-09 01:44:23 +03:00
|
|
|
class Blob;
|
2016-07-09 05:42:33 +03:00
|
|
|
class DocumentFragment;
|
2018-04-20 19:53:17 +03:00
|
|
|
class Event;
|
2018-03-20 07:16:05 +03:00
|
|
|
class MouseEvent;
|
2016-07-09 05:42:33 +03:00
|
|
|
} // namespace dom
|
|
|
|
namespace widget {
|
|
|
|
struct IMEState;
|
|
|
|
} // namespace widget
|
|
|
|
|
2016-08-24 15:53:52 +03:00
|
|
|
enum class ParagraphSeparator { div, p, br };
|
|
|
|
|
2016-07-09 05:42:33 +03:00
|
|
|
/**
|
|
|
|
* The HTML editor implementation.<br>
|
|
|
|
* Use to edit HTML document represented as a DOM tree.
|
|
|
|
*/
|
2016-07-09 05:54:50 +03:00
|
|
|
class HTMLEditor final : public TextEditor,
|
2016-07-09 05:42:33 +03:00
|
|
|
public nsIHTMLEditor,
|
|
|
|
public nsIHTMLObjectResizer,
|
|
|
|
public nsIHTMLAbsPosEditor,
|
|
|
|
public nsITableEditor,
|
|
|
|
public nsIHTMLInlineTableEditor,
|
|
|
|
public nsIEditorStyleSheets,
|
|
|
|
public nsStubMutationObserver,
|
2018-07-23 10:45:07 +03:00
|
|
|
public nsIEditorMailSupport {
|
2016-07-09 05:42:33 +03:00
|
|
|
public:
|
2018-05-22 14:15:05 +03:00
|
|
|
/****************************************************************************
|
|
|
|
* NOTE: DO NOT MAKE YOUR NEW METHODS PUBLIC IF they are called by other
|
|
|
|
* classes under libeditor except EditorEventListener and
|
|
|
|
* HTMLEditorEventListener because each public method which may fire
|
|
|
|
* eEditorInput event will need to instantiate new stack class for
|
|
|
|
* managing input type value of eEditorInput and cache some objects
|
|
|
|
* for smarter handling. In other words, when you add new root
|
|
|
|
* method to edit the DOM tree, you can make your new method public.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-07-09 05:42:33 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2016-07-09 05:54:50 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLEditor, TextEditor)
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
// nsStubMutationObserver overrides
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
|
|
|
|
|
|
|
// nsIHTMLEditor methods
|
|
|
|
NS_DECL_NSIHTMLEDITOR
|
|
|
|
|
|
|
|
// nsIHTMLObjectResizer methods (implemented in HTMLObjectResizer.cpp)
|
|
|
|
NS_DECL_NSIHTMLOBJECTRESIZER
|
|
|
|
|
|
|
|
// nsIHTMLAbsPosEditor methods (implemented in HTMLAbsPositionEditor.cpp)
|
|
|
|
NS_DECL_NSIHTMLABSPOSEDITOR
|
|
|
|
|
|
|
|
// nsIHTMLInlineTableEditor methods (implemented in HTMLInlineTableEditor.cpp)
|
|
|
|
NS_DECL_NSIHTMLINLINETABLEEDITOR
|
|
|
|
|
|
|
|
// nsIEditorStyleSheets methods
|
2017-01-27 05:11:09 +03:00
|
|
|
NS_DECL_NSIEDITORSTYLESHEETS
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
// nsIEditorMailSupport methods
|
|
|
|
NS_DECL_NSIEDITORMAILSUPPORT
|
|
|
|
|
|
|
|
// nsITableEditor methods
|
2017-01-27 05:11:09 +03:00
|
|
|
NS_DECL_NSITABLEEDITOR
|
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
// nsISelectionListener overrides
|
|
|
|
NS_DECL_NSISELECTIONLISTENER
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
HTMLEditor();
|
|
|
|
|
|
|
|
nsHTMLDocument* GetHTMLDocument() const;
|
|
|
|
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual void PreDestroy(bool aDestroyingFrames) override;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
bool GetReturnInParagraphCreatesNewParagraph();
|
2018-06-26 07:29:36 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
// TextEditor overrides
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-01-02 16:05:23 +03:00
|
|
|
virtual nsresult Init(Document& aDoc, Element* aRoot,
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsISelectionController* aSelCon, uint32_t aFlags,
|
|
|
|
const nsAString& aValue) override;
|
|
|
|
NS_IMETHOD BeginningOfDocument() override;
|
|
|
|
NS_IMETHOD SetFlags(uint32_t aFlags) override;
|
|
|
|
|
2019-04-25 10:14:39 +03:00
|
|
|
virtual bool CanPaste(int32_t aClipboardType) const override;
|
|
|
|
using EditorBase::CanPaste;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult PasteTransferableAsAction(
|
|
|
|
nsITransferable* aTransferable,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr) override;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
2019-05-08 01:27:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT NS_IMETHOD DeleteNode(nsINode* aNode) override;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
2018-11-03 07:19:22 +03:00
|
|
|
NS_IMETHOD InsertLineBreak() override;
|
|
|
|
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
virtual nsresult HandleKeyPressEvent(
|
|
|
|
WidgetKeyboardEvent* aKeyboardEvent) override;
|
|
|
|
virtual nsIContent* GetFocusedContent() override;
|
|
|
|
virtual already_AddRefed<nsIContent> GetFocusedContentForIME() override;
|
|
|
|
virtual bool IsActiveInDOMWindow() override;
|
|
|
|
virtual dom::EventTarget* GetDOMEventTarget() override;
|
2018-09-20 12:53:35 +03:00
|
|
|
virtual Element* FindSelectionRoot(nsINode* aNode) const override;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
virtual bool IsAcceptableInputEvent(WidgetGUIEvent* aGUIEvent) override;
|
|
|
|
virtual nsresult GetPreferredIMEState(widget::IMEState* aState) override;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2019-06-10 13:27:07 +03:00
|
|
|
/**
|
|
|
|
* PasteNoFormatting() pastes content in clipboard without any style
|
|
|
|
* information.
|
|
|
|
*
|
|
|
|
* @param aSelectionType nsIClipboard::kGlobalClipboard or
|
|
|
|
* nsIClipboard::kSelectionClipboard.
|
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult PasteNoFormattingAsAction(
|
|
|
|
int32_t aSelectionType, nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
2018-07-23 10:34:03 +03:00
|
|
|
/**
|
|
|
|
* PasteAsQuotationAsAction() pastes content in clipboard with newly created
|
|
|
|
* blockquote element. If the editor is in plaintext mode, will paste the
|
|
|
|
* content with appending ">" to start of each line.
|
|
|
|
*
|
|
|
|
* @param aClipboardType nsIClipboard::kGlobalClipboard or
|
|
|
|
* nsIClipboard::kSelectionClipboard.
|
2018-10-10 15:05:39 +03:00
|
|
|
* @param aDispatchPasteEvent true if this should dispatch ePaste event
|
|
|
|
* before pasting. Otherwise, false.
|
2019-06-10 13:27:07 +03:00
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2018-07-23 10:34:03 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult PasteAsQuotationAsAction(
|
|
|
|
int32_t aClipboardType, bool aDispatchPasteEvent,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr) override;
|
2018-07-23 10:34:03 +03:00
|
|
|
|
2016-07-09 05:42:33 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Can we paste |aTransferable| or, if |aTransferable| is null, will a call
|
|
|
|
* to pasteTransferable later possibly succeed if given an instance of
|
|
|
|
* nsITransferable then? True if the doc is modifiable, and, if
|
|
|
|
* |aTransfeable| is non-null, we have pasteable data in |aTransfeable|.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
virtual bool CanPasteTransferable(nsITransferable* aTransferable) override;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2017-10-26 16:54:30 +03:00
|
|
|
/**
|
2018-11-03 14:19:07 +03:00
|
|
|
* InsertLineBreakAsAction() is called when user inputs a line break with
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Shift + Enter or something.
|
2019-06-10 13:27:07 +03:00
|
|
|
*
|
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2017-10-26 16:54:30 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult InsertLineBreakAsAction(
|
|
|
|
nsIPrincipal* aPrincipal = nullptr) override;
|
2018-11-02 17:24:33 +03:00
|
|
|
|
2018-11-03 07:19:22 +03:00
|
|
|
/**
|
|
|
|
* InsertParagraphSeparatorAsAction() is called when user tries to separate
|
|
|
|
* current paragraph with Enter key press in HTMLEditor or something.
|
2019-06-10 13:27:07 +03:00
|
|
|
*
|
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2018-11-03 07:19:22 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
nsresult InsertParagraphSeparatorAsAction(nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
InsertElementAtSelectionAsAction(Element* aElement, bool aDeleteSelection,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult InsertLinkAroundSelectionAsAction(
|
|
|
|
Element* aAnchorElement, nsIPrincipal* aPrincipal = nullptr);
|
2018-11-03 07:19:22 +03:00
|
|
|
|
2018-08-10 13:36:24 +03:00
|
|
|
/**
|
|
|
|
* CreateElementWithDefaults() creates new element whose name is
|
|
|
|
* aTagName with some default attributes are set. Note that this is a
|
|
|
|
* public utility method. I.e., just creates element, not insert it
|
|
|
|
* into the DOM tree.
|
|
|
|
* NOTE: This is available for internal use too since this does not change
|
|
|
|
* the DOM tree nor undo transactions, and does not refer Selection,
|
|
|
|
* HTMLEditRules, etc.
|
|
|
|
*
|
|
|
|
* @param aTagName The new element's tag name. If the name is
|
|
|
|
* one of "href", "anchor" or "namedanchor",
|
|
|
|
* this creates an <a> element.
|
|
|
|
* @return Newly created element.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-08-10 13:36:24 +03:00
|
|
|
already_AddRefed<Element> CreateElementWithDefaults(const nsAtom& aTagName);
|
|
|
|
|
2018-08-14 11:30:09 +03:00
|
|
|
/**
|
|
|
|
* Indent or outdent content around Selection.
|
2019-06-10 13:27:07 +03:00
|
|
|
*
|
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2018-08-14 11:30:09 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
IndentAsAction(nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
OutdentAsAction(nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetParagraphFormatAsAction(
|
|
|
|
const nsAString& aParagraphFormat, nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
|
|
|
nsresult AlignAsAction(const nsAString& aAlignType,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
|
|
|
nsresult RemoveListAsAction(const nsAString& aListType,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult MakeOrChangeListAsAction(
|
|
|
|
const nsAString& aListType, bool entireList, const nsAString& aBulletType,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
2018-08-14 11:30:09 +03:00
|
|
|
|
2017-10-26 16:54:30 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* event callback when a mouse button is pressed
|
|
|
|
* @param aX [IN] horizontal position of the pointer
|
|
|
|
* @param aY [IN] vertical position of the pointer
|
|
|
|
* @param aTarget [IN] the element triggering the event
|
|
|
|
* @param aMouseEvent [IN] the event
|
2017-10-26 16:54:30 +03:00
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult OnMouseDown(int32_t aX, int32_t aY,
|
|
|
|
Element* aTarget,
|
|
|
|
dom::Event* aMouseEvent);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
/**
|
|
|
|
* event callback when a mouse button is released
|
|
|
|
* @param aX [IN] horizontal position of the pointer
|
|
|
|
* @param aY [IN] vertical position of the pointer
|
|
|
|
* @param aTarget [IN] the element triggering the event
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult OnMouseUp(int32_t aX, int32_t aY,
|
|
|
|
Element* aTarget);
|
2018-02-07 09:28:04 +03:00
|
|
|
|
2016-07-09 05:42:33 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* event callback when the mouse pointer is moved
|
|
|
|
* @param aMouseEvent [IN] the event
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
2018-11-06 09:09:18 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult OnMouseMove(dom::MouseEvent* aMouseEvent);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-08-28 12:46:53 +03:00
|
|
|
/**
|
|
|
|
* IsCSSEnabled() returns true if this editor treats styles with style
|
|
|
|
* attribute of HTML elements. Otherwise, if this editor treats all styles
|
|
|
|
* with "font style elements" like <b>, <i>, etc, and <blockquote> to indent,
|
|
|
|
* align attribute to align contents, returns false.
|
|
|
|
*/
|
|
|
|
bool IsCSSEnabled() const {
|
|
|
|
// TODO: removal of mCSSAware and use only the presence of mCSSEditUtils
|
|
|
|
return mCSSAware && mCSSEditUtils && mCSSEditUtils->IsCSSPrefChecked();
|
|
|
|
}
|
|
|
|
|
Bug 1449564 - part 1: Disable object resizer and inline table editor in default r=m_kato
Gecko supports resizers of <img> elements and <table>, <td>, <th> elements and
has UI to remove existing table row or column in default. However, the other
browsers don't have such UI and web apps need to disable this feature with
calling both:
document.execCommand("enableObjectResizing", false, false);
document.execCommand("enableInlineTableEditing", false, false);
for avoiding conflicting with their own features to edit such elements.
Therefore, it doesn't make sense to keep enabling them in default only on
Gecko. If web apps want to keep using these features, they should call:
document.execCommand("enableObjectResizing", false, true);
document.execCommand("enableInlineTableEditing", false, true);
at initializing the editor.
And also this patch fixes bugs of
document.queryCommandState("enableObjectResizing") and
document.queryCommandState("enableInlineTableEditing"). They always return
false even after calling document.execCommand(..., false, true) since
nsSetDocumentStateCommand::GetCommandStateParams() sets bool value as
STATE_ATTRIBUTE. However, nsHTMLDocument::QueryCommandValue() which is the
caller referring STATE_ATTRIBUTE doesn't treat it as bool value. And also
those commands are related to state of document. Therefore, they should be
return as bool value of STATE_ALL instead. Then,
nsHTMLDocument::QueryCommandState() returns the state as expected. Note that
those commands are supported only by Gecko. So, we don't need to worry about
the compatibility.
Finally, this patch rewrites 2 existing tests to check basic behavior of
resizers and appearance of resizers.
Note that this patch does not add new tests to test inline table editor
since it's difficult to test the behavior with current API. Perhaps, we
should add an API to nsIHTMLEditor to retrieve each anonymous elements in
another bug since it requires to add wrapping API of SpecialPowers.
MozReview-Commit-ID: 1FhYo5vcV60
--HG--
rename : editor/libeditor/tests/test_objectResizing.html => editor/libeditor/tests/test_resizers_appearance.html
rename : editor/libeditor/tests/test_bug640321.html => editor/libeditor/tests/test_resizers_resizing_elements.html
extra : rebase_source : a707de5a64ef1f8ce974cdf1be093d1b4f61c7bc
2018-04-02 11:26:46 +03:00
|
|
|
/**
|
|
|
|
* Enable/disable object resizers for <img> elements, <table> elements,
|
|
|
|
* absolute positioned elements (required absolute position editor enabled).
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void EnableObjectResizer(bool aEnable) {
|
2018-08-17 13:03:02 +03:00
|
|
|
if (mIsObjectResizingEnabled == aEnable) {
|
|
|
|
return;
|
|
|
|
}
|
2018-10-30 13:00:17 +03:00
|
|
|
|
|
|
|
AutoEditActionDataSetter editActionData(
|
|
|
|
*this, EditAction::eEnableOrDisableResizer);
|
|
|
|
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Bug 1449564 - part 1: Disable object resizer and inline table editor in default r=m_kato
Gecko supports resizers of <img> elements and <table>, <td>, <th> elements and
has UI to remove existing table row or column in default. However, the other
browsers don't have such UI and web apps need to disable this feature with
calling both:
document.execCommand("enableObjectResizing", false, false);
document.execCommand("enableInlineTableEditing", false, false);
for avoiding conflicting with their own features to edit such elements.
Therefore, it doesn't make sense to keep enabling them in default only on
Gecko. If web apps want to keep using these features, they should call:
document.execCommand("enableObjectResizing", false, true);
document.execCommand("enableInlineTableEditing", false, true);
at initializing the editor.
And also this patch fixes bugs of
document.queryCommandState("enableObjectResizing") and
document.queryCommandState("enableInlineTableEditing"). They always return
false even after calling document.execCommand(..., false, true) since
nsSetDocumentStateCommand::GetCommandStateParams() sets bool value as
STATE_ATTRIBUTE. However, nsHTMLDocument::QueryCommandValue() which is the
caller referring STATE_ATTRIBUTE doesn't treat it as bool value. And also
those commands are related to state of document. Therefore, they should be
return as bool value of STATE_ALL instead. Then,
nsHTMLDocument::QueryCommandState() returns the state as expected. Note that
those commands are supported only by Gecko. So, we don't need to worry about
the compatibility.
Finally, this patch rewrites 2 existing tests to check basic behavior of
resizers and appearance of resizers.
Note that this patch does not add new tests to test inline table editor
since it's difficult to test the behavior with current API. Perhaps, we
should add an API to nsIHTMLEditor to retrieve each anonymous elements in
another bug since it requires to add wrapping API of SpecialPowers.
MozReview-Commit-ID: 1FhYo5vcV60
--HG--
rename : editor/libeditor/tests/test_objectResizing.html => editor/libeditor/tests/test_resizers_appearance.html
rename : editor/libeditor/tests/test_bug640321.html => editor/libeditor/tests/test_resizers_resizing_elements.html
extra : rebase_source : a707de5a64ef1f8ce974cdf1be093d1b4f61c7bc
2018-04-02 11:26:46 +03:00
|
|
|
mIsObjectResizingEnabled = aEnable;
|
2019-05-09 10:37:51 +03:00
|
|
|
RefreshEditingUI();
|
Bug 1449564 - part 1: Disable object resizer and inline table editor in default r=m_kato
Gecko supports resizers of <img> elements and <table>, <td>, <th> elements and
has UI to remove existing table row or column in default. However, the other
browsers don't have such UI and web apps need to disable this feature with
calling both:
document.execCommand("enableObjectResizing", false, false);
document.execCommand("enableInlineTableEditing", false, false);
for avoiding conflicting with their own features to edit such elements.
Therefore, it doesn't make sense to keep enabling them in default only on
Gecko. If web apps want to keep using these features, they should call:
document.execCommand("enableObjectResizing", false, true);
document.execCommand("enableInlineTableEditing", false, true);
at initializing the editor.
And also this patch fixes bugs of
document.queryCommandState("enableObjectResizing") and
document.queryCommandState("enableInlineTableEditing"). They always return
false even after calling document.execCommand(..., false, true) since
nsSetDocumentStateCommand::GetCommandStateParams() sets bool value as
STATE_ATTRIBUTE. However, nsHTMLDocument::QueryCommandValue() which is the
caller referring STATE_ATTRIBUTE doesn't treat it as bool value. And also
those commands are related to state of document. Therefore, they should be
return as bool value of STATE_ALL instead. Then,
nsHTMLDocument::QueryCommandState() returns the state as expected. Note that
those commands are supported only by Gecko. So, we don't need to worry about
the compatibility.
Finally, this patch rewrites 2 existing tests to check basic behavior of
resizers and appearance of resizers.
Note that this patch does not add new tests to test inline table editor
since it's difficult to test the behavior with current API. Perhaps, we
should add an API to nsIHTMLEditor to retrieve each anonymous elements in
another bug since it requires to add wrapping API of SpecialPowers.
MozReview-Commit-ID: 1FhYo5vcV60
--HG--
rename : editor/libeditor/tests/test_objectResizing.html => editor/libeditor/tests/test_resizers_appearance.html
rename : editor/libeditor/tests/test_bug640321.html => editor/libeditor/tests/test_resizers_resizing_elements.html
extra : rebase_source : a707de5a64ef1f8ce974cdf1be093d1b4f61c7bc
2018-04-02 11:26:46 +03:00
|
|
|
}
|
|
|
|
bool IsObjectResizerEnabled() const { return mIsObjectResizingEnabled; }
|
|
|
|
|
Bug 1551185 - Make nsImageFrame::ShouldDisplaySelection() check whether resizer target element is its content or not r=smaug
Currently, `nsISelectionDisplay::DISPLAY_ALL` is used only by `HTMLEditor`.
And only when it's set, `nsImageFrame::ShouldDisplaySelection()` returns `false`
if only its `mContent` is selected. However, this is based on an assumption,
that is, when only one `<img>` is selected in an HTML editor, it's target of
resizers. However, this is completely wrong. Web apps can disable resizers
with `document.execCommand("enableObjectResizing", false, false)` and now,
it's disabled by default.
Therefore, this patch makes the method check whether its `mContent` is
target of resizers at the moment.
Differential Revision: https://phabricator.services.mozilla.com/D32449
--HG--
extra : moz-landing-system : lando
2019-05-24 15:02:34 +03:00
|
|
|
Element* GetResizerTarget() const { return mResizedObject; }
|
|
|
|
|
Bug 1449564 - part 1: Disable object resizer and inline table editor in default r=m_kato
Gecko supports resizers of <img> elements and <table>, <td>, <th> elements and
has UI to remove existing table row or column in default. However, the other
browsers don't have such UI and web apps need to disable this feature with
calling both:
document.execCommand("enableObjectResizing", false, false);
document.execCommand("enableInlineTableEditing", false, false);
for avoiding conflicting with their own features to edit such elements.
Therefore, it doesn't make sense to keep enabling them in default only on
Gecko. If web apps want to keep using these features, they should call:
document.execCommand("enableObjectResizing", false, true);
document.execCommand("enableInlineTableEditing", false, true);
at initializing the editor.
And also this patch fixes bugs of
document.queryCommandState("enableObjectResizing") and
document.queryCommandState("enableInlineTableEditing"). They always return
false even after calling document.execCommand(..., false, true) since
nsSetDocumentStateCommand::GetCommandStateParams() sets bool value as
STATE_ATTRIBUTE. However, nsHTMLDocument::QueryCommandValue() which is the
caller referring STATE_ATTRIBUTE doesn't treat it as bool value. And also
those commands are related to state of document. Therefore, they should be
return as bool value of STATE_ALL instead. Then,
nsHTMLDocument::QueryCommandState() returns the state as expected. Note that
those commands are supported only by Gecko. So, we don't need to worry about
the compatibility.
Finally, this patch rewrites 2 existing tests to check basic behavior of
resizers and appearance of resizers.
Note that this patch does not add new tests to test inline table editor
since it's difficult to test the behavior with current API. Perhaps, we
should add an API to nsIHTMLEditor to retrieve each anonymous elements in
another bug since it requires to add wrapping API of SpecialPowers.
MozReview-Commit-ID: 1FhYo5vcV60
--HG--
rename : editor/libeditor/tests/test_objectResizing.html => editor/libeditor/tests/test_resizers_appearance.html
rename : editor/libeditor/tests/test_bug640321.html => editor/libeditor/tests/test_resizers_resizing_elements.html
extra : rebase_source : a707de5a64ef1f8ce974cdf1be093d1b4f61c7bc
2018-04-02 11:26:46 +03:00
|
|
|
/**
|
|
|
|
* Enable/disable inline table editor, e.g., adding new row or column,
|
|
|
|
* removing existing row or column.
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void EnableInlineTableEditor(bool aEnable) {
|
2018-08-17 13:03:02 +03:00
|
|
|
if (mIsInlineTableEditingEnabled == aEnable) {
|
|
|
|
return;
|
|
|
|
}
|
2018-10-30 13:00:17 +03:00
|
|
|
|
|
|
|
AutoEditActionDataSetter editActionData(
|
|
|
|
*this, EditAction::eEnableOrDisableInlineTableEditingUI);
|
|
|
|
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Bug 1449564 - part 1: Disable object resizer and inline table editor in default r=m_kato
Gecko supports resizers of <img> elements and <table>, <td>, <th> elements and
has UI to remove existing table row or column in default. However, the other
browsers don't have such UI and web apps need to disable this feature with
calling both:
document.execCommand("enableObjectResizing", false, false);
document.execCommand("enableInlineTableEditing", false, false);
for avoiding conflicting with their own features to edit such elements.
Therefore, it doesn't make sense to keep enabling them in default only on
Gecko. If web apps want to keep using these features, they should call:
document.execCommand("enableObjectResizing", false, true);
document.execCommand("enableInlineTableEditing", false, true);
at initializing the editor.
And also this patch fixes bugs of
document.queryCommandState("enableObjectResizing") and
document.queryCommandState("enableInlineTableEditing"). They always return
false even after calling document.execCommand(..., false, true) since
nsSetDocumentStateCommand::GetCommandStateParams() sets bool value as
STATE_ATTRIBUTE. However, nsHTMLDocument::QueryCommandValue() which is the
caller referring STATE_ATTRIBUTE doesn't treat it as bool value. And also
those commands are related to state of document. Therefore, they should be
return as bool value of STATE_ALL instead. Then,
nsHTMLDocument::QueryCommandState() returns the state as expected. Note that
those commands are supported only by Gecko. So, we don't need to worry about
the compatibility.
Finally, this patch rewrites 2 existing tests to check basic behavior of
resizers and appearance of resizers.
Note that this patch does not add new tests to test inline table editor
since it's difficult to test the behavior with current API. Perhaps, we
should add an API to nsIHTMLEditor to retrieve each anonymous elements in
another bug since it requires to add wrapping API of SpecialPowers.
MozReview-Commit-ID: 1FhYo5vcV60
--HG--
rename : editor/libeditor/tests/test_objectResizing.html => editor/libeditor/tests/test_resizers_appearance.html
rename : editor/libeditor/tests/test_bug640321.html => editor/libeditor/tests/test_resizers_resizing_elements.html
extra : rebase_source : a707de5a64ef1f8ce974cdf1be093d1b4f61c7bc
2018-04-02 11:26:46 +03:00
|
|
|
mIsInlineTableEditingEnabled = aEnable;
|
2019-05-09 10:37:51 +03:00
|
|
|
RefreshEditingUI();
|
Bug 1449564 - part 1: Disable object resizer and inline table editor in default r=m_kato
Gecko supports resizers of <img> elements and <table>, <td>, <th> elements and
has UI to remove existing table row or column in default. However, the other
browsers don't have such UI and web apps need to disable this feature with
calling both:
document.execCommand("enableObjectResizing", false, false);
document.execCommand("enableInlineTableEditing", false, false);
for avoiding conflicting with their own features to edit such elements.
Therefore, it doesn't make sense to keep enabling them in default only on
Gecko. If web apps want to keep using these features, they should call:
document.execCommand("enableObjectResizing", false, true);
document.execCommand("enableInlineTableEditing", false, true);
at initializing the editor.
And also this patch fixes bugs of
document.queryCommandState("enableObjectResizing") and
document.queryCommandState("enableInlineTableEditing"). They always return
false even after calling document.execCommand(..., false, true) since
nsSetDocumentStateCommand::GetCommandStateParams() sets bool value as
STATE_ATTRIBUTE. However, nsHTMLDocument::QueryCommandValue() which is the
caller referring STATE_ATTRIBUTE doesn't treat it as bool value. And also
those commands are related to state of document. Therefore, they should be
return as bool value of STATE_ALL instead. Then,
nsHTMLDocument::QueryCommandState() returns the state as expected. Note that
those commands are supported only by Gecko. So, we don't need to worry about
the compatibility.
Finally, this patch rewrites 2 existing tests to check basic behavior of
resizers and appearance of resizers.
Note that this patch does not add new tests to test inline table editor
since it's difficult to test the behavior with current API. Perhaps, we
should add an API to nsIHTMLEditor to retrieve each anonymous elements in
another bug since it requires to add wrapping API of SpecialPowers.
MozReview-Commit-ID: 1FhYo5vcV60
--HG--
rename : editor/libeditor/tests/test_objectResizing.html => editor/libeditor/tests/test_resizers_appearance.html
rename : editor/libeditor/tests/test_bug640321.html => editor/libeditor/tests/test_resizers_resizing_elements.html
extra : rebase_source : a707de5a64ef1f8ce974cdf1be093d1b4f61c7bc
2018-04-02 11:26:46 +03:00
|
|
|
}
|
|
|
|
bool IsInlineTableEditorEnabled() const {
|
|
|
|
return mIsInlineTableEditingEnabled;
|
|
|
|
}
|
|
|
|
|
2018-04-04 16:27:49 +03:00
|
|
|
/**
|
|
|
|
* Enable/disable absolute position editor, resizing absolute positioned
|
|
|
|
* elements (required object resizers enabled) or positioning them with
|
|
|
|
* dragging grabber.
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void EnableAbsolutePositionEditor(bool aEnable) {
|
2018-08-17 13:03:02 +03:00
|
|
|
if (mIsAbsolutelyPositioningEnabled == aEnable) {
|
|
|
|
return;
|
|
|
|
}
|
2018-10-30 13:00:17 +03:00
|
|
|
|
|
|
|
AutoEditActionDataSetter editActionData(
|
|
|
|
*this, EditAction::eEnableOrDisableAbsolutePositionEditor);
|
|
|
|
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-04 16:27:49 +03:00
|
|
|
mIsAbsolutelyPositioningEnabled = aEnable;
|
2019-05-09 10:37:51 +03:00
|
|
|
RefreshEditingUI();
|
2018-04-04 16:27:49 +03:00
|
|
|
}
|
|
|
|
bool IsAbsolutePositionEditorEnabled() const {
|
2017-08-04 12:30:13 +03:00
|
|
|
return mIsAbsolutelyPositioningEnabled;
|
|
|
|
}
|
2018-02-01 04:55:25 +03:00
|
|
|
|
2018-04-04 16:27:49 +03:00
|
|
|
// non-virtual methods of interface methods
|
|
|
|
|
2018-02-01 04:55:25 +03:00
|
|
|
/**
|
|
|
|
* returns the deepest absolutely positioned container of the selection
|
|
|
|
* if it exists or null.
|
|
|
|
*/
|
2019-08-13 10:34:11 +03:00
|
|
|
already_AddRefed<Element> GetAbsolutelyPositionedSelectionContainer() const;
|
2018-02-01 04:55:25 +03:00
|
|
|
|
2017-08-04 12:30:13 +03:00
|
|
|
Element* GetPositionedElement() const { return mAbsolutelyPositionedObject; }
|
2018-02-01 04:55:25 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* extracts the selection from the normal flow of the document and
|
|
|
|
* positions it.
|
2019-06-10 13:27:07 +03:00
|
|
|
*
|
2018-02-01 04:55:25 +03:00
|
|
|
* @param aEnabled [IN] true to absolutely position the selection,
|
|
|
|
* false to put it back in the normal flow
|
2019-06-10 13:27:07 +03:00
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2018-02-01 04:55:25 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
nsresult SetSelectionToAbsoluteOrStaticAsAction(
|
|
|
|
bool aEnabled, nsIPrincipal* aPrincipal = nullptr);
|
2018-02-01 04:55:25 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the absolute z-index of a positioned element. Never returns 'auto'
|
|
|
|
* @return the z-index of the element
|
|
|
|
* @param aElement [IN] the element.
|
|
|
|
*/
|
|
|
|
int32_t GetZIndex(Element& aElement);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* adds aChange to the z-index of the currently positioned element.
|
2019-06-10 13:27:07 +03:00
|
|
|
*
|
2018-02-01 04:55:25 +03:00
|
|
|
* @param aChange [IN] relative change to apply to current z-index
|
2019-06-10 13:27:07 +03:00
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2018-02-01 04:55:25 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
nsresult AddZIndexAsAction(int32_t aChange,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetBackgroundColorAsAction(
|
|
|
|
const nsAString& aColor, nsIPrincipal* aPrincipal = nullptr);
|
2018-02-01 04:55:25 +03:00
|
|
|
|
2018-10-24 07:17:42 +03:00
|
|
|
/**
|
|
|
|
* SetInlinePropertyAsAction() sets a property which changes inline style of
|
|
|
|
* text. E.g., bold, italic, super and sub.
|
|
|
|
* This automatically removes exclusive style, however, treats all changes
|
|
|
|
* as a transaction.
|
2019-06-10 13:27:07 +03:00
|
|
|
*
|
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2018-10-24 07:17:42 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetInlinePropertyAsAction(
|
|
|
|
nsAtom& aProperty, nsAtom* aAttribute, const nsAString& aValue,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
2018-08-13 08:16:10 +03:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult GetInlineProperty(nsAtom* aProperty, nsAtom* aAttribute,
|
2017-08-25 08:40:45 +03:00
|
|
|
const nsAString& aValue, bool* aFirst, bool* aAny,
|
2019-08-12 11:31:04 +03:00
|
|
|
bool* aAll) const;
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult GetInlinePropertyWithAttrValue(nsAtom* aProperty, nsAtom* aAttr,
|
2017-08-25 08:40:45 +03:00
|
|
|
const nsAString& aValue, bool* aFirst,
|
|
|
|
bool* aAny, bool* aAll,
|
|
|
|
nsAString& outValue);
|
2018-10-30 13:00:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* RemoveInlinePropertyAsAction() removes a property which changes inline
|
|
|
|
* style of text. E.g., bold, italic, super and sub.
|
2018-11-30 04:21:59 +03:00
|
|
|
*
|
|
|
|
* @param aProperty Tag name whcih represents the inline style you want to
|
|
|
|
* remove. E.g., nsGkAtoms::strong, nsGkAtoms::b, etc.
|
|
|
|
* If nsGkAtoms::href, <a> element which has href
|
|
|
|
* attribute will be removed.
|
|
|
|
* If nsGkAtoms::name, <a> element which has non-empty
|
|
|
|
* name attribute will be removed.
|
|
|
|
* @param aAttribute If aProperty is nsGkAtoms::font, aAttribute should be
|
|
|
|
* nsGkAtoms::fase, nsGkAtoms::size, nsGkAtoms::color or
|
|
|
|
* nsGkAtoms::bgcolor. Otherwise, set nullptr.
|
|
|
|
* Must not use nsGkAtoms::_empty here.
|
2019-06-10 13:27:07 +03:00
|
|
|
* @param aPrincipal Set subject principal if it may be called by JS. If
|
|
|
|
* set to nullptr, will be treated as called by system.
|
2018-10-30 13:00:17 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
RemoveInlinePropertyAsAction(nsAtom& aProperty, nsAtom* aAttribute,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
RemoveAllInlinePropertiesAsAction(nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
IncreaseFontSizeAsAction(nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
DecreaseFontSizeAsAction(nsIPrincipal* aPrincipal = nullptr);
|
2018-01-26 08:38:05 +03:00
|
|
|
|
2018-08-27 09:52:35 +03:00
|
|
|
/**
|
|
|
|
* GetFontColorState() returns foreground color information in first
|
|
|
|
* range of Selection.
|
|
|
|
* If first range of Selection is collapsed and there is a cache of style for
|
|
|
|
* new text, aIsMixed is set to false and aColor is set to the cached color.
|
|
|
|
* If first range of Selection is collapsed and there is no cached color,
|
|
|
|
* this returns the color of the node, aIsMixed is set to false and aColor is
|
|
|
|
* set to the color.
|
|
|
|
* If first range of Selection is not collapsed, this collects colors of
|
|
|
|
* each node in the range. If there are two or more colors, aIsMixed is set
|
|
|
|
* to true and aColor is truncated. If only one color is set to all of the
|
|
|
|
* range, aIsMixed is set to false and aColor is set to the color.
|
|
|
|
* If there is no Selection ranges, aIsMixed is set to false and aColor is
|
|
|
|
* truncated.
|
|
|
|
*
|
|
|
|
* @param aIsMixed Must not be nullptr. This is set to true
|
|
|
|
* if there is two or more colors in first
|
|
|
|
* range of Selection.
|
|
|
|
* @param aColor Returns the color if only one color is set to
|
|
|
|
* all of first range in Selection. Otherwise,
|
|
|
|
* returns empty string.
|
|
|
|
* @return Returns error only when illegal cases, e.g.,
|
|
|
|
* Selection instance has gone, first range
|
|
|
|
* Selection is broken.
|
|
|
|
*/
|
|
|
|
nsresult GetFontColorState(bool* aIsMixed, nsAString& aColor);
|
|
|
|
|
2018-01-26 08:38:05 +03:00
|
|
|
/**
|
|
|
|
* SetComposerCommandsUpdater() sets or unsets mComposerCommandsUpdater.
|
|
|
|
* This will crash in debug build if the editor already has an instance
|
|
|
|
* but called with another instance.
|
|
|
|
*/
|
|
|
|
void SetComposerCommandsUpdater(
|
|
|
|
ComposerCommandsUpdater* aComposerCommandsUpdater) {
|
|
|
|
MOZ_ASSERT(!aComposerCommandsUpdater || !mComposerCommandsUpdater ||
|
|
|
|
aComposerCommandsUpdater == mComposerCommandsUpdater);
|
|
|
|
mComposerCommandsUpdater = aComposerCommandsUpdater;
|
|
|
|
}
|
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
ParagraphSeparator GetDefaultParagraphSeparator() const {
|
|
|
|
return mDefaultParagraphSeparator;
|
|
|
|
}
|
|
|
|
void SetDefaultParagraphSeparator(ParagraphSeparator aSep) {
|
|
|
|
mDefaultParagraphSeparator = aSep;
|
|
|
|
}
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Modifies the table containing the selection according to the
|
|
|
|
* activation of an inline table editing UI element
|
|
|
|
* @param aUIAnonymousElement [IN] the inline table editing UI element
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult DoInlineTableEditingAction(const Element& aUIAnonymousElement);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1484092 - part 1: Make HTMLEditor::GetElementOrParentByTagName() use nsAtom for the tag name r=m_kato
HTMLElementOrParentByTagName() is the last user of IsLinkTag(const nsAString&)
and IsNamedAnchorTag(const nsAString&). For making their maintenance easier,
let's make GetElementOrParentByTagName() take const nsAtom& for tag name.
GetElementOrParentByTagName() has two functions, one is looking for an element
starting from a node. The other is, if the start node is nullptr, it retrieves
anchor node of Selection as start node. Therefore, this patch splits the
first part to GetElementOrParentByTagNameInternal(). Then, creates its
wrapper which retrieves anchor of Selection automatically,
GetElementOrParentByTagNameAtSelection().
Additionally, this patch makes all internal callers of HTMLEditor use
GetElementOrParentByTagNameInternal() or
GetElementOrParentByTagNameAtSelection() directly. Then, public method,
GetElementOrParentByTagName() is called only by outer classes.
Note that some callers use both GetElementOrParentByTagNameInternal()
and GetElementOrParentByTagNameAtSelection() since they don't check whether
setting node is nullptr. They may be bug of them. We should investigate
the API callers later.
Differential Revision: https://phabricator.services.mozilla.com/D3584
--HG--
extra : moz-landing-system : lando
2018-08-17 17:06:18 +03:00
|
|
|
/**
|
|
|
|
* GetElementOrParentByTagName() looks for an element node whose name matches
|
|
|
|
* aTagName from aNode or anchor node of Selection to <body> element.
|
|
|
|
*
|
|
|
|
* @param aTagName The tag name which you want to look for.
|
|
|
|
* Must not be nsGkAtoms::_empty.
|
|
|
|
* If nsGkAtoms::list, the result may be <ul>, <ol> or
|
|
|
|
* <dl> element.
|
|
|
|
* If nsGkAtoms::td, the result may be <td> or <th>.
|
|
|
|
* If nsGkAtoms::href, the result may be <a> element
|
|
|
|
* which has "href" attribute with non-empty value.
|
2018-08-17 17:50:56 +03:00
|
|
|
* If nsGkAtoms::anchor, the result may be <a> which
|
|
|
|
* has "name" attribute with non-empty value.
|
Bug 1484092 - part 1: Make HTMLEditor::GetElementOrParentByTagName() use nsAtom for the tag name r=m_kato
HTMLElementOrParentByTagName() is the last user of IsLinkTag(const nsAString&)
and IsNamedAnchorTag(const nsAString&). For making their maintenance easier,
let's make GetElementOrParentByTagName() take const nsAtom& for tag name.
GetElementOrParentByTagName() has two functions, one is looking for an element
starting from a node. The other is, if the start node is nullptr, it retrieves
anchor node of Selection as start node. Therefore, this patch splits the
first part to GetElementOrParentByTagNameInternal(). Then, creates its
wrapper which retrieves anchor of Selection automatically,
GetElementOrParentByTagNameAtSelection().
Additionally, this patch makes all internal callers of HTMLEditor use
GetElementOrParentByTagNameInternal() or
GetElementOrParentByTagNameAtSelection() directly. Then, public method,
GetElementOrParentByTagName() is called only by outer classes.
Note that some callers use both GetElementOrParentByTagNameInternal()
and GetElementOrParentByTagNameAtSelection() since they don't check whether
setting node is nullptr. They may be bug of them. We should investigate
the API callers later.
Differential Revision: https://phabricator.services.mozilla.com/D3584
--HG--
extra : moz-landing-system : lando
2018-08-17 17:06:18 +03:00
|
|
|
* @param aNode If non-nullptr, this starts to look for the result
|
|
|
|
* from it. Otherwise, i.e., nullptr, starts from
|
|
|
|
* anchor node of Selection.
|
|
|
|
* @return If an element which matches aTagName, returns
|
|
|
|
* an Element. Otherwise, nullptr.
|
|
|
|
*/
|
2018-08-22 04:20:23 +03:00
|
|
|
Element* GetElementOrParentByTagName(const nsAtom& aTagName,
|
|
|
|
nsINode* aNode) const;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-06-04 11:45:34 +03:00
|
|
|
/**
|
|
|
|
* Get an active editor's editing host in DOM window. If this editor isn't
|
|
|
|
* active in the DOM window, this returns NULL.
|
|
|
|
*/
|
2018-07-30 13:35:43 +03:00
|
|
|
Element* GetActiveEditingHost() const;
|
2018-06-04 11:45:34 +03:00
|
|
|
|
2019-06-04 11:42:43 +03:00
|
|
|
/**
|
|
|
|
* NotifyEditingHostMaybeChanged() is called when new element becomes
|
|
|
|
* contenteditable when the document already had contenteditable elements.
|
|
|
|
*/
|
|
|
|
void NotifyEditingHostMaybeChanged();
|
|
|
|
|
2019-03-30 01:42:32 +03:00
|
|
|
/** Insert a string as quoted text
|
|
|
|
* (whose representation is dependant on the editor type),
|
|
|
|
* replacing the selected text (if any).
|
|
|
|
*
|
|
|
|
* @param aQuotedText The actual text to be quoted
|
|
|
|
* @parem aNodeInserted Return the node which was inserted.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT // USED_BY_COMM_CENTRAL
|
|
|
|
nsresult
|
|
|
|
InsertAsQuotation(const nsAString& aQuotedText, nsINode** aNodeInserted);
|
2019-03-30 01:42:32 +03:00
|
|
|
|
2018-09-14 13:03:24 +03:00
|
|
|
/**
|
|
|
|
* Inserts a plaintext string at the current location,
|
|
|
|
* with special processing for lines beginning with ">",
|
|
|
|
* which will be treated as mail quotes and inserted
|
|
|
|
* as plaintext quoted blocks.
|
|
|
|
* If the selection is not collapsed, the selection is deleted
|
|
|
|
* and the insertion takes place at the resulting collapsed selection.
|
|
|
|
*
|
|
|
|
* @param aString the string to be inserted
|
|
|
|
*/
|
2019-05-08 01:27:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-14 13:03:24 +03:00
|
|
|
nsresult InsertTextWithQuotations(const nsAString& aStringToInsert);
|
|
|
|
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult InsertHTMLAsAction(
|
|
|
|
const nsAString& aInString, nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
protected: // May be called by friends.
|
2018-05-22 14:15:05 +03:00
|
|
|
/****************************************************************************
|
|
|
|
* Some classes like TextEditRules, HTMLEditRules, WSRunObject which are
|
|
|
|
* part of handling edit actions are allowed to call the following protected
|
|
|
|
* methods. However, those methods won't prepare caches of some objects
|
|
|
|
* which are necessary for them. So, if you want some following methods
|
|
|
|
* to do that for you, you need to create a wrapper method in public scope
|
|
|
|
* and call it.
|
|
|
|
****************************************************************************/
|
|
|
|
|
Bug 1569902 - part 4: Make `TextEditor` inserts padding `<br>` element for empty last line after setting flags to `NS_PADDING_FOR_EMPTY_LAST_LINE` r=m_kato
Stopping using attribute for "moz-br", `IMEContentObserver` cannot know when
new `<br>` element is changed to padding element for empty last line.
Therefore, editor needs to insert padding `<br>` element after setting the
flag properly. Then, `IMEContentObserver` does not need to recompute the
length of `<br>` element (if it's for padding, it computes the length as 0).
Unfortunately, `TextEditor::InsertBrElementWithTransaction()` is used in too
many places and it already has optional argument. Therefore, it's difficult
to change it. However, we should share the preparation before creating `<br>`
element in it with new method. Therefore, this patch creates
`EditorBase::PrepareToInsertBRElement()` to share the preparation point (almost
just moved from the method). Then, new method is created as
`EditorBase::InsertPaddingBRElementForEmptyLastLineWithTransaction()` because
it's used both in `TextEditor` and `HTMLEditor`. Finally, `TextEditor` won't
insert `<br>` element with `InsertBrElementWithTransaction()`. Therefore, it's
moved to `HTMLEditor` with renaming to `InsertBRElementWithTransaction()`.
Differential Revision: https://phabricator.services.mozilla.com/D39860
--HG--
extra : moz-landing-system : lando
2019-08-02 08:46:41 +03:00
|
|
|
/**
|
|
|
|
* InsertBRElementWithTransaction() creates a <br> element and inserts it
|
|
|
|
* before aPointToInsert. Then, tries to collapse selection at or after the
|
|
|
|
* new <br> node if aSelect is not eNone.
|
|
|
|
*
|
|
|
|
* @param aPointToInsert The DOM point where should be <br> node inserted
|
|
|
|
* before.
|
|
|
|
* @param aSelect If eNone, this won't change selection.
|
|
|
|
* If eNext, selection will be collapsed after
|
|
|
|
* the <br> element.
|
|
|
|
* If ePrevious, selection will be collapsed at
|
|
|
|
* the <br> element.
|
|
|
|
* @return The new <br> node. If failed to create new
|
|
|
|
* <br> node, returns nullptr.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT already_AddRefed<Element> InsertBRElementWithTransaction(
|
|
|
|
const EditorDOMPoint& aPointToInsert, EDirection aSelect = eNone);
|
|
|
|
|
2018-04-11 13:11:15 +03:00
|
|
|
/**
|
|
|
|
* DeleteSelectionWithTransaction() removes selected content or content
|
|
|
|
* around caret with transactions.
|
|
|
|
*
|
|
|
|
* @param aDirection How much range should be removed.
|
|
|
|
* @param aStripWrappers Whether the parent blocks should be removed
|
|
|
|
* when they become empty.
|
|
|
|
*/
|
2019-05-08 01:27:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-04-11 13:11:15 +03:00
|
|
|
virtual nsresult DeleteSelectionWithTransaction(
|
|
|
|
EDirection aAction, EStripWrappers aStripWrappers) override;
|
2018-04-10 10:23:54 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* DeleteNodeWithTransaction() removes aNode from the DOM tree if it's
|
|
|
|
* modifiable. Note that this is not an override of same method of
|
|
|
|
* EditorBase.
|
|
|
|
*
|
|
|
|
* @param aNode The node to be removed from the DOM tree.
|
|
|
|
*/
|
2019-05-08 01:27:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult DeleteNodeWithTransaction(nsINode& aNode);
|
2018-04-10 10:23:54 +03:00
|
|
|
|
2018-04-10 10:50:06 +03:00
|
|
|
/**
|
2019-07-22 06:53:29 +03:00
|
|
|
* DeleteTextWithTransaction() removes text in the range from aTextNode if
|
2018-04-10 10:50:06 +03:00
|
|
|
* it's modifiable. Note that this not an override of same method of
|
|
|
|
* EditorBase.
|
|
|
|
*
|
2019-07-22 06:53:29 +03:00
|
|
|
* @param aTextNode The text node which should be modified.
|
|
|
|
* @param aOffset Start offset of removing text in aTextNode.
|
2018-04-10 10:50:06 +03:00
|
|
|
* @param aLength Length of removing text.
|
|
|
|
*/
|
2019-07-22 06:53:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult DeleteTextWithTransaction(dom::Text& aTextNode,
|
|
|
|
uint32_t aOffset,
|
|
|
|
uint32_t aLength);
|
2018-04-10 10:50:06 +03:00
|
|
|
|
2019-06-10 13:31:13 +03:00
|
|
|
/**
|
|
|
|
* DeleteParentBlocksIfEmpty() removes parent block elements if they
|
|
|
|
* don't have visible contents. Note that due performance issue of
|
|
|
|
* WSRunObject, this call may be expensive. And also note that this
|
|
|
|
* removes a empty block with a transaction. So, please make sure that
|
|
|
|
* you've already created `AutoPlaceholderBatch`.
|
|
|
|
*
|
|
|
|
* @param aPoint The point whether this method climbing up the DOM
|
|
|
|
* tree to remove empty parent blocks.
|
|
|
|
* @return NS_OK if one or more empty block parents are deleted.
|
|
|
|
* NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND if the point is
|
|
|
|
* not in empty block.
|
|
|
|
* Or NS_ERROR_* if something unexpected occurs.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT MOZ_MUST_USE nsresult
|
|
|
|
DeleteParentBlocksWithTransactionIfEmpty(const EditorDOMPoint& aPoint);
|
|
|
|
|
2018-04-12 11:58:14 +03:00
|
|
|
/**
|
|
|
|
* InsertTextWithTransaction() inserts aStringToInsert at aPointToInsert.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-04-12 11:58:14 +03:00
|
|
|
virtual nsresult InsertTextWithTransaction(
|
2019-01-02 16:05:23 +03:00
|
|
|
Document& aDocument, const nsAString& aStringToInsert,
|
2018-04-12 11:58:14 +03:00
|
|
|
const EditorRawDOMPoint& aPointToInsert,
|
|
|
|
EditorRawDOMPoint* aPointAfterInsertedString = nullptr) override;
|
|
|
|
|
2018-04-16 19:15:23 +03:00
|
|
|
/**
|
|
|
|
* CopyLastEditableChildStyles() clones inline container elements into
|
|
|
|
* aPreviousBlock to aNewBlock to keep using same style in it.
|
|
|
|
*
|
|
|
|
* @param aPreviousBlock The previous block element. All inline
|
|
|
|
* elements which are last sibling of each level
|
|
|
|
* are cloned to aNewBlock.
|
|
|
|
* @param aNewBlock New block container element.
|
|
|
|
* @param aNewBrElement If this method creates a new <br> element for
|
|
|
|
* placeholder, this is set to the new <br>
|
|
|
|
* element.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-04-16 19:15:23 +03:00
|
|
|
nsresult CopyLastEditableChildStylesWithTransaction(
|
|
|
|
Element& aPreviousBlock, Element& aNewBlock,
|
|
|
|
RefPtr<Element>* aNewBrElement);
|
|
|
|
|
2016-07-09 05:42:33 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* RemoveBlockContainerWithTransaction() removes aElement from the DOM tree
|
|
|
|
* but moves its all children to its parent node and if its parent needs <br>
|
|
|
|
* element to have at least one line-height, this inserts <br> element
|
|
|
|
* automatically.
|
|
|
|
*
|
|
|
|
* @param aElement Block element to be removed.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult RemoveBlockContainerWithTransaction(Element& aElement);
|
|
|
|
|
2018-07-30 13:35:43 +03:00
|
|
|
virtual Element* GetEditorRoot() const override;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
using EditorBase::IsEditable;
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
virtual nsresult RemoveAttributeOrEquivalent(
|
|
|
|
Element* aElement, nsAtom* aAttribute,
|
|
|
|
bool aSuppressTransaction) override;
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
virtual nsresult SetAttributeOrEquivalent(Element* aElement,
|
|
|
|
nsAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
bool aSuppressTransaction) override;
|
|
|
|
using EditorBase::RemoveAttributeOrEquivalent;
|
|
|
|
using EditorBase::SetAttributeOrEquivalent;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetBlockNodeParent() returns parent or nearest ancestor of aNode if
|
|
|
|
* there is a block parent. If aAncestorLimiter is not nullptr,
|
|
|
|
* this stops looking for the result.
|
|
|
|
*/
|
|
|
|
static Element* GetBlockNodeParent(nsINode* aNode,
|
|
|
|
nsINode* aAncestorLimiter = nullptr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetBlock() returns aNode itself, or parent or nearest ancestor of aNode
|
|
|
|
* if there is a block parent. If aAncestorLimiter is not nullptr,
|
|
|
|
* this stops looking for the result.
|
|
|
|
*/
|
|
|
|
static Element* GetBlock(nsINode& aNode, nsINode* aAncestorLimiter = nullptr);
|
|
|
|
|
2018-08-16 18:12:51 +03:00
|
|
|
/**
|
|
|
|
* Returns container element of ranges in Selection. If Selection is
|
|
|
|
* collapsed, returns focus container node (or its parent element).
|
|
|
|
* If Selection selects only one element node, returns the element node.
|
|
|
|
* If Selection is only one range, returns common ancestor of the range.
|
|
|
|
* XXX If there are two or more Selection ranges, this returns parent node
|
|
|
|
* of start container of a range which starts with different node from
|
|
|
|
* start container of the first range.
|
|
|
|
*/
|
2018-10-30 13:01:38 +03:00
|
|
|
Element* GetSelectionContainerElement() const;
|
2018-08-16 18:12:51 +03:00
|
|
|
|
2018-08-24 11:29:12 +03:00
|
|
|
/**
|
|
|
|
* GetFirstSelectedTableCellElement() returns a <td> or <th> element if
|
|
|
|
* first range of Selection (i.e., result of Selection::GetRangeAt(0))
|
|
|
|
* selects a <td> element or <th> element. Even if Selection is in
|
|
|
|
* a cell element, this returns nullptr. And even if 2nd or later
|
|
|
|
* range of Selection selects a cell element, also returns nullptr.
|
|
|
|
* Note that when this looks for a cell element, this resets the internal
|
2018-08-27 09:50:12 +03:00
|
|
|
* index of ranges of Selection. When you call
|
|
|
|
* GetNextSelectedTableCellElement() after a call of this, it'll return 2nd
|
|
|
|
* selected cell if there is.
|
2018-08-24 11:29:12 +03:00
|
|
|
*
|
|
|
|
* @param aRv Returns error if there is no selection or
|
|
|
|
* first range of Selection is unexpected.
|
|
|
|
* @return A <td> or <th> element is selected by first
|
|
|
|
* range of Selection. Note that the range must
|
|
|
|
* be: startContaienr and endContainer are same
|
|
|
|
* <tr> element, startOffset + 1 equals endOffset.
|
|
|
|
*/
|
2018-10-30 13:01:38 +03:00
|
|
|
already_AddRefed<Element> GetFirstSelectedTableCellElement(
|
|
|
|
ErrorResult& aRv) const;
|
2018-08-24 11:29:12 +03:00
|
|
|
|
2018-08-27 09:50:12 +03:00
|
|
|
/**
|
|
|
|
* GetNextSelectedTableCellElement() is a stateful method to retrieve
|
|
|
|
* selected table cell elements which are selected by 2nd or later ranges
|
|
|
|
* of Selection. When you call GetFirstSelectedTableCellElement(), it
|
|
|
|
* resets internal counter of this method. Then, following calls of
|
|
|
|
* GetNextSelectedTableCellElement() scans the remaining ranges of Selection.
|
|
|
|
* If a range selects a <td> or <th> element, returns the cell element.
|
|
|
|
* If a range selects an element but neither <td> nor <th> element, this
|
|
|
|
* ignores the range. If a range is in a text node, returns null without
|
|
|
|
* throwing exception, but stops scanning the remaining ranges even you
|
|
|
|
* call this again.
|
|
|
|
* Note that this may cross <table> boundaries since this method just
|
|
|
|
* scans all ranges of Selection. Therefore, returning cells which
|
|
|
|
* belong to different <table> elements.
|
|
|
|
*
|
|
|
|
* @param aRv Returns error if Selection doesn't have
|
|
|
|
* range properly.
|
|
|
|
* @return A <td> or <th> element if one of remaining
|
|
|
|
* ranges selects a <td> or <th> element unless
|
|
|
|
* this does not meet a range in a text node.
|
|
|
|
*/
|
2018-10-30 13:01:38 +03:00
|
|
|
already_AddRefed<Element> GetNextSelectedTableCellElement(
|
|
|
|
ErrorResult& aRv) const;
|
2018-08-27 09:50:12 +03:00
|
|
|
|
2018-09-19 04:58:48 +03:00
|
|
|
/**
|
|
|
|
* DeleteTableCellContentsWithTransaction() removes any contents in cell
|
|
|
|
* elements. If two or more cell elements are selected, this removes
|
|
|
|
* all selected cells' contents. Otherwise, this removes contents of
|
|
|
|
* a cell which contains first selection range. This does not return
|
|
|
|
* error even if selection is not in cell element, just does nothing.
|
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-19 04:58:48 +03:00
|
|
|
nsresult DeleteTableCellContentsWithTransaction();
|
|
|
|
|
2019-08-13 10:34:11 +03:00
|
|
|
static void IsNextCharInNodeWhitespace(nsIContent* aContent, int32_t aOffset,
|
|
|
|
bool* outIsSpace, bool* outIsNBSP,
|
|
|
|
nsIContent** outNode = nullptr,
|
|
|
|
int32_t* outOffset = 0);
|
|
|
|
static void IsPrevCharInNodeWhitespace(nsIContent* aContent, int32_t aOffset,
|
|
|
|
bool* outIsSpace, bool* outIsNBSP,
|
|
|
|
nsIContent** outNode = nullptr,
|
|
|
|
int32_t* outOffset = 0);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
/**
|
2019-08-21 09:21:05 +03:00
|
|
|
* NodeIsBlockStatic() returns true if aElement is an element node and
|
|
|
|
* should be treated as a block.
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
*/
|
2019-08-21 09:21:05 +03:00
|
|
|
static bool NodeIsBlockStatic(const nsINode& aElement);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
2019-08-21 10:13:41 +03:00
|
|
|
/**
|
|
|
|
* NodeIsInlineStatic() returns true if aElement is an element node but
|
|
|
|
* shouldn't be treated as a block or aElement is not an element.
|
|
|
|
* XXX This looks odd. For example, how about a comment node?
|
|
|
|
*/
|
|
|
|
static bool NodeIsInlineStatic(const nsINode& aElement) {
|
|
|
|
return !NodeIsBlockStatic(aElement);
|
|
|
|
}
|
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
/**
|
|
|
|
* extracts an element from the normal flow of the document and
|
|
|
|
* positions it, and puts it back in the normal flow.
|
|
|
|
* @param aElement [IN] the element
|
|
|
|
* @param aEnabled [IN] true to absolutely position the element,
|
|
|
|
* false to put it back in the normal flow
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult SetPositionToAbsoluteOrStatic(Element& aElement, bool aEnabled);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* adds aChange to the z-index of an arbitrary element.
|
|
|
|
* @param aElement [IN] the element
|
|
|
|
* @param aChange [IN] relative change to apply to current z-index of
|
|
|
|
* the element
|
|
|
|
* @param aReturn [OUT] the new z-index of the element
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult RelativeChangeElementZIndex(Element& aElement,
|
|
|
|
int32_t aChange,
|
|
|
|
int32_t* aReturn);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
2019-08-07 18:58:41 +03:00
|
|
|
virtual bool IsBlockNode(nsINode* aNode) const override;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
using EditorBase::IsBlockNode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns true if aParentTag can contain a child of type aChildTag.
|
|
|
|
*/
|
|
|
|
virtual bool TagCanContainTag(nsAtom& aParentTag,
|
|
|
|
nsAtom& aChildTag) const override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if aNode is a container.
|
|
|
|
*/
|
2019-08-07 18:58:41 +03:00
|
|
|
virtual bool IsContainer(nsINode* aNode) const override;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Join together any adjacent editable text nodes in the range.
|
|
|
|
*/
|
2019-05-08 05:29:43 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult CollapseAdjacentTextNodes(nsRange* aRange);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
2017-12-20 09:07:37 +03:00
|
|
|
/**
|
|
|
|
* IsInVisibleTextFrames() returns true if all text in aText is in visible
|
|
|
|
* text frames. Callers have to guarantee that there is no pending reflow.
|
|
|
|
*/
|
2019-08-07 18:58:41 +03:00
|
|
|
bool IsInVisibleTextFrames(dom::Text& aText) const;
|
2017-12-20 09:07:37 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* IsVisibleTextNode() returns true if aText has visible text. If it has
|
|
|
|
* only whitespaces and they are collapsed, returns false.
|
|
|
|
*/
|
2019-08-12 11:31:04 +03:00
|
|
|
bool IsVisibleTextNode(Text& aText) const;
|
2017-12-20 09:07:37 +03:00
|
|
|
|
2016-07-09 05:42:33 +03:00
|
|
|
/**
|
|
|
|
* aNode must be a non-null text node.
|
|
|
|
* outIsEmptyNode must be non-null.
|
|
|
|
*/
|
|
|
|
nsresult IsEmptyNode(nsINode* aNode, bool* outIsEmptyBlock,
|
2019-08-02 08:45:18 +03:00
|
|
|
bool aSingleBRDoesntCount = false,
|
2016-07-09 05:42:33 +03:00
|
|
|
bool aListOrCellNotEmpty = false,
|
2019-08-12 11:31:04 +03:00
|
|
|
bool aSafeToAskFrames = false) const;
|
2016-07-09 05:42:33 +03:00
|
|
|
nsresult IsEmptyNodeImpl(nsINode* aNode, bool* outIsEmptyBlock,
|
2019-08-02 08:45:18 +03:00
|
|
|
bool aSingleBRDoesntCount, bool aListOrCellNotEmpty,
|
2019-08-12 11:31:04 +03:00
|
|
|
bool aSafeToAskFrames, bool* aSeenBR) const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-07-09 05:42:33 +03:00
|
|
|
static bool HasAttributes(Element* aElement) {
|
|
|
|
MOZ_ASSERT(aElement);
|
|
|
|
uint32_t attrCount = aElement->GetAttrCount();
|
|
|
|
return attrCount > 1 ||
|
|
|
|
(1 == attrCount &&
|
|
|
|
!aElement->GetAttrNameAt(0)->Equals(nsGkAtoms::mozdirty));
|
|
|
|
}
|
|
|
|
|
2018-01-10 06:47:16 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Content-based query returns true if <aProperty aAttribute=aValue> effects
|
|
|
|
* aNode. If <aProperty aAttribute=aValue> contains aNode, but
|
|
|
|
* <aProperty aAttribute=SomeOtherValue> also contains aNode and the second is
|
|
|
|
* more deeply nested than the first, then the first does not effect aNode.
|
|
|
|
*
|
|
|
|
* @param aNode The target of the query
|
|
|
|
* @param aProperty The property that we are querying for
|
|
|
|
* @param aAttribute The attribute of aProperty, example: color in
|
|
|
|
* <FONT color="blue"> May be null.
|
|
|
|
* @param aValue The value of aAttribute, example: blue in
|
|
|
|
* <FONT color="blue"> May be null. Ignored if aAttribute
|
|
|
|
* is null.
|
|
|
|
* @param outValue [OUT] the value of the attribute, if aIsSet is true
|
|
|
|
* @return true if <aProperty aAttribute=aValue> effects
|
|
|
|
* aNode.
|
|
|
|
*
|
|
|
|
* The nsIContent variant returns aIsSet instead of using an out parameter.
|
2018-01-10 06:47:16 +03:00
|
|
|
*/
|
2019-08-07 18:58:41 +03:00
|
|
|
static bool IsTextPropertySetByContent(nsINode* aNode, nsAtom* aProperty,
|
|
|
|
nsAtom* aAttribute,
|
|
|
|
const nsAString* aValue,
|
|
|
|
nsAString* outValue = nullptr);
|
2018-01-10 06:47:16 +03:00
|
|
|
|
2018-08-30 08:20:24 +03:00
|
|
|
static dom::Element* GetLinkElement(nsINode* aNode);
|
2018-01-10 06:47:16 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Small utility routine to test if a break node is visible to user.
|
2018-01-10 06:47:16 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
bool IsVisibleBRElement(nsINode* aNode);
|
2018-01-10 06:47:16 +03:00
|
|
|
|
2018-01-19 10:41:41 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Helper routines for font size changing.
|
2018-01-19 10:41:41 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
enum class FontSize { incr, decr };
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult RelativeFontChangeOnTextNode(FontSize aDir, Text& aTextNode,
|
|
|
|
int32_t aStartOffset,
|
|
|
|
int32_t aEndOffset);
|
2018-01-19 10:41:41 +03:00
|
|
|
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult SetInlinePropertyOnNode(nsIContent& aNode, nsAtom& aProperty,
|
|
|
|
nsAtom* aAttribute, const nsAString& aValue);
|
Bug 662591 - HTMLEditor should set caret to start of first editable text node or before first editable inline node r=m_kato
Currently, HTMLEditor doesn't initialize caret position when it gets focus by
itself in most cases. Only when it's in designMode, it may move caret to the
first visible (not checking CSS actually).
In most cases, caret position is adjusted when EditorBase::InitializeSelection()
calls Selection::SetAncestorLimiter(). If selected range is outside of
new limiter, it moves caret to start of the new limiter. However, this is
really different behavior from the other browsers. The other browsers try
to move caret to the first editable text node or before the first editable
content such as <img>, <input>, etc.
This difference causes a serious incompatible issue with Draft.js. It doesn't
initialize caret position when it gets focus but it assumes that caret is
always set to before <br> element if there is no other content.
So, let's try to behave as what other browsers do as far as possible.
This patch makes editor behave as:
* if selection is already in the editing host except start of the editing host,
does nothing.
* if there is non-editable element before any editable node, move caret to
start of the editing host.
* if there is editable text node or element node which cannot have a text node,
move its start or before it.
* if there is no editable nodes which can contain text nodes, move caret to
start of the editing host.
Note that before applying this patch, in designMode, BeginningOfDocument() used
document element instead of <body> element. Therefore, it may set odd position
if <head> element has some text nodes with <script> or <style>. However,
this doesn't make sense and for making more consistent behavior between
designMode and contenteditable, this patch makes it use editing host (it's
<body> element if it's in designMode).
MozReview-Commit-ID: 5neYoTMq6Cc
--HG--
extra : rebase_source : c4d06b6864a221d7cd2833a007d73f7d67821e95
2018-03-02 08:20:25 +03:00
|
|
|
|
2019-05-08 01:34:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult SplitStyleAbovePoint(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
|
|
|
|
nsAtom* aProperty, nsAtom* aAttribute,
|
|
|
|
nsIContent** aOutLeftNode = nullptr,
|
|
|
|
nsIContent** aOutRightNode = nullptr);
|
2018-04-06 08:53:05 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsIContent* GetPriorHTMLSibling(nsINode* aNode);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsIContent* GetNextHTMLSibling(nsINode* aNode);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* GetPreviousHTMLElementOrText*() methods are similar to
|
|
|
|
* EditorBase::GetPreviousElementOrText*() but this won't return nodes
|
|
|
|
* outside active editing host.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsIContent* GetPreviousHTMLElementOrText(nsINode& aNode) {
|
|
|
|
return GetPreviousHTMLElementOrTextInternal(aNode, false);
|
|
|
|
}
|
|
|
|
nsIContent* GetPreviousHTMLElementOrTextInBlock(nsINode& aNode) {
|
|
|
|
return GetPreviousHTMLElementOrTextInternal(aNode, true);
|
|
|
|
}
|
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetPreviousHTMLElementOrText(
|
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint) {
|
|
|
|
return GetPreviousHTMLElementOrTextInternal(aPoint, false);
|
|
|
|
}
|
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetPreviousHTMLElementOrTextInBlock(
|
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint) {
|
|
|
|
return GetPreviousHTMLElementOrTextInternal(aPoint, true);
|
|
|
|
}
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2017-11-21 08:38:19 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* GetPreviousHTMLElementOrTextInternal() methods are common implementation
|
|
|
|
* of above methods. Please don't use this method directly.
|
2017-11-21 08:38:19 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsIContent* GetPreviousHTMLElementOrTextInternal(nsINode& aNode,
|
|
|
|
bool aNoBlockCrossing);
|
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetPreviousHTMLElementOrTextInternal(
|
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint, bool aNoBlockCrossing);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* GetPreviousEditableHTMLNode*() methods are similar to
|
|
|
|
* EditorBase::GetPreviousEditableNode() but this won't return nodes outside
|
|
|
|
* active editing host.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsIContent* GetPreviousEditableHTMLNode(nsINode& aNode) {
|
|
|
|
return GetPreviousEditableHTMLNodeInternal(aNode, false);
|
|
|
|
}
|
|
|
|
nsIContent* GetPreviousEditableHTMLNodeInBlock(nsINode& aNode) {
|
|
|
|
return GetPreviousEditableHTMLNodeInternal(aNode, true);
|
|
|
|
}
|
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetPreviousEditableHTMLNode(
|
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint) {
|
|
|
|
return GetPreviousEditableHTMLNodeInternal(aPoint, false);
|
|
|
|
}
|
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetPreviousEditableHTMLNodeInBlock(
|
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint) {
|
|
|
|
return GetPreviousEditableHTMLNodeInternal(aPoint, true);
|
|
|
|
}
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* GetPreviousEditableHTMLNodeInternal() methods are common implementation
|
|
|
|
* of above methods. Please don't use this method directly.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsIContent* GetPreviousEditableHTMLNodeInternal(nsINode& aNode,
|
|
|
|
bool aNoBlockCrossing);
|
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetPreviousEditableHTMLNodeInternal(
|
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint, bool aNoBlockCrossing);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* GetNextHTMLElementOrText*() methods are similar to
|
|
|
|
* EditorBase::GetNextElementOrText*() but this won't return nodes outside
|
|
|
|
* active editing host.
|
|
|
|
*
|
|
|
|
* Note that same as EditorBase::GetTextEditableNode(), methods which take
|
|
|
|
* |const EditorRawDOMPoint&| start to search from the node pointed by it.
|
|
|
|
* On the other hand, methods which take |nsINode&| start to search from
|
|
|
|
* next node of aNode.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsIContent* GetNextHTMLElementOrText(nsINode& aNode) {
|
|
|
|
return GetNextHTMLElementOrTextInternal(aNode, false);
|
|
|
|
}
|
|
|
|
nsIContent* GetNextHTMLElementOrTextInBlock(nsINode& aNode) {
|
|
|
|
return GetNextHTMLElementOrTextInternal(aNode, true);
|
|
|
|
}
|
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetNextHTMLElementOrText(
|
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint) {
|
|
|
|
return GetNextHTMLElementOrTextInternal(aPoint, false);
|
|
|
|
}
|
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetNextHTMLElementOrTextInBlock(
|
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint) {
|
|
|
|
return GetNextHTMLElementOrTextInternal(aPoint, true);
|
|
|
|
}
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* GetNextHTMLNodeInternal() methods are common implementation
|
|
|
|
* of above methods. Please don't use this method directly.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsIContent* GetNextHTMLElementOrTextInternal(nsINode& aNode,
|
|
|
|
bool aNoBlockCrossing);
|
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetNextHTMLElementOrTextInternal(
|
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint, bool aNoBlockCrossing);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* GetNextEditableHTMLNode*() methods are similar to
|
|
|
|
* EditorBase::GetNextEditableNode() but this won't return nodes outside
|
|
|
|
* active editing host.
|
|
|
|
*
|
|
|
|
* Note that same as EditorBase::GetTextEditableNode(), methods which take
|
|
|
|
* |const EditorRawDOMPoint&| start to search from the node pointed by it.
|
|
|
|
* On the other hand, methods which take |nsINode&| start to search from
|
|
|
|
* next node of aNode.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
2019-08-13 10:34:11 +03:00
|
|
|
nsIContent* GetNextEditableHTMLNode(nsINode& aNode) const {
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
return GetNextEditableHTMLNodeInternal(aNode, false);
|
|
|
|
}
|
2019-08-13 10:34:11 +03:00
|
|
|
nsIContent* GetNextEditableHTMLNodeInBlock(nsINode& aNode) const {
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
return GetNextEditableHTMLNodeInternal(aNode, true);
|
|
|
|
}
|
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetNextEditableHTMLNode(
|
2019-08-13 10:34:11 +03:00
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint) const {
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
return GetNextEditableHTMLNodeInternal(aPoint, false);
|
|
|
|
}
|
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetNextEditableHTMLNodeInBlock(
|
2019-08-13 10:34:11 +03:00
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint) const {
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
return GetNextEditableHTMLNodeInternal(aPoint, true);
|
|
|
|
}
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* GetNextEditableHTMLNodeInternal() methods are common implementation
|
|
|
|
* of above methods. Please don't use this method directly.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsIContent* GetNextEditableHTMLNodeInternal(nsINode& aNode,
|
2019-08-13 10:34:11 +03:00
|
|
|
bool aNoBlockCrossing) const;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
template <typename PT, typename CT>
|
|
|
|
nsIContent* GetNextEditableHTMLNodeInternal(
|
2019-08-13 10:34:11 +03:00
|
|
|
const EditorDOMPointBase<PT, CT>& aPoint, bool aNoBlockCrossing) const;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
bool IsFirstEditableChild(nsINode* aNode);
|
|
|
|
bool IsLastEditableChild(nsINode* aNode);
|
|
|
|
nsIContent* GetFirstEditableChild(nsINode& aNode);
|
|
|
|
nsIContent* GetLastEditableChild(nsINode& aNode);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsIContent* GetFirstEditableLeaf(nsINode& aNode);
|
|
|
|
nsIContent* GetLastEditableLeaf(nsINode& aNode);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult GetInlinePropertyBase(nsAtom& aProperty, nsAtom* aAttribute,
|
|
|
|
const nsAString* aValue, bool* aFirst,
|
2019-08-12 11:31:04 +03:00
|
|
|
bool* aAny, bool* aAll,
|
|
|
|
nsAString* outValue) const;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult ClearStyle(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
|
|
|
|
nsAtom* aProperty, nsAtom* aAttribute);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2019-05-08 01:34:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetPositionToAbsolute(Element& aElement);
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetPositionToStatic(Element& aElement);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-10-25 08:55:04 +03:00
|
|
|
/**
|
|
|
|
* OnModifyDocument() is called when the editor is changed. This should
|
|
|
|
* be called only by HTMLEditRules::DocumentModifiedWorker() to call
|
2018-10-30 13:00:17 +03:00
|
|
|
* HTMLEditRules::OnModifyDocument() with AutoEditActionDataSetter
|
|
|
|
* instance.
|
2018-10-25 08:55:04 +03:00
|
|
|
*/
|
2019-08-13 03:56:57 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT MOZ_MUST_USE nsresult OnModifyDocument();
|
2018-10-25 08:55:04 +03:00
|
|
|
|
2019-08-22 04:10:30 +03:00
|
|
|
protected: // edit sub-action handler
|
|
|
|
/**
|
|
|
|
* GetInlineStyles() retrieves the style of aNode and modifies each item of
|
|
|
|
* aStyleCacheArray. This might cause flushing layout at retrieving computed
|
|
|
|
* values of CSS properties.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT MOZ_MUST_USE nsresult
|
|
|
|
GetInlineStyles(nsINode& aNode, AutoStyleCacheArray& aStyleCacheArray);
|
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
protected: // Called by helper classes.
|
Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled. However, currently, we call smaller
jobs as edit action. For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed. However, for the InputEvent.inputType,
we need inserText information. So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.
And also this renames related stuff:
EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo
MozReview-Commit-ID: cvSkPUjFm1
--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 14:12:34 +03:00
|
|
|
virtual void OnStartToHandleTopLevelEditSubAction(
|
|
|
|
EditSubAction aEditSubAction, nsIEditor::EDirection aDirection) override;
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled. However, currently, we call smaller
jobs as edit action. For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed. However, for the InputEvent.inputType,
we need inserText information. So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.
And also this renames related stuff:
EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo
MozReview-Commit-ID: cvSkPUjFm1
--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 14:12:34 +03:00
|
|
|
virtual void OnEndHandlingTopLevelEditSubAction() override;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
protected: // Shouldn't be used by friend classes
|
|
|
|
virtual ~HTMLEditor();
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-11-03 07:19:22 +03:00
|
|
|
/**
|
|
|
|
* InsertParagraphSeparatorAsSubAction() inserts a line break if it's
|
|
|
|
* HTMLEditor and it's possible.
|
|
|
|
*/
|
|
|
|
nsresult InsertParagraphSeparatorAsSubAction();
|
|
|
|
|
2019-03-26 13:06:43 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-06-07 16:30:14 +03:00
|
|
|
virtual nsresult SelectAllInternal() override;
|
|
|
|
|
2018-08-15 11:59:40 +03:00
|
|
|
/**
|
|
|
|
* SelectContentInternal() sets Selection to aContentToSelect to
|
|
|
|
* aContentToSelect + 1 in parent of aContentToSelect.
|
|
|
|
*
|
|
|
|
* @param aContentToSelect The content which should be selected.
|
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-10-30 13:01:38 +03:00
|
|
|
nsresult SelectContentInternal(nsIContent& aContentToSelect);
|
2018-08-15 11:59:40 +03:00
|
|
|
|
2018-08-14 09:13:54 +03:00
|
|
|
/**
|
|
|
|
* CollapseSelectionAfter() collapses Selection after aElement.
|
|
|
|
* If aElement is an orphan node or not in editing host, returns error.
|
|
|
|
*/
|
2018-10-30 13:01:38 +03:00
|
|
|
nsresult CollapseSelectionAfter(Element& aElement);
|
2018-08-14 09:13:54 +03:00
|
|
|
|
Bug 1484092 - part 1: Make HTMLEditor::GetElementOrParentByTagName() use nsAtom for the tag name r=m_kato
HTMLElementOrParentByTagName() is the last user of IsLinkTag(const nsAString&)
and IsNamedAnchorTag(const nsAString&). For making their maintenance easier,
let's make GetElementOrParentByTagName() take const nsAtom& for tag name.
GetElementOrParentByTagName() has two functions, one is looking for an element
starting from a node. The other is, if the start node is nullptr, it retrieves
anchor node of Selection as start node. Therefore, this patch splits the
first part to GetElementOrParentByTagNameInternal(). Then, creates its
wrapper which retrieves anchor of Selection automatically,
GetElementOrParentByTagNameAtSelection().
Additionally, this patch makes all internal callers of HTMLEditor use
GetElementOrParentByTagNameInternal() or
GetElementOrParentByTagNameAtSelection() directly. Then, public method,
GetElementOrParentByTagName() is called only by outer classes.
Note that some callers use both GetElementOrParentByTagNameInternal()
and GetElementOrParentByTagNameAtSelection() since they don't check whether
setting node is nullptr. They may be bug of them. We should investigate
the API callers later.
Differential Revision: https://phabricator.services.mozilla.com/D3584
--HG--
extra : moz-landing-system : lando
2018-08-17 17:06:18 +03:00
|
|
|
/**
|
|
|
|
* GetElementOrParentByTagNameAtSelection() looks for an element node whose
|
|
|
|
* name matches aTagName from anchor node of Selection to <body> element.
|
|
|
|
*
|
|
|
|
* @param aTagName The tag name which you want to look for.
|
|
|
|
* Must not be nsGkAtoms::_empty.
|
|
|
|
* If nsGkAtoms::list, the result may be <ul>, <ol> or
|
|
|
|
* <dl> element.
|
|
|
|
* If nsGkAtoms::td, the result may be <td> or <th>.
|
|
|
|
* If nsGkAtoms::href, the result may be <a> element
|
|
|
|
* which has "href" attribute with non-empty value.
|
2018-08-17 17:50:56 +03:00
|
|
|
* If nsGkAtoms::anchor, the result may be <a> which
|
|
|
|
* has "name" attribute with non-empty value.
|
Bug 1484092 - part 1: Make HTMLEditor::GetElementOrParentByTagName() use nsAtom for the tag name r=m_kato
HTMLElementOrParentByTagName() is the last user of IsLinkTag(const nsAString&)
and IsNamedAnchorTag(const nsAString&). For making their maintenance easier,
let's make GetElementOrParentByTagName() take const nsAtom& for tag name.
GetElementOrParentByTagName() has two functions, one is looking for an element
starting from a node. The other is, if the start node is nullptr, it retrieves
anchor node of Selection as start node. Therefore, this patch splits the
first part to GetElementOrParentByTagNameInternal(). Then, creates its
wrapper which retrieves anchor of Selection automatically,
GetElementOrParentByTagNameAtSelection().
Additionally, this patch makes all internal callers of HTMLEditor use
GetElementOrParentByTagNameInternal() or
GetElementOrParentByTagNameAtSelection() directly. Then, public method,
GetElementOrParentByTagName() is called only by outer classes.
Note that some callers use both GetElementOrParentByTagNameInternal()
and GetElementOrParentByTagNameAtSelection() since they don't check whether
setting node is nullptr. They may be bug of them. We should investigate
the API callers later.
Differential Revision: https://phabricator.services.mozilla.com/D3584
--HG--
extra : moz-landing-system : lando
2018-08-17 17:06:18 +03:00
|
|
|
* @return If an element which matches aTagName, returns
|
|
|
|
* an Element. Otherwise, nullptr.
|
|
|
|
*/
|
2018-10-30 13:01:38 +03:00
|
|
|
Element* GetElementOrParentByTagNameAtSelection(const nsAtom& aTagName) const;
|
Bug 1484092 - part 1: Make HTMLEditor::GetElementOrParentByTagName() use nsAtom for the tag name r=m_kato
HTMLElementOrParentByTagName() is the last user of IsLinkTag(const nsAString&)
and IsNamedAnchorTag(const nsAString&). For making their maintenance easier,
let's make GetElementOrParentByTagName() take const nsAtom& for tag name.
GetElementOrParentByTagName() has two functions, one is looking for an element
starting from a node. The other is, if the start node is nullptr, it retrieves
anchor node of Selection as start node. Therefore, this patch splits the
first part to GetElementOrParentByTagNameInternal(). Then, creates its
wrapper which retrieves anchor of Selection automatically,
GetElementOrParentByTagNameAtSelection().
Additionally, this patch makes all internal callers of HTMLEditor use
GetElementOrParentByTagNameInternal() or
GetElementOrParentByTagNameAtSelection() directly. Then, public method,
GetElementOrParentByTagName() is called only by outer classes.
Note that some callers use both GetElementOrParentByTagNameInternal()
and GetElementOrParentByTagNameAtSelection() since they don't check whether
setting node is nullptr. They may be bug of them. We should investigate
the API callers later.
Differential Revision: https://phabricator.services.mozilla.com/D3584
--HG--
extra : moz-landing-system : lando
2018-08-17 17:06:18 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GetElementOrParentByTagNameInternal() looks for an element node whose
|
|
|
|
* name matches aTagName from aNode to <body> element.
|
|
|
|
*
|
|
|
|
* @param aTagName The tag name which you want to look for.
|
|
|
|
* Must not be nsGkAtoms::_empty.
|
|
|
|
* If nsGkAtoms::list, the result may be <ul>, <ol> or
|
|
|
|
* <dl> element.
|
|
|
|
* If nsGkAtoms::td, the result may be <td> or <th>.
|
|
|
|
* If nsGkAtoms::href, the result may be <a> element
|
|
|
|
* which has "href" attribute with non-empty value.
|
2018-08-17 17:50:56 +03:00
|
|
|
* If nsGkAtoms::anchor, the result may be <a> which
|
|
|
|
* has "name" attribute with non-empty value.
|
Bug 1484092 - part 1: Make HTMLEditor::GetElementOrParentByTagName() use nsAtom for the tag name r=m_kato
HTMLElementOrParentByTagName() is the last user of IsLinkTag(const nsAString&)
and IsNamedAnchorTag(const nsAString&). For making their maintenance easier,
let's make GetElementOrParentByTagName() take const nsAtom& for tag name.
GetElementOrParentByTagName() has two functions, one is looking for an element
starting from a node. The other is, if the start node is nullptr, it retrieves
anchor node of Selection as start node. Therefore, this patch splits the
first part to GetElementOrParentByTagNameInternal(). Then, creates its
wrapper which retrieves anchor of Selection automatically,
GetElementOrParentByTagNameAtSelection().
Additionally, this patch makes all internal callers of HTMLEditor use
GetElementOrParentByTagNameInternal() or
GetElementOrParentByTagNameAtSelection() directly. Then, public method,
GetElementOrParentByTagName() is called only by outer classes.
Note that some callers use both GetElementOrParentByTagNameInternal()
and GetElementOrParentByTagNameAtSelection() since they don't check whether
setting node is nullptr. They may be bug of them. We should investigate
the API callers later.
Differential Revision: https://phabricator.services.mozilla.com/D3584
--HG--
extra : moz-landing-system : lando
2018-08-17 17:06:18 +03:00
|
|
|
* @param aNode Start node to look for the element.
|
|
|
|
* @return If an element which matches aTagName, returns
|
|
|
|
* an Element. Otherwise, nullptr.
|
|
|
|
*/
|
|
|
|
Element* GetElementOrParentByTagNameInternal(const nsAtom& aTagName,
|
2018-08-22 04:20:23 +03:00
|
|
|
nsINode& aNode) const;
|
Bug 1484092 - part 1: Make HTMLEditor::GetElementOrParentByTagName() use nsAtom for the tag name r=m_kato
HTMLElementOrParentByTagName() is the last user of IsLinkTag(const nsAString&)
and IsNamedAnchorTag(const nsAString&). For making their maintenance easier,
let's make GetElementOrParentByTagName() take const nsAtom& for tag name.
GetElementOrParentByTagName() has two functions, one is looking for an element
starting from a node. The other is, if the start node is nullptr, it retrieves
anchor node of Selection as start node. Therefore, this patch splits the
first part to GetElementOrParentByTagNameInternal(). Then, creates its
wrapper which retrieves anchor of Selection automatically,
GetElementOrParentByTagNameAtSelection().
Additionally, this patch makes all internal callers of HTMLEditor use
GetElementOrParentByTagNameInternal() or
GetElementOrParentByTagNameAtSelection() directly. Then, public method,
GetElementOrParentByTagName() is called only by outer classes.
Note that some callers use both GetElementOrParentByTagNameInternal()
and GetElementOrParentByTagNameAtSelection() since they don't check whether
setting node is nullptr. They may be bug of them. We should investigate
the API callers later.
Differential Revision: https://phabricator.services.mozilla.com/D3584
--HG--
extra : moz-landing-system : lando
2018-08-17 17:06:18 +03:00
|
|
|
|
2018-08-10 10:51:52 +03:00
|
|
|
/**
|
2018-11-05 14:38:10 +03:00
|
|
|
* GetSelectedElement() returns a "selected" element node. "selected" means:
|
|
|
|
* - there is only one selection range
|
|
|
|
* - the range starts from an element node or in an element
|
|
|
|
* - the range ends at immediately after same element
|
|
|
|
* - and the range does not include any other element nodes.
|
|
|
|
* Additionally, only when aTagName is nsGkAtoms::href, this thinks that an
|
|
|
|
* <a> element which has non-empty "href" attribute includes the range, the
|
|
|
|
* <a> element is selected.
|
2018-08-10 10:51:52 +03:00
|
|
|
*
|
2018-11-05 14:38:10 +03:00
|
|
|
* NOTE: This method is implementation of nsIHTMLEditor.getSelectedElement()
|
|
|
|
* and comm-central depends on this behavior. Therefore, if you need to use
|
|
|
|
* this method internally but you need to change, perhaps, you should create
|
|
|
|
* another method for avoiding breakage of comm-central apps.
|
|
|
|
*
|
|
|
|
* @param aTagName The atom of tag name in lower case. Set this to
|
|
|
|
* result of GetLowerCaseNameAtom() if you have a tag
|
|
|
|
* name with nsString.
|
|
|
|
* If nullptr, this returns any element node or nullptr.
|
|
|
|
* If nsGkAtoms::href, this returns an <a> element which
|
|
|
|
* has non-empty "href" attribute or nullptr.
|
|
|
|
* If nsGkAtoms::anchor, this returns an <a> element which
|
|
|
|
* has non-empty "name" attribute or nullptr.
|
|
|
|
* Otherwise, returns an element node whose name is
|
|
|
|
* same as aTagName or nullptr.
|
|
|
|
* @param aRv Returns error code.
|
|
|
|
* @return A "selected" element.
|
2018-08-10 10:51:52 +03:00
|
|
|
*/
|
2018-10-30 13:01:38 +03:00
|
|
|
already_AddRefed<Element> GetSelectedElement(const nsAtom* aTagName,
|
2018-08-10 12:01:42 +03:00
|
|
|
ErrorResult& aRv);
|
2018-08-10 10:51:52 +03:00
|
|
|
|
2018-08-22 04:20:23 +03:00
|
|
|
/**
|
|
|
|
* GetFirstTableRowElement() returns the first <tr> element in the most
|
|
|
|
* nearest ancestor of aTableOrElementInTable or itself.
|
|
|
|
*
|
|
|
|
* @param aTableOrElementInTable <table> element or another element.
|
|
|
|
* If this is a <table> element, returns
|
|
|
|
* first <tr> element in it. Otherwise,
|
|
|
|
* returns first <tr> element in nearest
|
|
|
|
* ancestor <table> element.
|
|
|
|
* @param aRv Returns an error code. When
|
|
|
|
* aTableOrElementInTable is neither
|
|
|
|
* <table> nor in a <table> element,
|
|
|
|
* returns NS_ERROR_FAILURE.
|
|
|
|
* However, if <table> does not have
|
|
|
|
* <tr> element, returns NS_OK.
|
|
|
|
*/
|
|
|
|
Element* GetFirstTableRowElement(Element& aTableOrElementInTable,
|
|
|
|
ErrorResult& aRv) const;
|
|
|
|
|
2018-08-22 09:52:07 +03:00
|
|
|
/**
|
|
|
|
* GetNextTableRowElement() returns next <tr> element of aTableRowElement.
|
|
|
|
* This won't cross <table> element boundary but may cross table section
|
|
|
|
* elements like <tbody>.
|
|
|
|
*
|
|
|
|
* @param aTableRowElement A <tr> element.
|
|
|
|
* @param aRv Returns error. If given element is <tr> but
|
|
|
|
* there is no next <tr> element, this returns
|
|
|
|
* nullptr but does not return error.
|
|
|
|
*/
|
|
|
|
Element* GetNextTableRowElement(Element& aTableRowElement,
|
|
|
|
ErrorResult& aRv) const;
|
|
|
|
|
2018-09-14 15:51:05 +03:00
|
|
|
struct CellAndIndexes;
|
2018-10-12 16:40:25 +03:00
|
|
|
struct CellData;
|
2018-09-14 15:51:05 +03:00
|
|
|
|
2018-08-22 06:34:40 +03:00
|
|
|
/**
|
|
|
|
* CellIndexes store both row index and column index of a table cell.
|
|
|
|
*/
|
|
|
|
struct MOZ_STACK_CLASS CellIndexes final {
|
|
|
|
int32_t mRow;
|
|
|
|
int32_t mColumn;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This constructor initializes mRowIndex and mColumnIndex with indexes of
|
|
|
|
* aCellElement.
|
|
|
|
*
|
|
|
|
* @param aCellElement An <td> or <th> element.
|
|
|
|
* @param aRv Returns error if layout information is not
|
|
|
|
* available or given element is not a table cell.
|
|
|
|
*/
|
|
|
|
CellIndexes(Element& aCellElement, ErrorResult& aRv)
|
|
|
|
: mRow(-1), mColumn(-1) {
|
|
|
|
MOZ_ASSERT(!aRv.Failed());
|
|
|
|
Update(aCellElement, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update mRowIndex and mColumnIndex with indexes of aCellElement.
|
|
|
|
*
|
|
|
|
* @param See above.
|
|
|
|
*/
|
|
|
|
void Update(Element& aCellElement, ErrorResult& aRv);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This constructor initializes mRowIndex and mColumnIndex with indexes of
|
|
|
|
* cell element which contains anchor of Selection.
|
|
|
|
*
|
|
|
|
* @param aHTMLEditor The editor which creates the instance.
|
|
|
|
* @param aSelection The Selection for the editor.
|
|
|
|
* @param aRv Returns error if there is no cell element
|
|
|
|
* which contains anchor of Selection, or layout
|
|
|
|
* information is not available.
|
|
|
|
*/
|
|
|
|
CellIndexes(HTMLEditor& aHTMLEditor, Selection& aSelection,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
: mRow(-1), mColumn(-1) {
|
|
|
|
Update(aHTMLEditor, aSelection, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update mRowIndex and mColumnIndex with indexes of cell element which
|
|
|
|
* contains anchor of Selection.
|
|
|
|
*
|
|
|
|
* @param See above.
|
|
|
|
*/
|
|
|
|
void Update(HTMLEditor& aHTMLEditor, Selection& aSelection,
|
|
|
|
ErrorResult& aRv);
|
2018-09-14 15:51:05 +03:00
|
|
|
|
2018-10-12 16:40:25 +03:00
|
|
|
bool operator==(const CellIndexes& aOther) const {
|
|
|
|
return mRow == aOther.mRow && mColumn == aOther.mColumn;
|
|
|
|
}
|
|
|
|
bool operator!=(const CellIndexes& aOther) const {
|
|
|
|
return mRow != aOther.mRow || mColumn != aOther.mColumn;
|
|
|
|
}
|
|
|
|
|
2018-09-14 15:51:05 +03:00
|
|
|
private:
|
|
|
|
CellIndexes() : mRow(-1), mColumn(-1) {}
|
|
|
|
|
|
|
|
friend struct CellAndIndexes;
|
2018-10-12 16:40:25 +03:00
|
|
|
friend struct CellData;
|
2018-09-14 15:51:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MOZ_STACK_CLASS CellAndIndexes final {
|
|
|
|
RefPtr<Element> mElement;
|
|
|
|
CellIndexes mIndexes;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This constructor initializes the members with cell element which is
|
|
|
|
* selected by first range of the Selection. Note that even if the
|
|
|
|
* first range is in the cell element, this does not treat it as the
|
|
|
|
* cell element is selected.
|
|
|
|
*/
|
|
|
|
CellAndIndexes(HTMLEditor& aHTMLEditor, Selection& aSelection,
|
|
|
|
ErrorResult& aRv) {
|
|
|
|
Update(aHTMLEditor, aSelection, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update mElement and mIndexes with cell element which is selected by
|
|
|
|
* first range of the Selection. Note that even if the first range is
|
|
|
|
* in the cell element, this does not treat it as the cell element is
|
|
|
|
* selected.
|
|
|
|
*/
|
|
|
|
void Update(HTMLEditor& aHTMLEditor, Selection& aSelection,
|
|
|
|
ErrorResult& aRv);
|
2018-08-22 06:34:40 +03:00
|
|
|
};
|
|
|
|
|
2018-10-12 16:40:25 +03:00
|
|
|
struct MOZ_STACK_CLASS CellData final {
|
|
|
|
RefPtr<Element> mElement;
|
|
|
|
// Current indexes which this is initialized with.
|
|
|
|
CellIndexes mCurrent;
|
|
|
|
// First column/row indexes of the cell. When current position is spanned
|
|
|
|
// from other column/row, this value becomes different from mCurrent.
|
|
|
|
CellIndexes mFirst;
|
|
|
|
// Computed rowspan/colspan values which are specified to the cell.
|
|
|
|
// Note that if the cell has larger rowspan/colspan value than actual
|
|
|
|
// table size, these values are the larger values.
|
|
|
|
int32_t mRowSpan;
|
|
|
|
int32_t mColSpan;
|
|
|
|
// Effective rowspan/colspan value at the index. For example, if first
|
|
|
|
// cell element in first row has rowspan="3", then, if this is initialized
|
|
|
|
// with 0-0 indexes, effective rowspan is 3. However, if this is
|
|
|
|
// initialized with 1-0 indexes, effective rowspan is 2.
|
|
|
|
int32_t mEffectiveRowSpan;
|
|
|
|
int32_t mEffectiveColSpan;
|
|
|
|
// mIsSelected is set to true if mElement itself or its parent <tr> or
|
|
|
|
// <table> is selected. Otherwise, e.g., the cell just contains selection
|
|
|
|
// range, this is set to false.
|
|
|
|
bool mIsSelected;
|
|
|
|
|
2018-10-16 04:10:44 +03:00
|
|
|
CellData()
|
|
|
|
: mRowSpan(-1),
|
|
|
|
mColSpan(-1),
|
|
|
|
mEffectiveRowSpan(-1),
|
|
|
|
mEffectiveColSpan(-1),
|
|
|
|
mIsSelected(false) {}
|
|
|
|
|
2018-10-12 16:40:25 +03:00
|
|
|
/**
|
|
|
|
* Those constructors initializes the members with a <table> element and
|
|
|
|
* both row and column index to specify a cell element.
|
|
|
|
*/
|
|
|
|
CellData(HTMLEditor& aHTMLEditor, Element& aTableElement, int32_t aRowIndex,
|
|
|
|
int32_t aColumnIndex, ErrorResult& aRv) {
|
|
|
|
Update(aHTMLEditor, aTableElement, aRowIndex, aColumnIndex, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
CellData(HTMLEditor& aHTMLEditor, Element& aTableElement,
|
|
|
|
const CellIndexes& aIndexes, ErrorResult& aRv) {
|
|
|
|
Update(aHTMLEditor, aTableElement, aIndexes, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Those Update() methods updates the members with a <table> element and
|
|
|
|
* both row and column index to specify a cell element.
|
|
|
|
*/
|
|
|
|
void Update(HTMLEditor& aHTMLEditor, Element& aTableElement,
|
|
|
|
int32_t aRowIndex, int32_t aColumnIndex, ErrorResult& aRv) {
|
|
|
|
mCurrent.mRow = aRowIndex;
|
|
|
|
mCurrent.mColumn = aColumnIndex;
|
|
|
|
Update(aHTMLEditor, aTableElement, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Update(HTMLEditor& aHTMLEditor, Element& aTableElement,
|
|
|
|
const CellIndexes& aIndexes, ErrorResult& aRv) {
|
|
|
|
mCurrent = aIndexes;
|
|
|
|
Update(aHTMLEditor, aTableElement, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Update(HTMLEditor& aHTMLEditor, Element& aTableElement,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* FailedOrNotFound() returns true if this failed to initialize/update
|
|
|
|
* or succeeded but found no cell element.
|
|
|
|
*/
|
|
|
|
bool FailedOrNotFound() const { return !mElement; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IsSpannedFromOtherRowOrColumn(), IsSpannedFromOtherColumn and
|
|
|
|
* IsSpannedFromOtherRow() return true if there is no cell element
|
|
|
|
* at the index because of spanning from other row and/or column.
|
|
|
|
*/
|
|
|
|
bool IsSpannedFromOtherRowOrColumn() const {
|
|
|
|
return mElement && mCurrent != mFirst;
|
|
|
|
}
|
|
|
|
bool IsSpannedFromOtherColumn() const {
|
|
|
|
return mElement && mCurrent.mColumn != mFirst.mColumn;
|
|
|
|
}
|
|
|
|
bool IsSpannedFromOtherRow() const {
|
|
|
|
return mElement && mCurrent.mRow != mFirst.mRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NextColumnIndex() and NextRowIndex() return column/row index of
|
|
|
|
* next cell. Note that this does not check whether there is next
|
|
|
|
* cell or not actually.
|
|
|
|
*/
|
|
|
|
int32_t NextColumnIndex() const {
|
|
|
|
if (NS_WARN_IF(FailedOrNotFound())) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return mCurrent.mColumn + mEffectiveColSpan;
|
|
|
|
}
|
|
|
|
int32_t NextRowIndex() const {
|
|
|
|
if (NS_WARN_IF(FailedOrNotFound())) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return mCurrent.mRow + mEffectiveRowSpan;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* LastColumnIndex() and LastRowIndex() return column/row index of
|
|
|
|
* column/row which is spanned by the cell.
|
|
|
|
*/
|
|
|
|
int32_t LastColumnIndex() const {
|
|
|
|
if (NS_WARN_IF(FailedOrNotFound())) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return NextColumnIndex() - 1;
|
|
|
|
}
|
|
|
|
int32_t LastRowIndex() const {
|
|
|
|
if (NS_WARN_IF(FailedOrNotFound())) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return NextRowIndex() - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NumberOfPrecedingColmuns() and NumberOfPrecedingRows() return number of
|
|
|
|
* preceding columns/rows if current index is spanned from other column/row.
|
|
|
|
* Otherwise, i.e., current point is not spanned form other column/row,
|
|
|
|
* returns 0.
|
|
|
|
*/
|
|
|
|
int32_t NumberOfPrecedingColmuns() const {
|
|
|
|
if (NS_WARN_IF(FailedOrNotFound())) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return mCurrent.mColumn - mFirst.mColumn;
|
|
|
|
}
|
|
|
|
int32_t NumberOfPrecedingRows() const {
|
|
|
|
if (NS_WARN_IF(FailedOrNotFound())) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return mCurrent.mRow - mFirst.mRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NumberOfFollowingColumns() and NumberOfFollowingRows() return
|
|
|
|
* number of remaining columns/rows if the cell spans to other
|
|
|
|
* column/row.
|
|
|
|
*/
|
|
|
|
int32_t NumberOfFollowingColumns() const {
|
|
|
|
if (NS_WARN_IF(FailedOrNotFound())) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return mEffectiveColSpan - 1;
|
|
|
|
}
|
|
|
|
int32_t NumberOfFollowingRows() const {
|
|
|
|
if (NS_WARN_IF(FailedOrNotFound())) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return mEffectiveRowSpan - 1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-08-23 10:32:16 +03:00
|
|
|
/**
|
|
|
|
* TableSize stores and computes number of rows and columns of a <table>
|
|
|
|
* element.
|
|
|
|
*/
|
|
|
|
struct MOZ_STACK_CLASS TableSize final {
|
|
|
|
int32_t mRowCount;
|
|
|
|
int32_t mColumnCount;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aHTMLEditor The editor which creates the instance.
|
|
|
|
* @param aTableOrElementInTable If a <table> element, computes number
|
|
|
|
* of rows and columns of it.
|
|
|
|
* If another element in a <table> element,
|
|
|
|
* computes number of rows and columns
|
|
|
|
* of nearest ancestor <table> element.
|
|
|
|
* Otherwise, i.e., non-<table> element
|
|
|
|
* not in <table>, returns error.
|
|
|
|
* @param aRv Returns error if the element is not
|
|
|
|
* in <table> or layout information is
|
|
|
|
* not available.
|
|
|
|
*/
|
|
|
|
TableSize(HTMLEditor& aHTMLEditor, Element& aTableOrElementInTable,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
: mRowCount(-1), mColumnCount(-1) {
|
|
|
|
MOZ_ASSERT(!aRv.Failed());
|
|
|
|
Update(aHTMLEditor, aTableOrElementInTable, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update mRowCount and mColumnCount for aTableOrElementInTable.
|
|
|
|
* See above for the detail.
|
|
|
|
*/
|
|
|
|
void Update(HTMLEditor& aHTMLEditor, Element& aTableOrElementInTable,
|
|
|
|
ErrorResult& aRv);
|
2018-09-19 12:00:06 +03:00
|
|
|
|
|
|
|
bool IsEmpty() const { return !mRowCount || !mColumnCount; }
|
2018-08-23 10:32:16 +03:00
|
|
|
};
|
|
|
|
|
2018-08-23 09:39:30 +03:00
|
|
|
/**
|
|
|
|
* GetTableCellElementAt() returns a <td> or <th> element of aTableElement
|
|
|
|
* if there is a cell at the indexes.
|
|
|
|
*
|
|
|
|
* @param aTableElement Must be a <table> element.
|
|
|
|
* @param aCellIndexes Indexes of cell which you want.
|
|
|
|
* If rowspan and/or colspan is specified 2 or
|
|
|
|
* larger, any indexes are allowed to retrieve
|
|
|
|
* the cell in the area.
|
|
|
|
* @return The cell element if there is in the <table>.
|
|
|
|
* Returns nullptr without error if the indexes
|
|
|
|
* are out of bounds.
|
|
|
|
*/
|
|
|
|
Element* GetTableCellElementAt(Element& aTableElement,
|
|
|
|
const CellIndexes& aCellIndexes) const {
|
|
|
|
return GetTableCellElementAt(aTableElement, aCellIndexes.mRow,
|
|
|
|
aCellIndexes.mColumn);
|
|
|
|
}
|
|
|
|
Element* GetTableCellElementAt(Element& aTableElement, int32_t aRowIndex,
|
|
|
|
int32_t aColumnIndex) const;
|
|
|
|
|
2018-09-14 15:56:22 +03:00
|
|
|
/**
|
|
|
|
* GetSelectedOrParentTableElement() returns <td>, <th>, <tr> or <table>
|
|
|
|
* element:
|
|
|
|
* #1 if the first selection range selects a cell, returns it.
|
|
|
|
* #2 if the first selection range does not select a cell and
|
|
|
|
* the selection anchor refers a <table>, returns it.
|
|
|
|
* #3 if the first selection range does not select a cell and
|
|
|
|
* the selection anchor refers a <tr>, returns it.
|
|
|
|
* #4 if the first selection range does not select a cell and
|
|
|
|
* the selection anchor refers a <td>, returns it.
|
|
|
|
* #5 otherwise, nearest ancestor <td> or <th> element of the
|
|
|
|
* selection anchor if there is.
|
|
|
|
* In #1 and #4, *aIsCellSelected will be set to true (i.e,, when
|
|
|
|
* a selection range selects a cell element).
|
|
|
|
*/
|
2018-10-30 13:01:38 +03:00
|
|
|
already_AddRefed<Element> GetSelectedOrParentTableElement(
|
2018-09-14 15:56:22 +03:00
|
|
|
ErrorResult& aRv, bool* aIsCellSelected = nullptr) const;
|
|
|
|
|
2018-08-13 07:15:34 +03:00
|
|
|
/**
|
|
|
|
* PasteInternal() pasts text with replacing selected content.
|
|
|
|
* This tries to dispatch ePaste event first. If its defaultPrevent() is
|
|
|
|
* called, this does nothing but returns NS_OK.
|
|
|
|
*
|
2018-10-10 15:05:39 +03:00
|
|
|
* @param aClipboardType nsIClipboard::kGlobalClipboard or
|
|
|
|
* nsIClipboard::kSelectionClipboard.
|
|
|
|
* @param aDispatchPasteEvent true if this should dispatch ePaste event
|
|
|
|
* before pasting. Otherwise, false.
|
2018-08-13 07:15:34 +03:00
|
|
|
*/
|
2019-03-12 04:55:03 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-10-10 15:05:39 +03:00
|
|
|
nsresult PasteInternal(int32_t aClipboardType, bool aDispatchPasteEvent);
|
2018-08-13 07:15:34 +03:00
|
|
|
|
2018-10-25 07:49:13 +03:00
|
|
|
/**
|
|
|
|
* InsertAsCitedQuotationInternal() inserts a <blockquote> element whose
|
|
|
|
* cite attribute is aCitation and whose content is aQuotedText.
|
|
|
|
* Note that this shouldn't be called when IsPlaintextEditor() is true.
|
|
|
|
*
|
|
|
|
* @param aQuotedText HTML source if aInsertHTML is true. Otherwise,
|
|
|
|
* plain text. This is inserted into new <blockquote>
|
|
|
|
* element.
|
|
|
|
* @param aCitation cite attribute value of new <blockquote> element.
|
|
|
|
* @param aInsertHTML true if aQuotedText should be treated as HTML
|
|
|
|
* source.
|
|
|
|
* false if aQuotedText should be treated as plain
|
|
|
|
* text.
|
|
|
|
* @param aNodeInserted [OUT] The new <blockquote> element.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-10-25 07:49:13 +03:00
|
|
|
nsresult InsertAsCitedQuotationInternal(const nsAString& aQuotedText,
|
|
|
|
const nsAString& aCitation,
|
|
|
|
bool aInsertHTML,
|
|
|
|
nsINode** aNodeInserted);
|
|
|
|
|
2016-07-09 05:42:33 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* InsertNodeIntoProperAncestorWithTransaction() attempts to insert aNode
|
|
|
|
* into the document, at aPointToInsert. Checks with strict dtd to see if
|
|
|
|
* containment is allowed. If not allowed, will attempt to find a parent
|
|
|
|
* in the parent hierarchy of aPointToInsert.GetContainer() that will accept
|
|
|
|
* aNode as a child. If such a parent is found, will split the document
|
|
|
|
* tree from aPointToInsert up to parent, and then insert aNode.
|
|
|
|
* aPointToInsert is then adjusted to point to the actual location that
|
|
|
|
* aNode was inserted at. aSplitAtEdges specifies if the splitting process
|
|
|
|
* is allowed to result in empty nodes.
|
2016-07-09 05:42:33 +03:00
|
|
|
*
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* @param aNode Node to insert.
|
|
|
|
* @param aPointToInsert Insertion point.
|
|
|
|
* @param aSplitAtEdges Splitting can result in empty nodes?
|
|
|
|
* @return Returns inserted point if succeeded.
|
|
|
|
* Otherwise, the result is not set.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT EditorDOMPoint InsertNodeIntoProperAncestorWithTransaction(
|
2019-05-08 12:40:17 +03:00
|
|
|
nsIContent& aNode, const EditorDOMPoint& aPointToInsert,
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
SplitAtEdges aSplitAtEdges);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
/**
|
|
|
|
* InsertBrElementAtSelectionWithTransaction() inserts a new <br> element at
|
|
|
|
* selection. If there is non-collapsed selection ranges, the selected
|
|
|
|
* ranges is deleted first.
|
|
|
|
*/
|
2019-05-08 01:27:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult InsertBrElementAtSelectionWithTransaction();
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-08-09 15:24:53 +03:00
|
|
|
/**
|
|
|
|
* InsertTextWithQuotationsInternal() replaces selection with new content.
|
|
|
|
* First, this method splits aStringToInsert to multiple chunks which start
|
|
|
|
* with non-linebreaker except first chunk and end with a linebreaker except
|
|
|
|
* last chunk. Then, each chunk starting with ">" is inserted after wrapping
|
|
|
|
* with <span _moz_quote="true">, and each chunk not starting with ">" is
|
|
|
|
* inserted as normal text.
|
|
|
|
*/
|
2019-05-08 01:27:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-08-09 15:24:53 +03:00
|
|
|
nsresult InsertTextWithQuotationsInternal(const nsAString& aStringToInsert);
|
|
|
|
|
2018-08-14 11:30:09 +03:00
|
|
|
/**
|
|
|
|
* IndentOrOutdentAsSubAction() indents or outdents the content around
|
|
|
|
* Selection. Callers have to guarantee that there is a placeholder
|
|
|
|
* transaction.
|
|
|
|
*
|
|
|
|
* @param aEditSubAction Must be EditSubAction::eIndent or
|
|
|
|
* EditSubAction::eOutdent.
|
|
|
|
*/
|
2019-05-08 01:34:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-08-14 11:30:09 +03:00
|
|
|
nsresult IndentOrOutdentAsSubAction(EditSubAction aEditSubAction);
|
|
|
|
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult LoadHTML(const nsAString& aInputString);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-08-13 08:16:10 +03:00
|
|
|
nsresult SetInlinePropertyInternal(nsAtom& aProperty, nsAtom* aAttribute,
|
|
|
|
const nsAString& aValue);
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-08-13 09:16:24 +03:00
|
|
|
nsresult RemoveInlinePropertyInternal(nsAtom* aProperty, nsAtom* aAttribute);
|
2018-08-13 08:16:10 +03:00
|
|
|
|
2018-07-19 15:31:19 +03:00
|
|
|
/**
|
|
|
|
* ReplaceHeadContentsWithSourceWithTransaction() replaces all children of
|
|
|
|
* <head> element with given source code. This is undoable.
|
|
|
|
*
|
|
|
|
* @param aSourceToInsert HTML source fragment to replace the children
|
|
|
|
* of <head> element.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-07-19 15:31:19 +03:00
|
|
|
nsresult ReplaceHeadContentsWithSourceWithTransaction(
|
|
|
|
const nsAString& aSourceToInsert);
|
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult GetCSSBackgroundColorState(bool* aMixed, nsAString& aOutColor,
|
|
|
|
bool aBlockLevel);
|
|
|
|
nsresult GetHTMLBackgroundColorState(bool* aMixed, nsAString& outColor);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult GetLastCellInRow(nsINode* aRowNode, nsINode** aCellNode);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-08-24 11:29:12 +03:00
|
|
|
static nsresult GetCellFromRange(nsRange* aRange, Element** aCell);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* This sets background on the appropriate container element (table, cell,)
|
|
|
|
* or calls into nsTextEditor to set the page background.
|
2017-12-05 09:36:49 +03:00
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult SetCSSBackgroundColorWithTransaction(const nsAString& aColor);
|
2019-05-08 08:09:56 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult SetHTMLBackgroundColorWithTransaction(const nsAString& aColor);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-10-30 13:01:38 +03:00
|
|
|
virtual void InitializeSelectionAncestorLimit(
|
|
|
|
nsIContent& aAncestorLimit) override;
|
2018-04-16 14:33:27 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Make the given selection span the entire document.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
2019-03-26 13:06:43 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-10-30 13:01:38 +03:00
|
|
|
virtual nsresult SelectEntireDocument() override;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Use this to assure that selection is set after attribute nodes when
|
|
|
|
* trying to collapse selection at begining of a block node
|
|
|
|
* e.g., when setting at beginning of a table cell
|
|
|
|
* This will stop at a table, however, since we don't want to
|
|
|
|
* "drill down" into nested tables.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
2018-10-30 13:01:38 +03:00
|
|
|
void CollapseSelectionToDeepestNonTableFirstChild(nsINode* aNode);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Returns TRUE if sheet was loaded, false if it wasn't.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
bool EnableExistingStyleSheet(const nsAString& aURL);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
2018-08-16 13:03:49 +03:00
|
|
|
* GetStyleSheetForURL() returns a pointer to StyleSheet which was added
|
|
|
|
* with AddOverrideStyleSheetInternal(). If it's not found, returns nullptr.
|
|
|
|
*
|
|
|
|
* @param aURL URL to the style sheet.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
StyleSheet* GetStyleSheetForURL(const nsAString& aURL);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-04-12 16:23:04 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Add a url + known style sheet to the internal lists.
|
2018-04-12 16:23:04 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult AddNewStyleSheetToList(const nsAString& aURL,
|
|
|
|
StyleSheet* aStyleSheet);
|
2018-08-16 13:01:23 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes style sheet from the internal lists.
|
|
|
|
*
|
|
|
|
* @param aURL URL to the style sheet.
|
|
|
|
* @return If the URL is in the internal list, returns the
|
|
|
|
* removed style sheet. Otherwise, i.e., not found,
|
|
|
|
* nullptr.
|
|
|
|
*/
|
|
|
|
already_AddRefed<StyleSheet> RemoveStyleSheetFromList(const nsAString& aURL);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-08-16 12:26:09 +03:00
|
|
|
/**
|
|
|
|
* Add and apply the style sheet synchronously.
|
|
|
|
*
|
|
|
|
* @param aURL URL to the style sheet.
|
|
|
|
*/
|
|
|
|
nsresult AddOverrideStyleSheetInternal(const nsAString& aURL);
|
|
|
|
|
2018-08-16 13:01:23 +03:00
|
|
|
/**
|
|
|
|
* Remove the style sheet from this editor synchronously.
|
|
|
|
*
|
|
|
|
* @param aURL URL to the style sheet.
|
|
|
|
* @return Even if there is no specified style sheet in the
|
|
|
|
* internal lists, this returns NS_OK.
|
|
|
|
*/
|
|
|
|
nsresult RemoveOverrideStyleSheetInternal(const nsAString& aURL);
|
|
|
|
|
2018-08-16 13:03:46 +03:00
|
|
|
/**
|
|
|
|
* Enable or disable the style sheet synchronously.
|
|
|
|
* aURL is just a key to specify a style sheet in the internal array.
|
|
|
|
* I.e., the style sheet has already been registered with
|
|
|
|
* AddOverrideStyleSheetInternal().
|
|
|
|
*
|
|
|
|
* @param aURL URL to the style sheet.
|
|
|
|
* @param aEnable true if enable the style sheet. false if disable it.
|
|
|
|
*/
|
|
|
|
void EnableStyleSheetInternal(const nsAString& aURL, bool aEnable);
|
|
|
|
|
Bug 1406726 - HTMLEditRules::WillInsertBreak() should reset mNewNode with caret position r=m_kato
HTMLEditRules::WillInsertBreak() started to use HTMLEditRules::MakeBasicBlock()
to wrap existing inline elements with default paragraph separator if inline
elements are children of editing host. However,
HTMLEditRules::ApplyBlockStyle() called by HTMLEditRules::MakeBasicBlock() sets
mNewNode to last new block node. So, if it wraps inline elements after caret
position, mNewNode becomes after expected caret position and
HTMLEditRules::AfterEditInner() will move caret into it.
This patch make HTMLEditRules::WillInsertBreak() reset mNewNode with
caret position after calling HTMLEditRules::MakeBasicBlock().
Additionally, this patch fixes a bug of HTMLEditor::IsVisibleBRElement().
That is, it uses only editable nodes to check if given <br> element is
visible. However, editable state is not related to this check. If <br>
element is followed by non-editable inline node (except invisible data
nodes), it always visible. This bug caused getting wrong nodes with
HTMLEditRules::GetNodesFromSelection() which is used by
HTMLEditRules::MakeBasicBlock(). Therefore, this patch also adds lots of
EditorBase::Get(Next|Previous)ElementOrText*() and
HTMLEditor::Get(Next|Previous)HTMLElementOrText*() to ignore only invisible
data nodes.
Note that even with this fix, the range of nodes computed by
HTMLEditRules::GetNodesFromSelection() is still odd if only non-editable
elements follow a <br> node which is first <br> element after the caret
position. However, what is expected by the execCommand spec is unclear.
So, automated test added by this patch checks current inconsistent behavior
for now.
MozReview-Commit-ID: 2m52StwoEEH
--HG--
extra : rebase_source : 6b9b2338e35c4d2e89a405fd8e1ffc7b0873ca1e
2018-02-13 13:01:42 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* MaybeCollapseSelectionAtFirstEditableNode() may collapse selection at
|
|
|
|
* proper position to staring to edit. If there is a non-editable node
|
|
|
|
* before any editable text nodes or inline elements which can have text
|
|
|
|
* nodes as their children, collapse selection at start of the editing
|
|
|
|
* host. If there is an editable text node which is not collapsed, collapses
|
|
|
|
* selection at the start of the text node. If there is an editable inline
|
|
|
|
* element which cannot have text nodes as its child, collapses selection at
|
|
|
|
* before the element node. Otherwise, collapses selection at start of the
|
|
|
|
* editing host.
|
|
|
|
*
|
|
|
|
* @param aIgnoreIfSelectionInEditingHost
|
|
|
|
* This method does nothing if selection is in the
|
|
|
|
* editing host except if it's collapsed at start of
|
|
|
|
* the editing host.
|
|
|
|
* Note that if selection ranges were outside of
|
|
|
|
* current selection limiter, selection was collapsed
|
|
|
|
* at the start of the editing host therefore, if
|
|
|
|
* you call this with setting this to true, you can
|
|
|
|
* keep selection ranges if user has already been
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
nsresult MaybeCollapseSelectionAtFirstEditableNode(
|
|
|
|
bool aIgnoreIfSelectionInEditingHost);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-09-18 07:34:21 +03:00
|
|
|
class BlobReader final {
|
2018-11-05 05:12:27 +03:00
|
|
|
typedef EditorBase::AutoEditActionDataSetter AutoEditActionDataSetter;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
public:
|
|
|
|
BlobReader(dom::BlobImpl* aBlob, HTMLEditor* aHTMLEditor, bool aIsSafe,
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* aSourceDoc, const EditorDOMPoint& aPointToInsert,
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
bool aDoDeleteSelection);
|
|
|
|
|
2018-09-18 07:34:21 +03:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(BlobReader)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(BlobReader)
|
|
|
|
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-18 07:34:21 +03:00
|
|
|
nsresult OnResult(const nsACString& aResult);
|
|
|
|
nsresult OnError(const nsAString& aErrorName);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
~BlobReader() {}
|
|
|
|
|
|
|
|
RefPtr<dom::BlobImpl> mBlob;
|
|
|
|
RefPtr<HTMLEditor> mHTMLEditor;
|
2019-01-02 16:05:23 +03:00
|
|
|
nsCOMPtr<Document> mSourceDoc;
|
2018-11-09 11:40:57 +03:00
|
|
|
EditorDOMPoint mPointToInsert;
|
2018-11-05 05:12:27 +03:00
|
|
|
EditAction mEditAction;
|
|
|
|
bool mIsSafe;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
bool mDoDeleteSelection;
|
|
|
|
};
|
|
|
|
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
virtual nsresult InitRules() override;
|
|
|
|
|
|
|
|
virtual void CreateEventListeners() override;
|
|
|
|
virtual nsresult InstallEventListeners() override;
|
|
|
|
virtual void RemoveEventListeners() override;
|
|
|
|
|
|
|
|
bool ShouldReplaceRootElement();
|
|
|
|
void NotifyRootChanged();
|
|
|
|
Element* GetBodyElement();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the focused node of this editor.
|
|
|
|
* @return If the editor has focus, this returns the focused node.
|
|
|
|
* Otherwise, returns null.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsINode> GetFocusedNode();
|
|
|
|
|
2018-11-21 06:59:02 +03:00
|
|
|
virtual already_AddRefed<Element> GetInputEventTargetElement() override;
|
2018-06-06 07:30:44 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
/**
|
|
|
|
* Return TRUE if aElement is a table-related elemet and caret was set.
|
|
|
|
*/
|
|
|
|
bool SetCaretInTableCell(dom::Element* aElement);
|
|
|
|
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult TabInTable(bool inIsShift, bool* outHandled);
|
|
|
|
|
2018-09-20 09:55:17 +03:00
|
|
|
/**
|
|
|
|
* InsertPosition is an enum to indicate where the method should insert to.
|
|
|
|
*/
|
|
|
|
enum class InsertPosition {
|
|
|
|
// Before selected cell or a cell containing first selection range.
|
|
|
|
eBeforeSelectedCell,
|
|
|
|
// After selected cell or a cell containing first selection range.
|
|
|
|
eAfterSelectedCell,
|
|
|
|
};
|
|
|
|
|
2018-09-20 14:44:35 +03:00
|
|
|
/**
|
|
|
|
* InsertTableCellsWithTransaction() inserts <td> elements before or after
|
|
|
|
* a cell element containing first selection range. I.e., if the cell
|
|
|
|
* spans columns and aInsertPosition is eAfterSelectedCell, new columns
|
|
|
|
* will be inserted after the right-most column which contains the cell.
|
|
|
|
* Note that this simply inserts <td> elements, i.e., colspan and rowspan
|
|
|
|
* around the cell containing selection are not modified. So, for example,
|
|
|
|
* adding a cell to rectangular table changes non-rectangular table.
|
|
|
|
* And if the cell containing selection is at left of row-spanning cell,
|
|
|
|
* it may be moved to right side of the row-spanning cell after inserting
|
|
|
|
* some cell elements before it. Similarly, colspan won't be adjusted
|
|
|
|
* for keeping table rectangle.
|
|
|
|
* If first selection range is not in table cell element, this does nothing
|
|
|
|
* but does not return error.
|
|
|
|
*
|
|
|
|
* @param aNumberOfCellssToInsert Number of cells to insert.
|
|
|
|
* @param aInsertPosition Before or after the target cell which
|
|
|
|
* contains first selection range.
|
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-20 14:44:35 +03:00
|
|
|
nsresult InsertTableCellsWithTransaction(int32_t aNumberOfCellsToInsert,
|
|
|
|
InsertPosition aInsertPosition);
|
|
|
|
|
2018-09-20 12:15:08 +03:00
|
|
|
/**
|
|
|
|
* InsertTableColumnsWithTransaction() inserts columns before or after
|
|
|
|
* a cell element containing first selection range. I.e., if the cell
|
|
|
|
* spans columns and aInsertPosition is eAfterSelectedCell, new columns
|
|
|
|
* will be inserted after the right-most row which contains the cell.
|
|
|
|
* If first selection range is not in table cell element, this does nothing
|
|
|
|
* but does not return error.
|
|
|
|
*
|
|
|
|
* @param aNumberOfColumnsToInsert Number of columns to insert.
|
|
|
|
* @param aInsertPosition Before or after the target cell which
|
|
|
|
* contains first selection range.
|
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-20 12:15:08 +03:00
|
|
|
nsresult InsertTableColumnsWithTransaction(int32_t aNumberOfColumnsToInsert,
|
|
|
|
InsertPosition aInsertPosition);
|
|
|
|
|
2018-09-20 09:55:17 +03:00
|
|
|
/**
|
|
|
|
* InsertTableRowsWithTransaction() inserts <tr> elements before or after
|
|
|
|
* a cell element containing first selection range. I.e., if the cell
|
|
|
|
* spans rows and aInsertPosition is eAfterSelectedCell, new rows will be
|
|
|
|
* inserted after the most-bottom row which contains the cell. If first
|
|
|
|
* selection range is not in table cell element, this does nothing but
|
|
|
|
* does not return error.
|
|
|
|
*
|
|
|
|
* @param aNumberOfRowsToInsert Number of rows to insert.
|
|
|
|
* @param aInsertPosition Before or after the target cell which
|
|
|
|
* contains first selection range.
|
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-20 09:55:17 +03:00
|
|
|
nsresult InsertTableRowsWithTransaction(int32_t aNumberOfRowsToInsert,
|
|
|
|
InsertPosition aInsertPosition);
|
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
/**
|
|
|
|
* Insert a new cell after or before supplied aCell.
|
|
|
|
* Optional: If aNewCell supplied, returns the newly-created cell (addref'd,
|
|
|
|
* of course)
|
|
|
|
* This doesn't change or use the current selection.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult InsertCell(Element* aCell, int32_t aRowSpan, int32_t aColSpan,
|
|
|
|
bool aAfter, bool aIsHeader, Element** aNewCell);
|
|
|
|
|
2018-09-19 09:34:33 +03:00
|
|
|
/**
|
|
|
|
* DeleteSelectedTableColumnsWithTransaction() removes cell elements which
|
|
|
|
* belong to same columns of selected cell elements.
|
|
|
|
* If only one cell element is selected or first selection range is
|
|
|
|
* in a cell, removes cell elements which belong to same column.
|
|
|
|
* If 2 or more cell elements are selected, removes cell elements which
|
|
|
|
* belong to any of all selected columns. In this case,
|
|
|
|
* aNumberOfColumnsToDelete is ignored.
|
|
|
|
* If there is no selection ranges, returns error.
|
|
|
|
* If selection is not in a cell element, this does not return error,
|
|
|
|
* just does nothing.
|
|
|
|
* WARNING: This does not remove <col> nor <colgroup> elements.
|
|
|
|
*
|
|
|
|
* @param aNumberOfColumnsToDelete Number of columns to remove. This is
|
|
|
|
* ignored if 2 ore more cells are
|
|
|
|
* selected.
|
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-19 09:34:33 +03:00
|
|
|
nsresult DeleteSelectedTableColumnsWithTransaction(
|
|
|
|
int32_t aNumberOfColumnsToDelete);
|
|
|
|
|
2018-09-19 09:39:31 +03:00
|
|
|
/**
|
|
|
|
* DeleteTableColumnWithTransaction() removes cell elements which belong
|
|
|
|
* to the specified column.
|
|
|
|
* This method adjusts colspan attribute value if cells spanning the
|
|
|
|
* column to delete.
|
|
|
|
* WARNING: This does not remove <col> nor <colgroup> elements.
|
|
|
|
*
|
|
|
|
* @param aTableElement The <table> element which contains the
|
|
|
|
* column which you want to remove.
|
|
|
|
* @param aRowIndex Index of the column which you want to remove.
|
|
|
|
* 0 is the first column.
|
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-19 09:39:31 +03:00
|
|
|
nsresult DeleteTableColumnWithTransaction(Element& aTableElement,
|
|
|
|
int32_t aColumnIndex);
|
|
|
|
|
2018-09-18 10:56:45 +03:00
|
|
|
/**
|
|
|
|
* DeleteSelectedTableRowsWithTransaction() removes <tr> elements.
|
|
|
|
* If only one cell element is selected or first selection range is
|
|
|
|
* in a cell, removes <tr> elements starting from a <tr> element
|
|
|
|
* containing the selected cell or first selection range.
|
|
|
|
* If 2 or more cell elements are selected, all <tr> elements
|
|
|
|
* which contains selected cell(s). In this case, aNumberOfRowsToDelete
|
|
|
|
* is ignored.
|
|
|
|
* If there is no selection ranges, returns error.
|
|
|
|
* If selection is not in a cell element, this does not return error,
|
|
|
|
* just does nothing.
|
|
|
|
*
|
|
|
|
* @param aNumberOfRowsToDelete Number of rows to remove. This is ignored
|
|
|
|
* if 2 or more cells are selected.
|
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-18 10:56:45 +03:00
|
|
|
nsresult DeleteSelectedTableRowsWithTransaction(
|
|
|
|
int32_t aNumberOfRowsToDelete);
|
|
|
|
|
2018-09-18 11:31:00 +03:00
|
|
|
/**
|
|
|
|
* DeleteTableRowWithTransaction() removes a <tr> element whose index in
|
|
|
|
* the <table> is aRowIndex.
|
|
|
|
* This method adjusts rowspan attribute value if the <tr> element contains
|
|
|
|
* cells which spans rows.
|
|
|
|
*
|
|
|
|
* @param aTableElement The <table> element which contains the
|
|
|
|
* <tr> element which you want to remove.
|
|
|
|
* @param aRowIndex Index of the <tr> element which you want to
|
|
|
|
* remove. 0 is the first row.
|
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-18 11:31:00 +03:00
|
|
|
nsresult DeleteTableRowWithTransaction(Element& aTableElement,
|
|
|
|
int32_t aRowIndex);
|
|
|
|
|
2018-09-19 11:50:11 +03:00
|
|
|
/**
|
|
|
|
* DeleteTableCellWithTransaction() removes table cell elements. If two or
|
|
|
|
* more cell elements are selected, this removes all selected cell elements.
|
|
|
|
* Otherwise, this removes some cell elements starting from selected cell
|
|
|
|
* element or a cell containing first selection range. When this removes
|
|
|
|
* last cell element in <tr> or <table>, this removes the <tr> or the
|
|
|
|
* <table> too. Note that when removing a cell causes number of its row
|
|
|
|
* becomes less than the others, this method does NOT fill the place with
|
|
|
|
* rowspan nor colspan. This does not return error even if selection is not
|
|
|
|
* in cell element, just does nothing.
|
|
|
|
*
|
|
|
|
* @param aNumberOfCellsToDelete Number of cells to remove. This is ignored
|
|
|
|
* if 2 or more cells are selected.
|
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-19 11:50:11 +03:00
|
|
|
nsresult DeleteTableCellWithTransaction(int32_t aNumberOfCellsToDelete);
|
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
/**
|
2018-09-19 04:58:48 +03:00
|
|
|
* DeleteAllChildrenWithTransaction() removes all children of aElement from
|
|
|
|
* the tree.
|
|
|
|
*
|
|
|
|
* @param aElement The element whose children you want to remove.
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
*/
|
2019-05-08 01:27:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-09-19 04:58:48 +03:00
|
|
|
nsresult DeleteAllChildrenWithTransaction(Element& aElement);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Move all contents from aCellToMerge into aTargetCell (append at end).
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult MergeCells(RefPtr<Element> aTargetCell, RefPtr<Element> aCellToMerge,
|
|
|
|
bool aDeleteCellToMerge);
|
|
|
|
|
2018-09-18 10:56:45 +03:00
|
|
|
/**
|
|
|
|
* DeleteTableElementAndChildren() removes aTableElement (and its children)
|
|
|
|
* from the DOM tree with transaction.
|
|
|
|
*
|
|
|
|
* @param aTableElement The <table> element which you want to remove.
|
|
|
|
*/
|
2019-05-08 01:27:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-10-30 13:01:38 +03:00
|
|
|
nsresult DeleteTableElementAndChildrenWithTransaction(Element& aTableElement);
|
2018-09-18 10:56:45 +03:00
|
|
|
|
2019-05-08 09:26:25 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetColSpan(Element* aCell, int32_t aColSpan);
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetRowSpan(Element* aCell, int32_t aRowSpan);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper used to get nsTableWrapperFrame for a table.
|
|
|
|
*/
|
2018-08-23 09:39:30 +03:00
|
|
|
static nsTableWrapperFrame* GetTableFrame(Element* aTable);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
/**
|
2018-09-19 07:32:10 +03:00
|
|
|
* GetNumberOfCellsInRow() returns number of actual cell elements in the row.
|
|
|
|
* If some cells appear by "rowspan" in other rows, they are ignored.
|
|
|
|
*
|
|
|
|
* @param aTableElement The <table> element.
|
|
|
|
* @param aRowIndex Valid row index in aTableElement. This method
|
|
|
|
* counts cell elements in the row.
|
|
|
|
* @return -1 if this meets unexpected error.
|
|
|
|
* Otherwise, number of cells which this method found.
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
*/
|
2018-09-19 07:32:10 +03:00
|
|
|
int32_t GetNumberOfCellsInRow(Element& aTableElement, int32_t aRowIndex);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if all cells in row or column at given index are selected.
|
|
|
|
*/
|
|
|
|
bool AllCellsInRowSelected(Element* aTable, int32_t aRowIndex,
|
|
|
|
int32_t aNumberOfColumns);
|
|
|
|
bool AllCellsInColumnSelected(Element* aTable, int32_t aColIndex,
|
|
|
|
int32_t aNumberOfRows);
|
|
|
|
|
|
|
|
bool IsEmptyCell(Element* aCell);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Most insert methods need to get the same basic context data.
|
|
|
|
* Any of the pointers may be null if you don't need that datum (for more
|
|
|
|
* efficiency).
|
|
|
|
* Input: *aCell is a known cell,
|
|
|
|
* if null, cell is obtained from the anchor node of the selection.
|
|
|
|
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is
|
|
|
|
* null.
|
|
|
|
*/
|
2018-10-30 13:01:38 +03:00
|
|
|
nsresult GetCellContext(Element** aTable, Element** aCell,
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsINode** aCellParent, int32_t* aCellOffset,
|
|
|
|
int32_t* aRowIndex, int32_t* aColIndex);
|
|
|
|
|
|
|
|
nsresult GetCellSpansAt(Element* aTable, int32_t aRowIndex, int32_t aColIndex,
|
|
|
|
int32_t& aActualRowSpan, int32_t& aActualColSpan);
|
|
|
|
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult SplitCellIntoColumns(Element* aTable, int32_t aRowIndex,
|
|
|
|
int32_t aColIndex, int32_t aColSpanLeft,
|
|
|
|
int32_t aColSpanRight, Element** aNewCell);
|
|
|
|
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult SplitCellIntoRows(Element* aTable, int32_t aRowIndex,
|
|
|
|
int32_t aColIndex, int32_t aRowSpanAbove,
|
|
|
|
int32_t aRowSpanBelow, Element** aNewCell);
|
|
|
|
|
2019-05-08 09:26:25 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult CopyCellBackgroundColor(Element* aDestCell,
|
|
|
|
Element* aSourceCell);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reduce rowspan/colspan when cells span into nonexistent rows/columns.
|
|
|
|
*/
|
2019-05-08 09:26:25 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult FixBadRowSpan(Element* aTable, int32_t aRowIndex,
|
|
|
|
int32_t& aNewRowCount);
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult FixBadColSpan(Element* aTable, int32_t aColIndex,
|
|
|
|
int32_t& aNewColCount);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
/**
|
2018-10-30 13:01:38 +03:00
|
|
|
* XXX NormalizeTableInternal() is broken. If it meets a cell which has
|
|
|
|
* bigger or smaller rowspan or colspan than actual number of cells,
|
|
|
|
* this always failed to scan the table. Therefore, this does nothing
|
|
|
|
* when the table should be normalized.
|
2018-09-13 11:03:56 +03:00
|
|
|
*
|
|
|
|
* @param aTableOrElementInTable An element which is in a <table> element
|
|
|
|
* or <table> element itself. Otherwise,
|
|
|
|
* this returns NS_OK but does nothing.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-10-30 13:01:38 +03:00
|
|
|
nsresult NormalizeTableInternal(Element& aTableOrElementInTable);
|
2018-09-13 11:03:56 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Fallback method: Call this after using ClearSelection() and you
|
|
|
|
* failed to set selection to some other content in the document.
|
|
|
|
*/
|
2018-10-30 13:01:38 +03:00
|
|
|
nsresult SetSelectionAtDocumentStart();
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
static Element* GetEnclosingTable(nsINode* aNode);
|
|
|
|
|
|
|
|
// Methods for handling plaintext quotations
|
2019-05-08 01:27:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult PasteAsPlaintextQuotation(int32_t aSelectionType);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert a string as quoted text, replacing the selected text (if any).
|
|
|
|
* @param aQuotedText The string to insert.
|
|
|
|
* @param aAddCites Whether to prepend extra ">" to each line
|
|
|
|
* (usually true, unless those characters
|
|
|
|
* have already been added.)
|
|
|
|
* @return aNodeInserted The node spanning the insertion, if applicable.
|
|
|
|
* If aAddCites is false, this will be null.
|
|
|
|
*/
|
2019-05-08 01:27:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult InsertAsPlaintextQuotation(const nsAString& aQuotedText,
|
2018-05-24 20:18:34 +03:00
|
|
|
bool aAddCites, nsINode** aNodeInserted);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
2018-11-09 11:40:57 +03:00
|
|
|
/**
|
|
|
|
* InsertObject() inserts given object at aPointToInsert.
|
|
|
|
*/
|
2019-03-13 00:04:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult InsertObject(const nsACString& aType, nsISupports* aObject,
|
2019-01-02 16:05:23 +03:00
|
|
|
bool aIsSafe, Document* aSourceDoc,
|
2018-11-09 11:40:57 +03:00
|
|
|
const EditorDOMPoint& aPointToInsert,
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
bool aDoDeleteSelection);
|
|
|
|
|
|
|
|
// factored methods for handling insertion of data from transferables
|
|
|
|
// (drag&drop or clipboard)
|
|
|
|
virtual nsresult PrepareTransferable(nsITransferable** transferable) override;
|
|
|
|
nsresult PrepareHTMLTransferable(nsITransferable** transferable);
|
2019-03-12 04:55:03 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult InsertFromTransferable(nsITransferable* transferable,
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* aSourceDoc,
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
const nsAString& aContextStr,
|
|
|
|
const nsAString& aInfoStr,
|
|
|
|
bool havePrivateHTMLFlavor,
|
|
|
|
bool aDoDeleteSelection);
|
2018-11-09 11:40:57 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* InsertFromDataTransfer() is called only when user drops data into
|
|
|
|
* this editor. Don't use this method for other purposes.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 998941 - part 1-3: Make TextEditor (only when not HTMLEditor instance) set InputEvent.data to inserting string when InputEvent.inputType is "insertFromPaste", "insertFromDrop" or "insertReplacementText" r=smaug,m_kato
https://rawgit.com/w3c/input-events/v1/index.html#dfn-data
https://w3c.github.io/input-events/#dfn-data
Both Input Events Level 1 and Level 2 declare that InputEvent.data should be
set to inserting string only on TextEditor when InputEvent.inputType is
"insertFromPaste", "insertFromPasteAsQuotation", "insertFromDrop",
"insertTranspose", "insertReplacementText" or "insertFromYank".
Currently, we support only "insertFromPaste", "insertFromDrop",
"insertReplacementText". Therefore, this patch makes TextEditor set
EditorBase::mEditActionData::mData only for them (and the instance is not
HTMLEditor's).
Differential Revision: https://phabricator.services.mozilla.com/D19287
--HG--
extra : moz-landing-system : lando
2019-02-19 09:28:57 +03:00
|
|
|
nsresult InsertFromDataTransfer(dom::DataTransfer* aDataTransfer,
|
|
|
|
int32_t aIndex, Document* aSourceDoc,
|
|
|
|
const EditorDOMPoint& aDroppedAt,
|
|
|
|
bool aDoDeleteSelection);
|
2018-11-09 11:40:57 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
bool HavePrivateHTMLFlavor(nsIClipboard* clipboard);
|
|
|
|
nsresult ParseCFHTML(nsCString& aCfhtml, char16_t** aStuffToPaste,
|
|
|
|
char16_t** aCfcontext);
|
|
|
|
|
|
|
|
nsresult StripFormattingNodes(nsIContent& aNode, bool aOnlyList = false);
|
|
|
|
nsresult CreateDOMFragmentFromPaste(
|
|
|
|
const nsAString& aInputString, const nsAString& aContextStr,
|
|
|
|
const nsAString& aInfoStr, nsCOMPtr<nsINode>* outFragNode,
|
|
|
|
nsCOMPtr<nsINode>* outStartNode, nsCOMPtr<nsINode>* outEndNode,
|
|
|
|
int32_t* outStartOffset, int32_t* outEndOffset, bool aTrustedInput);
|
|
|
|
nsresult ParseFragment(const nsAString& aStr, nsAtom* aContextLocalName,
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* aTargetDoc,
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
dom::DocumentFragment** aFragment, bool aTrustedInput);
|
|
|
|
void CreateListOfNodesToPaste(dom::DocumentFragment& aFragment,
|
|
|
|
nsTArray<OwningNonNull<nsINode>>& outNodeList,
|
|
|
|
nsINode* aStartContainer, int32_t aStartOffset,
|
|
|
|
nsINode* aEndContainer, int32_t aEndOffset);
|
|
|
|
enum class StartOrEnd { start, end };
|
|
|
|
void GetListAndTableParents(StartOrEnd aStartOrEnd,
|
|
|
|
nsTArray<OwningNonNull<nsINode>>& aNodeList,
|
|
|
|
nsTArray<OwningNonNull<Element>>& outArray);
|
|
|
|
int32_t DiscoverPartialListsAndTables(
|
|
|
|
nsTArray<OwningNonNull<nsINode>>& aPasteNodes,
|
|
|
|
nsTArray<OwningNonNull<Element>>& aListsAndTables);
|
|
|
|
nsINode* ScanForListAndTableStructure(
|
|
|
|
StartOrEnd aStartOrEnd, nsTArray<OwningNonNull<nsINode>>& aNodes,
|
|
|
|
Element& aListOrTable);
|
|
|
|
void ReplaceOrphanedStructure(
|
|
|
|
StartOrEnd aStartOrEnd, nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
|
|
|
nsTArray<OwningNonNull<Element>>& aListAndTableArray,
|
|
|
|
int32_t aHighWaterMark);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetBetterInsertionPointFor() returns better insertion point to insert
|
|
|
|
* aNodeToInsert.
|
|
|
|
*
|
|
|
|
* @param aNodeToInsert The node to insert.
|
|
|
|
* @param aPointToInsert A candidate point to insert the node.
|
|
|
|
* @return Better insertion point if next visible node
|
|
|
|
* is a <br> element and previous visible node
|
|
|
|
* is neither none, another <br> element nor
|
|
|
|
* different block level element.
|
|
|
|
*/
|
|
|
|
EditorRawDOMPoint GetBetterInsertionPointFor(
|
|
|
|
nsINode& aNodeToInsert, const EditorRawDOMPoint& aPointToInsert);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MakeDefinitionListItemWithTransaction() replaces parent list of current
|
|
|
|
* selection with <dl> or create new <dl> element and creates a definition
|
|
|
|
* list item whose name is aTagName.
|
|
|
|
*
|
|
|
|
* @param aTagName Must be nsGkAtoms::dt or nsGkAtoms::dd.
|
|
|
|
*/
|
|
|
|
nsresult MakeDefinitionListItemWithTransaction(nsAtom& aTagName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* InsertBasicBlockWithTransaction() inserts a block element whose name
|
|
|
|
* is aTagName at selection.
|
|
|
|
*
|
|
|
|
* @param aTagName A block level element name. Must NOT be
|
|
|
|
* nsGkAtoms::dt nor nsGkAtoms::dd.
|
|
|
|
*/
|
2019-05-08 01:34:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult InsertBasicBlockWithTransaction(nsAtom& aTagName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Increase/decrease the font size of selection.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult RelativeFontChange(FontSize aDir);
|
|
|
|
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult RelativeFontChangeOnNode(int32_t aSizeChange, nsIContent* aNode);
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult RelativeFontChangeHelper(int32_t aSizeChange, nsINode* aNode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper routines for inline style.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult SetInlinePropertyOnTextNode(Text& aData, int32_t aStartOffset,
|
|
|
|
int32_t aEndOffset, nsAtom& aProperty,
|
|
|
|
nsAtom* aAttribute,
|
|
|
|
const nsAString& aValue);
|
|
|
|
|
|
|
|
nsresult PromoteInlineRange(nsRange& aRange);
|
|
|
|
nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange& aRange);
|
2019-05-08 01:34:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult SplitStyleAboveRange(nsRange* aRange, nsAtom* aProperty,
|
|
|
|
nsAtom* aAttribute);
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult RemoveStyleInside(nsIContent& aNode, nsAtom* aProperty,
|
|
|
|
nsAtom* aAttribute,
|
|
|
|
const bool aChildrenOnly = false);
|
|
|
|
|
|
|
|
bool IsAtFrontOfNode(nsINode& aNode, int32_t aOffset);
|
|
|
|
bool IsAtEndOfNode(nsINode& aNode, int32_t aOffset);
|
|
|
|
bool IsOnlyAttribute(const Element* aElement, nsAtom* aAttribute);
|
|
|
|
|
|
|
|
bool HasStyleOrIdOrClass(Element* aElement);
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult RemoveElementIfNoStyleOrIdOrClass(Element& aElement);
|
Bug 1406726 - HTMLEditRules::WillInsertBreak() should reset mNewNode with caret position r=m_kato
HTMLEditRules::WillInsertBreak() started to use HTMLEditRules::MakeBasicBlock()
to wrap existing inline elements with default paragraph separator if inline
elements are children of editing host. However,
HTMLEditRules::ApplyBlockStyle() called by HTMLEditRules::MakeBasicBlock() sets
mNewNode to last new block node. So, if it wraps inline elements after caret
position, mNewNode becomes after expected caret position and
HTMLEditRules::AfterEditInner() will move caret into it.
This patch make HTMLEditRules::WillInsertBreak() reset mNewNode with
caret position after calling HTMLEditRules::MakeBasicBlock().
Additionally, this patch fixes a bug of HTMLEditor::IsVisibleBRElement().
That is, it uses only editable nodes to check if given <br> element is
visible. However, editable state is not related to this check. If <br>
element is followed by non-editable inline node (except invisible data
nodes), it always visible. This bug caused getting wrong nodes with
HTMLEditRules::GetNodesFromSelection() which is used by
HTMLEditRules::MakeBasicBlock(). Therefore, this patch also adds lots of
EditorBase::Get(Next|Previous)ElementOrText*() and
HTMLEditor::Get(Next|Previous)HTMLElementOrText*() to ignore only invisible
data nodes.
Note that even with this fix, the range of nodes computed by
HTMLEditRules::GetNodesFromSelection() is still odd if only non-editable
elements follow a <br> node which is first <br> element after the caret
position. However, what is expected by the execCommand spec is unclear.
So, automated test added by this patch checks current inconsistent behavior
for now.
MozReview-Commit-ID: 2m52StwoEEH
--HG--
extra : rebase_source : 6b9b2338e35c4d2e89a405fd8e1ffc7b0873ca1e
2018-02-13 13:01:42 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Whether the outer window of the DOM event target has focus or not.
|
Bug 1406726 - HTMLEditRules::WillInsertBreak() should reset mNewNode with caret position r=m_kato
HTMLEditRules::WillInsertBreak() started to use HTMLEditRules::MakeBasicBlock()
to wrap existing inline elements with default paragraph separator if inline
elements are children of editing host. However,
HTMLEditRules::ApplyBlockStyle() called by HTMLEditRules::MakeBasicBlock() sets
mNewNode to last new block node. So, if it wraps inline elements after caret
position, mNewNode becomes after expected caret position and
HTMLEditRules::AfterEditInner() will move caret into it.
This patch make HTMLEditRules::WillInsertBreak() reset mNewNode with
caret position after calling HTMLEditRules::MakeBasicBlock().
Additionally, this patch fixes a bug of HTMLEditor::IsVisibleBRElement().
That is, it uses only editable nodes to check if given <br> element is
visible. However, editable state is not related to this check. If <br>
element is followed by non-editable inline node (except invisible data
nodes), it always visible. This bug caused getting wrong nodes with
HTMLEditRules::GetNodesFromSelection() which is used by
HTMLEditRules::MakeBasicBlock(). Therefore, this patch also adds lots of
EditorBase::Get(Next|Previous)ElementOrText*() and
HTMLEditor::Get(Next|Previous)HTMLElementOrText*() to ignore only invisible
data nodes.
Note that even with this fix, the range of nodes computed by
HTMLEditRules::GetNodesFromSelection() is still odd if only non-editable
elements follow a <br> node which is first <br> element after the caret
position. However, what is expected by the execCommand spec is unclear.
So, automated test added by this patch checks current inconsistent behavior
for now.
MozReview-Commit-ID: 2m52StwoEEH
--HG--
extra : rebase_source : 6b9b2338e35c4d2e89a405fd8e1ffc7b0873ca1e
2018-02-13 13:01:42 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
bool OurWindowHasFocus();
|
Bug 1406726 - HTMLEditRules::WillInsertBreak() should reset mNewNode with caret position r=m_kato
HTMLEditRules::WillInsertBreak() started to use HTMLEditRules::MakeBasicBlock()
to wrap existing inline elements with default paragraph separator if inline
elements are children of editing host. However,
HTMLEditRules::ApplyBlockStyle() called by HTMLEditRules::MakeBasicBlock() sets
mNewNode to last new block node. So, if it wraps inline elements after caret
position, mNewNode becomes after expected caret position and
HTMLEditRules::AfterEditInner() will move caret into it.
This patch make HTMLEditRules::WillInsertBreak() reset mNewNode with
caret position after calling HTMLEditRules::MakeBasicBlock().
Additionally, this patch fixes a bug of HTMLEditor::IsVisibleBRElement().
That is, it uses only editable nodes to check if given <br> element is
visible. However, editable state is not related to this check. If <br>
element is followed by non-editable inline node (except invisible data
nodes), it always visible. This bug caused getting wrong nodes with
HTMLEditRules::GetNodesFromSelection() which is used by
HTMLEditRules::MakeBasicBlock(). Therefore, this patch also adds lots of
EditorBase::Get(Next|Previous)ElementOrText*() and
HTMLEditor::Get(Next|Previous)HTMLElementOrText*() to ignore only invisible
data nodes.
Note that even with this fix, the range of nodes computed by
HTMLEditRules::GetNodesFromSelection() is still odd if only non-editable
elements follow a <br> node which is first <br> element after the caret
position. However, what is expected by the execCommand spec is unclear.
So, automated test added by this patch checks current inconsistent behavior
for now.
MozReview-Commit-ID: 2m52StwoEEH
--HG--
extra : rebase_source : 6b9b2338e35c4d2e89a405fd8e1ffc7b0873ca1e
2018-02-13 13:01:42 +03:00
|
|
|
|
2017-11-09 17:31:59 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* This function is used to insert a string of HTML input optionally with some
|
|
|
|
* context information into the editable field. The HTML input either comes
|
|
|
|
* from a transferable object created as part of a drop/paste operation, or
|
|
|
|
* from the InsertHTML method. We may want the HTML input to be sanitized
|
|
|
|
* (for example, if it's coming from a transferable object), in which case
|
|
|
|
* aTrustedInput should be set to false, otherwise, the caller should set it
|
|
|
|
* to true, which means that the HTML will be inserted in the DOM verbatim.
|
|
|
|
*
|
|
|
|
* aClearStyle should be set to false if you want the paste to be affected by
|
|
|
|
* local style (e.g., for the insertHTML command).
|
2017-11-09 17:31:59 +03:00
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult DoInsertHTMLWithContext(
|
|
|
|
const nsAString& aInputString, const nsAString& aContextStr,
|
2019-01-02 16:05:23 +03:00
|
|
|
const nsAString& aInfoStr, const nsAString& aFlavor, Document* aSourceDoc,
|
|
|
|
const EditorDOMPoint& aPointToInsert, bool aDeleteSelection,
|
|
|
|
bool aTrustedInput, bool aClearStyle = true);
|
2017-11-09 17:31:59 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* sets the position of an element; warning it does NOT check if the
|
|
|
|
* element is already positioned or not and that's on purpose.
|
|
|
|
* @param aElement [IN] the element
|
|
|
|
* @param aX [IN] the x position in pixels.
|
|
|
|
* @param aY [IN] the y position in pixels.
|
2017-11-09 17:31:59 +03:00
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void SetTopAndLeft(Element& aElement, int32_t aX,
|
|
|
|
int32_t aY);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1406726 - HTMLEditRules::WillInsertBreak() should reset mNewNode with caret position r=m_kato
HTMLEditRules::WillInsertBreak() started to use HTMLEditRules::MakeBasicBlock()
to wrap existing inline elements with default paragraph separator if inline
elements are children of editing host. However,
HTMLEditRules::ApplyBlockStyle() called by HTMLEditRules::MakeBasicBlock() sets
mNewNode to last new block node. So, if it wraps inline elements after caret
position, mNewNode becomes after expected caret position and
HTMLEditRules::AfterEditInner() will move caret into it.
This patch make HTMLEditRules::WillInsertBreak() reset mNewNode with
caret position after calling HTMLEditRules::MakeBasicBlock().
Additionally, this patch fixes a bug of HTMLEditor::IsVisibleBRElement().
That is, it uses only editable nodes to check if given <br> element is
visible. However, editable state is not related to this check. If <br>
element is followed by non-editable inline node (except invisible data
nodes), it always visible. This bug caused getting wrong nodes with
HTMLEditRules::GetNodesFromSelection() which is used by
HTMLEditRules::MakeBasicBlock(). Therefore, this patch also adds lots of
EditorBase::Get(Next|Previous)ElementOrText*() and
HTMLEditor::Get(Next|Previous)HTMLElementOrText*() to ignore only invisible
data nodes.
Note that even with this fix, the range of nodes computed by
HTMLEditRules::GetNodesFromSelection() is still odd if only non-editable
elements follow a <br> node which is first <br> element after the caret
position. However, what is expected by the execCommand spec is unclear.
So, automated test added by this patch checks current inconsistent behavior
for now.
MozReview-Commit-ID: 2m52StwoEEH
--HG--
extra : rebase_source : 6b9b2338e35c4d2e89a405fd8e1ffc7b0873ca1e
2018-02-13 13:01:42 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Reset a selected cell or collapsed selection (the caret) after table
|
|
|
|
* editing.
|
Bug 1406726 - HTMLEditRules::WillInsertBreak() should reset mNewNode with caret position r=m_kato
HTMLEditRules::WillInsertBreak() started to use HTMLEditRules::MakeBasicBlock()
to wrap existing inline elements with default paragraph separator if inline
elements are children of editing host. However,
HTMLEditRules::ApplyBlockStyle() called by HTMLEditRules::MakeBasicBlock() sets
mNewNode to last new block node. So, if it wraps inline elements after caret
position, mNewNode becomes after expected caret position and
HTMLEditRules::AfterEditInner() will move caret into it.
This patch make HTMLEditRules::WillInsertBreak() reset mNewNode with
caret position after calling HTMLEditRules::MakeBasicBlock().
Additionally, this patch fixes a bug of HTMLEditor::IsVisibleBRElement().
That is, it uses only editable nodes to check if given <br> element is
visible. However, editable state is not related to this check. If <br>
element is followed by non-editable inline node (except invisible data
nodes), it always visible. This bug caused getting wrong nodes with
HTMLEditRules::GetNodesFromSelection() which is used by
HTMLEditRules::MakeBasicBlock(). Therefore, this patch also adds lots of
EditorBase::Get(Next|Previous)ElementOrText*() and
HTMLEditor::Get(Next|Previous)HTMLElementOrText*() to ignore only invisible
data nodes.
Note that even with this fix, the range of nodes computed by
HTMLEditRules::GetNodesFromSelection() is still odd if only non-editable
elements follow a <br> node which is first <br> element after the caret
position. However, what is expected by the execCommand spec is unclear.
So, automated test added by this patch checks current inconsistent behavior
for now.
MozReview-Commit-ID: 2m52StwoEEH
--HG--
extra : rebase_source : 6b9b2338e35c4d2e89a405fd8e1ffc7b0873ca1e
2018-02-13 13:01:42 +03:00
|
|
|
*
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* @param aTable A table in the document.
|
|
|
|
* @param aRow The row ...
|
|
|
|
* @param aCol ... and column defining the cell where we will try to
|
|
|
|
* place the caret.
|
|
|
|
* @param aSelected If true, we select the whole cell instead of setting
|
|
|
|
* caret.
|
|
|
|
* @param aDirection If cell at (aCol, aRow) is not found, search for
|
|
|
|
* previous cell in the same column (aPreviousColumn) or
|
|
|
|
* row (ePreviousRow) or don't search for another cell
|
|
|
|
* (aNoSearch). If no cell is found, caret is place just
|
|
|
|
* before table; and if that fails, at beginning of
|
|
|
|
* document. Thus we generally don't worry about the
|
|
|
|
* return value and can use the
|
|
|
|
* AutoSelectionSetterAfterTableEdit stack-based object to
|
|
|
|
* insure we reset the caret in a table-editing method.
|
Bug 1406726 - HTMLEditRules::WillInsertBreak() should reset mNewNode with caret position r=m_kato
HTMLEditRules::WillInsertBreak() started to use HTMLEditRules::MakeBasicBlock()
to wrap existing inline elements with default paragraph separator if inline
elements are children of editing host. However,
HTMLEditRules::ApplyBlockStyle() called by HTMLEditRules::MakeBasicBlock() sets
mNewNode to last new block node. So, if it wraps inline elements after caret
position, mNewNode becomes after expected caret position and
HTMLEditRules::AfterEditInner() will move caret into it.
This patch make HTMLEditRules::WillInsertBreak() reset mNewNode with
caret position after calling HTMLEditRules::MakeBasicBlock().
Additionally, this patch fixes a bug of HTMLEditor::IsVisibleBRElement().
That is, it uses only editable nodes to check if given <br> element is
visible. However, editable state is not related to this check. If <br>
element is followed by non-editable inline node (except invisible data
nodes), it always visible. This bug caused getting wrong nodes with
HTMLEditRules::GetNodesFromSelection() which is used by
HTMLEditRules::MakeBasicBlock(). Therefore, this patch also adds lots of
EditorBase::Get(Next|Previous)ElementOrText*() and
HTMLEditor::Get(Next|Previous)HTMLElementOrText*() to ignore only invisible
data nodes.
Note that even with this fix, the range of nodes computed by
HTMLEditRules::GetNodesFromSelection() is still odd if only non-editable
elements follow a <br> node which is first <br> element after the caret
position. However, what is expected by the execCommand spec is unclear.
So, automated test added by this patch checks current inconsistent behavior
for now.
MozReview-Commit-ID: 2m52StwoEEH
--HG--
extra : rebase_source : 6b9b2338e35c4d2e89a405fd8e1ffc7b0873ca1e
2018-02-13 13:01:42 +03:00
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
void SetSelectionAfterTableEdit(Element* aTable, int32_t aRow, int32_t aCol,
|
|
|
|
int32_t aDirection, bool aSelected);
|
Bug 1406726 - HTMLEditRules::WillInsertBreak() should reset mNewNode with caret position r=m_kato
HTMLEditRules::WillInsertBreak() started to use HTMLEditRules::MakeBasicBlock()
to wrap existing inline elements with default paragraph separator if inline
elements are children of editing host. However,
HTMLEditRules::ApplyBlockStyle() called by HTMLEditRules::MakeBasicBlock() sets
mNewNode to last new block node. So, if it wraps inline elements after caret
position, mNewNode becomes after expected caret position and
HTMLEditRules::AfterEditInner() will move caret into it.
This patch make HTMLEditRules::WillInsertBreak() reset mNewNode with
caret position after calling HTMLEditRules::MakeBasicBlock().
Additionally, this patch fixes a bug of HTMLEditor::IsVisibleBRElement().
That is, it uses only editable nodes to check if given <br> element is
visible. However, editable state is not related to this check. If <br>
element is followed by non-editable inline node (except invisible data
nodes), it always visible. This bug caused getting wrong nodes with
HTMLEditRules::GetNodesFromSelection() which is used by
HTMLEditRules::MakeBasicBlock(). Therefore, this patch also adds lots of
EditorBase::Get(Next|Previous)ElementOrText*() and
HTMLEditor::Get(Next|Previous)HTMLElementOrText*() to ignore only invisible
data nodes.
Note that even with this fix, the range of nodes computed by
HTMLEditRules::GetNodesFromSelection() is still odd if only non-editable
elements follow a <br> node which is first <br> element after the caret
position. However, what is expected by the execCommand spec is unclear.
So, automated test added by this patch checks current inconsistent behavior
for now.
MozReview-Commit-ID: 2m52StwoEEH
--HG--
extra : rebase_source : 6b9b2338e35c4d2e89a405fd8e1ffc7b0873ca1e
2018-02-13 13:01:42 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
void RemoveListenerAndDeleteRef(const nsAString& aEvent,
|
|
|
|
nsIDOMEventListener* aListener,
|
|
|
|
bool aUseCapture, ManualNACPtr aElement,
|
2019-03-15 08:01:10 +03:00
|
|
|
PresShell* aPresShell);
|
|
|
|
void DeleteRefToAnonymousNode(ManualNACPtr aContent, PresShell* aPresShell);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
2018-08-17 11:56:28 +03:00
|
|
|
/**
|
2019-05-09 10:37:51 +03:00
|
|
|
* RefreshEditingUI() may refresh editing UIs for current Selection, focus,
|
2018-08-17 11:56:28 +03:00
|
|
|
* etc. If this shows or hides some UIs, it causes reflow. So, this is
|
|
|
|
* not safe method.
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult RefreshEditingUI();
|
2018-08-17 11:56:28 +03:00
|
|
|
|
2017-11-09 18:12:22 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Returns the offset of an element's frame to its absolute containing block.
|
2017-11-09 18:12:22 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult GetElementOrigin(Element& aElement, int32_t& aX, int32_t& aY);
|
|
|
|
nsresult GetPositionAndDimensions(Element& aElement, int32_t& aX, int32_t& aY,
|
|
|
|
int32_t& aW, int32_t& aH,
|
|
|
|
int32_t& aBorderLeft, int32_t& aBorderTop,
|
|
|
|
int32_t& aMarginLeft, int32_t& aMarginTop);
|
|
|
|
|
|
|
|
bool IsInObservedSubtree(nsIContent* aChild);
|
|
|
|
|
|
|
|
void UpdateRootElement();
|
|
|
|
|
2018-09-11 11:15:52 +03:00
|
|
|
/**
|
|
|
|
* SetAllResizersPosition() moves all resizers to proper position.
|
|
|
|
* If the resizers are hidden or replaced with another set of resizers
|
|
|
|
* while this is running, this returns error. So, callers shouldn't
|
|
|
|
* keep handling the resizers if this returns error.
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetAllResizersPosition();
|
2017-11-09 18:12:22 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Shows active resizers around an element's frame
|
|
|
|
* @param aResizedElement [IN] a DOM Element
|
2017-11-09 18:12:22 +03:00
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult ShowResizersInternal(Element& aResizedElement);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-09-06 08:02:46 +03:00
|
|
|
/**
|
|
|
|
* Hide resizers if they are visible. If this is called while there is no
|
|
|
|
* visible resizers, this does not return error, but does nothing.
|
|
|
|
*/
|
|
|
|
nsresult HideResizersInternal();
|
|
|
|
|
2018-09-11 11:15:52 +03:00
|
|
|
/**
|
|
|
|
* RefreshResizersInternal() moves resizers to proper position. This does
|
|
|
|
* nothing if there is no resizing target.
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult RefreshResizersInternal();
|
2018-09-11 11:15:52 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
ManualNACPtr CreateResizer(int16_t aLocation, nsIContent& aParentContent);
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void SetAnonymousElementPosition(int32_t aX, int32_t aY,
|
|
|
|
Element* aResizer);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
ManualNACPtr CreateShadow(nsIContent& aParentContent,
|
|
|
|
Element& aOriginalObject);
|
2018-09-11 11:15:52 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SetShadowPosition() moves the shadow element to proper position.
|
|
|
|
*
|
|
|
|
* @param aShadowElement Must be mResizingShadow or mPositioningShadow.
|
|
|
|
* @param aElement The element which has the shadow.
|
|
|
|
* @param aElementX Left of aElement.
|
|
|
|
* @param aElementY Top of aElement.
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetShadowPosition(Element& aShadowElement,
|
|
|
|
Element& aElement,
|
|
|
|
int32_t aElementLeft,
|
|
|
|
int32_t aElementTop);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
ManualNACPtr CreateResizingInfo(nsIContent& aParentContent);
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetResizingInfoPosition(int32_t aX, int32_t aY,
|
|
|
|
int32_t aW, int32_t aH);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
|
|
|
|
enum class ResizeAt {
|
|
|
|
eX,
|
|
|
|
eY,
|
|
|
|
eWidth,
|
|
|
|
eHeight,
|
|
|
|
};
|
|
|
|
int32_t GetNewResizingIncrement(int32_t aX, int32_t aY, ResizeAt aResizeAt);
|
|
|
|
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult StartResizing(Element* aHandle);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
int32_t GetNewResizingX(int32_t aX, int32_t aY);
|
|
|
|
int32_t GetNewResizingY(int32_t aX, int32_t aY);
|
|
|
|
int32_t GetNewResizingWidth(int32_t aX, int32_t aY);
|
|
|
|
int32_t GetNewResizingHeight(int32_t aX, int32_t aY);
|
|
|
|
void HideShadowAndInfo();
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void SetFinalSize(int32_t aX, int32_t aY);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
void SetResizeIncrements(int32_t aX, int32_t aY, int32_t aW, int32_t aH,
|
|
|
|
bool aPreserveRatio);
|
2018-08-17 13:03:02 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* HideAnonymousEditingUIs() forcibly hides all editing UIs (resizers,
|
|
|
|
* inline-table-editing UI, absolute positioning UI).
|
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
void HideAnonymousEditingUIs();
|
|
|
|
|
2018-08-17 13:03:02 +03:00
|
|
|
/**
|
|
|
|
* HideAnonymousEditingUIsIfUnnecessary() hides all editing UIs if some of
|
|
|
|
* visible UIs are now unnecessary.
|
|
|
|
*/
|
|
|
|
void HideAnonymousEditingUIsIfUnnecessary();
|
|
|
|
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
/**
|
|
|
|
* sets the z-index of an element.
|
|
|
|
* @param aElement [IN] the element
|
|
|
|
* @param aZorder [IN] the z-index
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void SetZIndex(Element& aElement, int32_t aZorder);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* shows a grabber attached to an arbitrary element. The grabber is an image
|
|
|
|
* positioned on the left hand side of the top border of the element. Draggin
|
|
|
|
* and dropping it allows to change the element's absolute position in the
|
|
|
|
* document. See chrome://editor/content/images/grabber.gif
|
|
|
|
* @param aElement [IN] the element
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult ShowGrabberInternal(Element& aElement);
|
2018-09-11 08:30:33 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Setting grabber to proper position for current mAbsolutelyPositionedObject.
|
|
|
|
* For example, while an element has grabber, the element may be resized
|
|
|
|
* or repositioned by script or something. Then, you need to reset grabber
|
|
|
|
* position with this.
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult RefreshGrabberInternal();
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* hide the grabber if it shown.
|
2016-07-09 05:42:33 +03:00
|
|
|
*/
|
2018-09-11 08:30:33 +03:00
|
|
|
void HideGrabberInternal();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CreateGrabberInternal() creates a grabber for moving aParentContent.
|
|
|
|
* This sets mGrabber to the new grabber. If this returns true, it's
|
|
|
|
* always non-nullptr. Otherwise, i.e., the grabber is hidden during
|
|
|
|
* creation, this returns false.
|
|
|
|
*/
|
|
|
|
bool CreateGrabberInternal(nsIContent& aParentContent);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult StartMoving();
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetFinalPosition(int32_t aX, int32_t aY);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
void AddPositioningOffset(int32_t& aX, int32_t& aY);
|
|
|
|
void SnapToGrid(int32_t& newX, int32_t& newY);
|
|
|
|
nsresult GrabberClicked();
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult EndMoving();
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
nsresult GetTemporaryStyleForFocusedPositionedElement(Element& aElement,
|
|
|
|
nsAString& aReturn);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-02-01 04:55:25 +03:00
|
|
|
/**
|
2018-09-11 15:10:54 +03:00
|
|
|
* Shows inline table editing UI around a <table> element which contains
|
|
|
|
* aCellElement. This returns error if creating UI is hidden during this,
|
|
|
|
* or detects another set of UI during this. In such case, callers
|
|
|
|
* shouldn't keep handling anything for the UI.
|
|
|
|
*
|
|
|
|
* @param aCellElement Must be an <td> or <th> element.
|
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
ShowInlineTableEditingUIInternal(Element& aCellElement);
|
2018-09-11 15:10:54 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hide all inline table editing UI.
|
2018-02-01 04:55:25 +03:00
|
|
|
*/
|
2018-09-11 15:10:54 +03:00
|
|
|
void HideInlineTableEditingUIInternal();
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2017-08-08 04:57:19 +03:00
|
|
|
/**
|
2018-09-11 15:10:54 +03:00
|
|
|
* RefreshInlineTableEditingUIInternal() moves inline table editing UI to
|
|
|
|
* proper position. This returns error if the UI is hidden or replaced
|
|
|
|
* during moving.
|
2017-08-08 04:57:19 +03:00
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult RefreshInlineTableEditingUIInternal();
|
2017-08-08 04:57:19 +03:00
|
|
|
|
2018-01-30 07:27:59 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* IsEmptyTextNode() returns true if aNode is a text node and does not have
|
|
|
|
* any visible characters.
|
2018-01-30 07:27:59 +03:00
|
|
|
*/
|
2019-08-12 11:31:04 +03:00
|
|
|
bool IsEmptyTextNode(nsINode& aNode) const;
|
2018-01-30 07:27:59 +03:00
|
|
|
|
2019-05-09 10:37:51 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT bool IsSimpleModifiableNode(nsIContent* aContent,
|
|
|
|
nsAtom* aProperty,
|
|
|
|
nsAtom* aAttribute,
|
|
|
|
const nsAString* aValue);
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
SetInlinePropertyOnNodeImpl(nsIContent& aNode, nsAtom& aProperty,
|
|
|
|
nsAtom* aAttribute, const nsAString& aValue);
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
typedef enum { eInserted, eAppended } InsertedOrAppended;
|
|
|
|
void DoContentInserted(nsIContent* aChild, InsertedOrAppended);
|
2018-08-10 13:36:24 +03:00
|
|
|
|
2018-04-12 11:20:21 +03:00
|
|
|
/**
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
* Returns an anonymous Element of type aTag,
|
|
|
|
* child of aParentContent. If aIsCreatedHidden is true, the class
|
|
|
|
* "hidden" is added to the created element. If aAnonClass is not
|
|
|
|
* the empty string, it becomes the value of the attribute "_moz_anonclass"
|
|
|
|
* @return a Element
|
|
|
|
* @param aTag [IN] desired type of the element to create
|
|
|
|
* @param aParentContent [IN] the parent node of the created anonymous
|
|
|
|
* element
|
|
|
|
* @param aAnonClass [IN] contents of the _moz_anonclass attribute
|
|
|
|
* @param aIsCreatedHidden [IN] a boolean specifying if the class "hidden"
|
|
|
|
* is to be added to the created anonymous
|
|
|
|
* element
|
2018-04-12 11:20:21 +03:00
|
|
|
*/
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
ManualNACPtr CreateAnonymousElement(nsAtom* aTag, nsIContent& aParentContent,
|
|
|
|
const nsAString& aAnonClass,
|
|
|
|
bool aIsCreatedHidden);
|
2018-09-09 01:44:23 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads a blob into memory and notifies the BlobReader object when the read
|
|
|
|
* operation is finished.
|
|
|
|
*
|
|
|
|
* @param aBlob The input blob
|
|
|
|
* @param aWindow The global object under which the read should happen.
|
|
|
|
* @param aBlobReader The blob reader object to be notified when finished.
|
|
|
|
*/
|
|
|
|
static nsresult SlurpBlob(dom::Blob* aBlob, nsPIDOMWindowOuter* aWindow,
|
|
|
|
BlobReader* aBlobReader);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-08-13 03:56:57 +03:00
|
|
|
/**
|
|
|
|
* OnModifyDocumentInternal() is called by OnModifyDocument().
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT MOZ_MUST_USE nsresult OnModifyDocumentInternal();
|
|
|
|
|
2019-08-20 04:51:19 +03:00
|
|
|
/**
|
|
|
|
* For saving allocation cost in the constructor of
|
|
|
|
* EditorBase::TopLevelEditSubActionData, we should reuse same RangeItem
|
|
|
|
* instance with all top level edit sub actions.
|
|
|
|
* The instance is always cleared when TopLevelEditSubActionData is
|
|
|
|
* destructed and the class is stack only class so that we don't need
|
|
|
|
* to (and also should not) add the RangeItem into the cycle collection.
|
|
|
|
*/
|
|
|
|
already_AddRefed<RangeItem> GetSelectedRangeItemForTopLevelEditSubAction()
|
|
|
|
const {
|
|
|
|
if (!mSelectedRangeForTopLevelEditSubAction) {
|
|
|
|
mSelectedRangeForTopLevelEditSubAction = new RangeItem();
|
|
|
|
}
|
|
|
|
return do_AddRef(mSelectedRangeForTopLevelEditSubAction);
|
|
|
|
}
|
|
|
|
|
2019-08-20 04:51:59 +03:00
|
|
|
/**
|
|
|
|
* For saving allocation cost in the constructor of
|
|
|
|
* EditorBase::TopLevelEditSubActionData, we should reuse same nsRange
|
|
|
|
* instance with all top level edit sub actions.
|
|
|
|
* The instance is always cleared when TopLevelEditSubActionData is
|
|
|
|
* destructed, but AbstractRange::mOwner keeps grabbing the owner document
|
|
|
|
* so that we need to make it in the cycle collection.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsRange> GetChangedRangeForTopLevelEditSubAction() const {
|
|
|
|
if (!mChangedRangeForTopLevelEditSubAction) {
|
|
|
|
mChangedRangeForTopLevelEditSubAction = new nsRange(GetDocument());
|
|
|
|
}
|
|
|
|
return do_AddRef(mChangedRangeForTopLevelEditSubAction);
|
|
|
|
}
|
|
|
|
|
2016-07-09 05:42:33 +03:00
|
|
|
protected:
|
|
|
|
RefPtr<TypeInState> mTypeInState;
|
2018-01-26 08:38:05 +03:00
|
|
|
RefPtr<ComposerCommandsUpdater> mComposerCommandsUpdater;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2019-08-20 04:51:19 +03:00
|
|
|
// Used by TopLevelEditSubActionData::mSelectedRange.
|
|
|
|
mutable RefPtr<RangeItem> mSelectedRangeForTopLevelEditSubAction;
|
2019-08-20 04:51:59 +03:00
|
|
|
// Used by TopLevelEditSubActionData::mChangedRange.
|
|
|
|
mutable RefPtr<nsRange> mChangedRangeForTopLevelEditSubAction;
|
2019-08-20 04:51:19 +03:00
|
|
|
|
2016-07-09 05:42:33 +03:00
|
|
|
bool mCRInParagraphCreatesParagraph;
|
|
|
|
|
|
|
|
bool mCSSAware;
|
2017-02-08 12:14:24 +03:00
|
|
|
UniquePtr<CSSEditUtils> mCSSEditUtils;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-08-24 11:29:12 +03:00
|
|
|
// mSelectedCellIndex is reset by GetFirstSelectedTableCellElement(),
|
2018-08-27 09:50:12 +03:00
|
|
|
// then, it'll be referred and incremented by
|
|
|
|
// GetNextSelectedTableCellElement().
|
|
|
|
mutable uint32_t mSelectedCellIndex;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
nsString mLastStyleSheetURL;
|
|
|
|
nsString mLastOverrideStyleSheetURL;
|
|
|
|
|
|
|
|
// Maintain a list of associated style sheets and their urls.
|
|
|
|
nsTArray<nsString> mStyleSheetURLs;
|
2016-09-26 15:03:25 +03:00
|
|
|
nsTArray<RefPtr<StyleSheet>> mStyleSheets;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
// resizing
|
|
|
|
bool mIsObjectResizingEnabled;
|
|
|
|
bool mIsResizing;
|
|
|
|
bool mPreserveRatio;
|
|
|
|
bool mResizedObjectIsAnImage;
|
|
|
|
|
|
|
|
// absolute positioning
|
|
|
|
bool mIsAbsolutelyPositioningEnabled;
|
|
|
|
bool mResizedObjectIsAbsolutelyPositioned;
|
|
|
|
bool mGrabberClicked;
|
|
|
|
bool mIsMoving;
|
|
|
|
|
|
|
|
bool mSnapToGridEnabled;
|
|
|
|
|
|
|
|
// inline table editing
|
|
|
|
bool mIsInlineTableEditingEnabled;
|
|
|
|
|
|
|
|
// resizing
|
2017-08-02 22:37:44 +03:00
|
|
|
ManualNACPtr mTopLeftHandle;
|
|
|
|
ManualNACPtr mTopHandle;
|
|
|
|
ManualNACPtr mTopRightHandle;
|
|
|
|
ManualNACPtr mLeftHandle;
|
|
|
|
ManualNACPtr mRightHandle;
|
|
|
|
ManualNACPtr mBottomLeftHandle;
|
|
|
|
ManualNACPtr mBottomHandle;
|
|
|
|
ManualNACPtr mBottomRightHandle;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-08-24 09:27:48 +03:00
|
|
|
RefPtr<Element> mActivatedHandle;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2017-08-02 22:37:44 +03:00
|
|
|
ManualNACPtr mResizingShadow;
|
|
|
|
ManualNACPtr mResizingInfo;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2018-04-27 06:35:18 +03:00
|
|
|
RefPtr<Element> mResizedObject;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
int32_t mOriginalX;
|
|
|
|
int32_t mOriginalY;
|
|
|
|
|
|
|
|
int32_t mResizedObjectX;
|
|
|
|
int32_t mResizedObjectY;
|
|
|
|
int32_t mResizedObjectWidth;
|
|
|
|
int32_t mResizedObjectHeight;
|
|
|
|
|
|
|
|
int32_t mResizedObjectMarginLeft;
|
|
|
|
int32_t mResizedObjectMarginTop;
|
|
|
|
int32_t mResizedObjectBorderLeft;
|
|
|
|
int32_t mResizedObjectBorderTop;
|
|
|
|
|
|
|
|
int32_t mXIncrementFactor;
|
|
|
|
int32_t mYIncrementFactor;
|
|
|
|
int32_t mWidthIncrementFactor;
|
|
|
|
int32_t mHeightIncrementFactor;
|
|
|
|
|
|
|
|
int8_t mInfoXIncrement;
|
|
|
|
int8_t mInfoYIncrement;
|
|
|
|
|
|
|
|
// absolute positioning
|
|
|
|
int32_t mPositionedObjectX;
|
|
|
|
int32_t mPositionedObjectY;
|
|
|
|
int32_t mPositionedObjectWidth;
|
|
|
|
int32_t mPositionedObjectHeight;
|
|
|
|
|
|
|
|
int32_t mPositionedObjectMarginLeft;
|
|
|
|
int32_t mPositionedObjectMarginTop;
|
|
|
|
int32_t mPositionedObjectBorderLeft;
|
|
|
|
int32_t mPositionedObjectBorderTop;
|
|
|
|
|
2018-09-11 08:30:33 +03:00
|
|
|
RefPtr<Element> mAbsolutelyPositionedObject;
|
2017-08-02 22:37:44 +03:00
|
|
|
ManualNACPtr mGrabber;
|
|
|
|
ManualNACPtr mPositioningShadow;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
|
|
|
int32_t mGridSize;
|
|
|
|
|
|
|
|
// inline table editing
|
2017-12-15 19:14:54 +03:00
|
|
|
RefPtr<Element> mInlineEditedCell;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2017-08-02 22:37:44 +03:00
|
|
|
ManualNACPtr mAddColumnBeforeButton;
|
|
|
|
ManualNACPtr mRemoveColumnButton;
|
|
|
|
ManualNACPtr mAddColumnAfterButton;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2017-08-02 22:37:44 +03:00
|
|
|
ManualNACPtr mAddRowBeforeButton;
|
|
|
|
ManualNACPtr mRemoveRowButton;
|
|
|
|
ManualNACPtr mAddRowAfterButton;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2016-11-24 09:58:01 +03:00
|
|
|
void AddMouseClickListener(Element* aElement);
|
|
|
|
void RemoveMouseClickListener(Element* aElement);
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2019-07-09 19:17:27 +03:00
|
|
|
bool mDisabledLinkHandling = false;
|
|
|
|
bool mOldLinkHandlingEnabled = false;
|
2016-07-09 05:42:33 +03:00
|
|
|
|
2017-04-06 15:02:42 +03:00
|
|
|
ParagraphSeparator mDefaultParagraphSeparator;
|
2016-08-24 15:53:52 +03:00
|
|
|
|
2017-08-08 04:57:19 +03:00
|
|
|
friend class AutoSelectionSetterAfterTableEdit;
|
2018-09-20 13:03:24 +03:00
|
|
|
friend class AutoSetTemporaryAncestorLimiter;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
friend class CSSEditUtils;
|
2018-08-16 13:29:20 +03:00
|
|
|
friend class EditorBase;
|
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make HTMLEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in HTMLEditor.h
(except removes BlockTransformationType since it's unused and replaces
ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by
searchfox.org).
MozReview-Commit-ID: 7PC8E8vD7w2
--HG--
extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
2018-05-22 12:28:50 +03:00
|
|
|
friend class EmptyEditableFunctor;
|
2016-07-09 05:42:33 +03:00
|
|
|
friend class HTMLEditRules;
|
2018-09-18 07:34:21 +03:00
|
|
|
friend class SlurpBlobEventListener;
|
2018-08-13 07:37:56 +03:00
|
|
|
friend class TextEditor;
|
2016-07-09 05:42:33 +03:00
|
|
|
friend class WSRunObject;
|
2019-08-12 11:30:57 +03:00
|
|
|
friend class WSRunScanner;
|
2016-07-09 05:42:33 +03:00
|
|
|
};
|
|
|
|
|
2017-08-04 09:01:36 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
mozilla::HTMLEditor* nsIEditor::AsHTMLEditor() {
|
|
|
|
return static_cast<mozilla::EditorBase*>(this)->mIsHTMLEditorClass
|
|
|
|
? static_cast<mozilla::HTMLEditor*>(this)
|
|
|
|
: nullptr;
|
2017-08-04 00:18:50 +03:00
|
|
|
}
|
|
|
|
|
2017-08-04 09:01:36 +03:00
|
|
|
const mozilla::HTMLEditor* nsIEditor::AsHTMLEditor() const {
|
|
|
|
return static_cast<const mozilla::EditorBase*>(this)->mIsHTMLEditorClass
|
|
|
|
? static_cast<const mozilla::HTMLEditor*>(this)
|
|
|
|
: nullptr;
|
2017-08-04 00:18:50 +03:00
|
|
|
}
|
|
|
|
|
2016-07-09 05:42:33 +03:00
|
|
|
#endif // #ifndef mozilla_HTMLEditor_h
|