зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1471115 - Remove unused methods in nsIHTMLEditor. r=masayuki
insertHTMLWithContext, getIndentState, setBodyAttribute and getSelectionContainer are unused from script (inc. c-c and bluegriffon). Differential Revision: https://phabricator.services.mozilla.com/D1822
This commit is contained in:
Родитель
0f901b5c31
Коммит
8bd7e4fabf
|
@ -1101,111 +1101,6 @@ MarginPropertyAtomForIndent(nsINode& aNode)
|
|||
*nsGkAtoms::marginRight : *nsGkAtoms::marginLeft;
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditRules::GetIndentState(bool* aCanIndent,
|
||||
bool* aCanOutdent)
|
||||
{
|
||||
if (NS_WARN_IF(!aCanIndent) || NS_WARN_IF(!aCanOutdent)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
|
||||
// XXX Looks like that this is implementation of
|
||||
// nsIHTMLEditor::getIndentState() however nobody calls this method
|
||||
// even with the interface method.
|
||||
*aCanIndent = true;
|
||||
*aCanOutdent = false;
|
||||
|
||||
Selection* selection = mHTMLEditor->GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
AutoSafeEditorData setData(*this, *mHTMLEditor, *selection);
|
||||
|
||||
// contruct a list of nodes to act on.
|
||||
nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
|
||||
nsresult rv =
|
||||
GetNodesFromSelection(EditSubAction::eIndent, arrayOfNodes,
|
||||
TouchContent::no);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// examine nodes in selection for blockquotes or list elements;
|
||||
// these we can outdent. Note that we return true for canOutdent
|
||||
// if *any* of the selection is outdentable, rather than all of it.
|
||||
bool useCSS = HTMLEditorRef().IsCSSEnabled();
|
||||
for (auto& curNode : Reversed(arrayOfNodes)) {
|
||||
if (HTMLEditUtils::IsNodeThatCanOutdent(curNode)) {
|
||||
*aCanOutdent = true;
|
||||
break;
|
||||
} else if (useCSS) {
|
||||
// we are in CSS mode, indentation is done using the margin-left (or margin-right) property
|
||||
nsAtom& marginProperty = MarginPropertyAtomForIndent(curNode);
|
||||
nsAutoString value;
|
||||
// retrieve its specified value
|
||||
CSSEditUtils::GetSpecifiedProperty(*curNode, marginProperty, value);
|
||||
float f;
|
||||
RefPtr<nsAtom> unit;
|
||||
// get its number part and its unit
|
||||
CSSEditUtils::ParseLength(value, &f, getter_AddRefs(unit));
|
||||
// if the number part is strictly positive, outdent is possible
|
||||
if (0 < f) {
|
||||
*aCanOutdent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (*aCanOutdent) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if we haven't found something to outdent yet, also check the parents
|
||||
// of selection endpoints. We might have a blockquote or list item
|
||||
// in the parent hierarchy.
|
||||
|
||||
Element* rootElement = HTMLEditorRef().GetRoot();
|
||||
if (NS_WARN_IF(!rootElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Test selection start container hierarchy.
|
||||
EditorRawDOMPoint selectionStartPoint(
|
||||
EditorBase::GetStartPoint(&SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
for (nsINode* node = selectionStartPoint.GetContainer();
|
||||
node && node != rootElement;
|
||||
node = node->GetParentNode()) {
|
||||
if (HTMLEditUtils::IsNodeThatCanOutdent(node)) {
|
||||
*aCanOutdent = true;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Test selection end container hierarchy.
|
||||
EditorRawDOMPoint selectionEndPoint(EditorBase::GetEndPoint(&SelectionRef()));
|
||||
if (NS_WARN_IF(!selectionEndPoint.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
for (nsINode* node = selectionEndPoint.GetContainer();
|
||||
node && node != rootElement;
|
||||
node = node->GetParentNode()) {
|
||||
if (HTMLEditUtils::IsNodeThatCanOutdent(node)) {
|
||||
*aCanOutdent = true;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
HTMLEditRules::GetParagraphState(bool* aMixed,
|
||||
nsAString& outFormat)
|
||||
|
|
|
@ -112,7 +112,6 @@ public:
|
|||
|
||||
nsresult GetListState(bool* aMixed, bool* aOL, bool* aUL, bool* aDL);
|
||||
nsresult GetListItemState(bool* aMixed, bool* aLI, bool* aDT, bool* aDD);
|
||||
nsresult GetIndentState(bool* aCanIndent, bool* aCanOutdent);
|
||||
nsresult GetAlignment(bool* aMixed, nsIHTMLEditor::EAlignment* aAlign);
|
||||
nsresult GetParagraphState(bool* aMixed, nsAString& outFormat);
|
||||
|
||||
|
|
|
@ -1992,19 +1992,6 @@ HTMLEditor::GetAlignment(bool* aMixed,
|
|||
return htmlRules->GetAlignment(aMixed, aAlign);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLEditor::GetIndentState(bool* aCanIndent,
|
||||
bool* aCanOutdent)
|
||||
{
|
||||
if (!mRules) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
NS_ENSURE_TRUE(aCanIndent && aCanOutdent, NS_ERROR_NULL_POINTER);
|
||||
|
||||
RefPtr<HTMLEditRules> htmlRules(mRules->AsHTMLEditRules());
|
||||
return htmlRules->GetIndentState(aCanIndent, aCanOutdent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLEditor::MakeOrChangeList(const nsAString& aListType,
|
||||
bool entireList,
|
||||
|
@ -2854,25 +2841,6 @@ HTMLEditor::SetHTMLBackgroundColorWithTransaction(const nsAString& aColor)
|
|||
RemoveAttributeWithTransaction(*element, *bgColorAtom);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLEditor::SetBodyAttribute(const nsAString& aAttribute,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
// TODO: Check selection for Cell, Row, Column or table and do color on appropriate level
|
||||
|
||||
MOZ_ASSERT(IsInitialized(), "The HTMLEditor hasn't been initialized yet");
|
||||
|
||||
// Set the background color attribute on the body tag
|
||||
RefPtr<Element> rootElement = GetRoot();
|
||||
if (NS_WARN_IF(!rootElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Use the editor method that goes through the transaction system
|
||||
RefPtr<nsAtom> attributeAtom = NS_Atomize(aAttribute);
|
||||
return SetAttributeWithTransaction(*rootElement, *attributeAtom, aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLEditor::GetLinkedObjects(nsIArray** aNodeList)
|
||||
{
|
||||
|
@ -4621,14 +4589,6 @@ HTMLEditor::EndUpdateViewBatch()
|
|||
return CheckSelectionStateForAnonymousButtons(selection);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLEditor::GetSelectionContainer(Element** aReturn)
|
||||
{
|
||||
RefPtr<Element> container = GetSelectionContainer();
|
||||
container.forget(aReturn);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Element*
|
||||
HTMLEditor::GetSelectionContainer()
|
||||
{
|
||||
|
|
|
@ -122,6 +122,10 @@ public:
|
|||
virtual void PreDestroy(bool aDestroyingFrames) override;
|
||||
|
||||
bool GetReturnInParagraphCreatesNewParagraph();
|
||||
|
||||
/**
|
||||
* Returns the deepest container of the selection
|
||||
*/
|
||||
Element* GetSelectionContainer();
|
||||
|
||||
// TextEditor overrides
|
||||
|
|
|
@ -176,23 +176,6 @@ HTMLEditor::InsertHTML(const nsAString& aInString)
|
|||
nullptr, nullptr, 0, true, true, false);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLEditor::InsertHTMLWithContext(const nsAString& aInputString,
|
||||
const nsAString& aContextStr,
|
||||
const nsAString& aInfoStr,
|
||||
const nsAString& aFlavor,
|
||||
nsIDocument* aSourceDoc,
|
||||
nsINode* aDestNode,
|
||||
int32_t aDestOffset,
|
||||
bool aDeleteSelection)
|
||||
{
|
||||
return DoInsertHTMLWithContext(aInputString, aContextStr, aInfoStr,
|
||||
aFlavor, aSourceDoc, aDestNode, aDestOffset,
|
||||
aDeleteSelection,
|
||||
/* trusted input */ true,
|
||||
/* clear style */ false);
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
||||
const nsAString& aContextStr,
|
||||
|
|
|
@ -152,30 +152,6 @@ interface nsIHTMLEditor : nsISupports
|
|||
*/
|
||||
void rebuildDocumentFromSource(in AString aSourceString);
|
||||
|
||||
/**
|
||||
* Insert some HTML source, interpreting
|
||||
* the string argument according to the given context.
|
||||
*
|
||||
* @param aInputString the string to be inserted
|
||||
* @param aContextStr Context of insertion
|
||||
* @param aInfoStr Related info to aInputString
|
||||
* @param aFlavor Transferable flavor, can be ""
|
||||
* @param aSourceDoc document where input was dragged from (may be null)
|
||||
* @param aDestinationNode location for insertion (such as when dropped)
|
||||
* @param aDestinationOffset used with aDestNode to determine insert location
|
||||
* @param aDeleteSelection used with aDestNode during drag&drop
|
||||
* @param aCollapseSelection used with aDestNode during drag&drop
|
||||
*/
|
||||
void insertHTMLWithContext(in AString aInputString,
|
||||
in AString aContextStr,
|
||||
in AString aInfoStr,
|
||||
in AString aFlavor,
|
||||
in Document aSourceDoc,
|
||||
in Node aDestinationNode,
|
||||
in long aDestinationOffset,
|
||||
in boolean aDeleteSelection);
|
||||
|
||||
|
||||
/**
|
||||
* Insert an element, which may have child nodes, at the selection
|
||||
* Used primarily to insert a new element for various insert element dialogs,
|
||||
|
@ -300,12 +276,6 @@ interface nsIHTMLEditor : nsISupports
|
|||
*/
|
||||
void getAlignment(out boolean aMixed, out short aAlign);
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*/
|
||||
void getIndentState(out boolean aCanIndent, out boolean aCanOutdent);
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
|
@ -415,18 +385,6 @@ interface nsIHTMLEditor : nsISupports
|
|||
*/
|
||||
void setBackgroundColor(in AString aColor);
|
||||
|
||||
|
||||
/**
|
||||
* Set an attribute on the document's <body> element
|
||||
* such as text, link, background colors
|
||||
*
|
||||
* 8/31/00 THIS ISN'T BEING USED? SHOULD WE DROP IT?
|
||||
*
|
||||
* @param aAttr The attribute to be set
|
||||
* @param aValue The value of the attribute
|
||||
*/
|
||||
void setBodyAttribute(in AString aAttr, in AString aValue);
|
||||
|
||||
/**
|
||||
* Find all the nodes in the document which contain references
|
||||
* to outside URIs (e.g. a href, img src, script src, etc.)
|
||||
|
@ -444,12 +402,6 @@ interface nsIHTMLEditor : nsISupports
|
|||
*/
|
||||
attribute boolean isCSSEnabled;
|
||||
|
||||
/**
|
||||
* returns the deepest container of the selection
|
||||
* @return a DOM Element
|
||||
*/
|
||||
Element getSelectionContainer();
|
||||
|
||||
/**
|
||||
* Checks if the anonymous nodes created by the HTML editor have to be
|
||||
* refreshed or hidden depending on a possible new state of the selection
|
||||
|
|
Загрузка…
Ссылка в новой задаче