mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
remove CSSisms from nsEditor; b=121092, r=brade, sr=kin
This commit is contained in:
parent
2259d802da
commit
fd4d0fd0da
@ -864,8 +864,10 @@ nsHighlightColorStateCommand::IsCommandEnabled(const nsAReadableString & aComman
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
editorShell->GetEditor(getter_AddRefs(editor));
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
|
||||
if (!htmlEditor) return NS_ERROR_FAILURE;
|
||||
PRBool useCSS;
|
||||
editor->IsCSSEnabled(&useCSS);
|
||||
htmlEditor->IsCSSEnabled(&useCSS);
|
||||
|
||||
*outCmdEnabled = useCSS;
|
||||
}
|
||||
|
@ -79,14 +79,7 @@ interface nsIEditor : nsISupports
|
||||
*/
|
||||
[noscript] void Init(in nsIDOMDocument doc, in nsIPresShellPtr shell, in nsIContentPtr aRoot, in nsISelectionController aSelCon, in unsigned long aFlags);
|
||||
|
||||
/** IsCSSEnabled answers a boolean which is true is the HTMLEditor has been
|
||||
* instantiated with CSS knowledge and if the CSS pref is currently checked
|
||||
*
|
||||
* @param aIsSet [OUT] true if CSS handled and enabled
|
||||
*/
|
||||
void IsCSSEnabled(out PRBool aIsSet);
|
||||
|
||||
void SetCSSEquivalentToHTMLStyle(in nsIDOMElement element, in DOMString sourceAttrName, in DOMString sourceAttrValue);
|
||||
void SetAttributeOrEquivalent(in nsIDOMElement element, in DOMString sourceAttrName, in DOMString sourceAttrValue);
|
||||
/**
|
||||
* PostCreate should be called after Init, and is the time that the editor tells
|
||||
* its documentStateObservers that the document has been created.
|
||||
|
@ -444,5 +444,12 @@ interface nsIHTMLEditor : nsISupports
|
||||
|
||||
void SetCSSEnabled(in boolean aIsCSSPrefChecked);
|
||||
|
||||
/** IsCSSEnabled answers a boolean which is true is the HTMLEditor has been
|
||||
* instantiated with CSS knowledge and if the CSS pref is currently checked
|
||||
*
|
||||
* @param aIsCSSEnabled [OUT] true if CSS handled and enabled
|
||||
*/
|
||||
void IsCSSEnabled(out boolean aIsCSSEnabled);
|
||||
|
||||
};
|
||||
|
||||
|
@ -71,8 +71,6 @@
|
||||
#include "nsIPlaintextEditor.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
|
||||
#include "nsIFrame.h" // Needed by IME code
|
||||
|
||||
#include "nsICSSStyleSheet.h"
|
||||
@ -88,7 +86,6 @@
|
||||
#include "EditAggregateTxn.h"
|
||||
#include "PlaceholderTxn.h"
|
||||
#include "ChangeAttributeTxn.h"
|
||||
#include "ChangeCSSInlineStyleTxn.h"
|
||||
#include "CreateElementTxn.h"
|
||||
#include "InsertElementTxn.h"
|
||||
#include "DeleteElementTxn.h"
|
||||
@ -99,7 +96,6 @@
|
||||
#include "JoinElementTxn.h"
|
||||
#include "nsStyleSheetTxns.h"
|
||||
#include "IMETextTxn.h"
|
||||
#include "nsIEditProperty.h"
|
||||
|
||||
// included for nsEditor::CreateHTMLContent
|
||||
#include "nsIElementFactory.h"
|
||||
@ -2117,8 +2113,6 @@ nsEditor::CloneAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode)
|
||||
|
||||
if (!aDestNode || !aSourceNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
PRBool useCSS;
|
||||
IsCSSEnabled(&useCSS);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> destElement = do_QueryInterface(aDestNode);
|
||||
nsCOMPtr<nsIDOMElement> sourceElement = do_QueryInterface(aSourceNode);
|
||||
@ -2140,8 +2134,8 @@ nsEditor::CloneAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode)
|
||||
// is already in the document
|
||||
PRBool destInBody = PR_TRUE;
|
||||
nsCOMPtr<nsIDOMElement> bodyElement;
|
||||
nsresult res = GetRootElement(getter_AddRefs(bodyElement));
|
||||
if (NS_FAILED(res)) return res;
|
||||
result = GetRootElement(getter_AddRefs(bodyElement));
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (!bodyElement) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> bodyNode = do_QueryInterface(bodyElement);
|
||||
@ -2202,16 +2196,9 @@ nsEditor::CloneAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode)
|
||||
if (NS_SUCCEEDED(sourceAttribute->GetValue(sourceAttrValue)))
|
||||
{
|
||||
if (destInBody) {
|
||||
if (useCSS) {
|
||||
res = SetCSSEquivalentToHTMLStyle(destElement, sourceAttrName, sourceAttrValue);
|
||||
}
|
||||
else {
|
||||
SetAttribute(destElement, sourceAttrName, sourceAttrValue);
|
||||
}
|
||||
result = SetAttributeOrEquivalent(destElement, sourceAttrName, sourceAttrValue);
|
||||
}
|
||||
else {
|
||||
// only elements in BODY can carry a STYLE attribute
|
||||
// so there is no need to test the value of useCSS here
|
||||
destElement->SetAttribute(sourceAttrName, sourceAttrValue);
|
||||
}
|
||||
} else {
|
||||
@ -5060,18 +5047,10 @@ nsEditor::CreateHTMLContent(const nsAReadableString& aTag, nsIContent** aContent
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsEditor::IsCSSEnabled(PRBool *aIsSet)
|
||||
{
|
||||
*aIsSet = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsEditor::SetCSSEquivalentToHTMLStyle(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue)
|
||||
nsEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue)
|
||||
{
|
||||
return SetAttribute(aElement, aAttribute, aValue);
|
||||
}
|
||||
|
@ -4069,7 +4069,7 @@ nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString *
|
||||
nsCOMPtr<nsIDOMElement> divElem = do_QueryInterface(firstChild);
|
||||
if (useCSS) {
|
||||
res = mHTMLEditor->RemoveAttribute(divElem, attr);
|
||||
mHTMLEditor->SetCSSEquivalentToHTMLStyle(divElem, attr, *alignType);
|
||||
mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType);
|
||||
}
|
||||
else {
|
||||
res = mHTMLEditor->SetAttribute(divElem, attr, *alignType);
|
||||
@ -4086,7 +4086,7 @@ nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString *
|
||||
nsCOMPtr<nsIDOMElement> divElem = do_QueryInterface(divNode);
|
||||
if (useCSS) {
|
||||
res = mHTMLEditor->RemoveAttribute(divElem, attr);
|
||||
mHTMLEditor->SetCSSEquivalentToHTMLStyle(divElem, attr, *alignType);
|
||||
mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType);
|
||||
}
|
||||
else {
|
||||
res = mHTMLEditor->SetAttribute(divElem, attr, *alignType);
|
||||
@ -7395,7 +7395,7 @@ nsHTMLEditRules::RemoveAlignment(nsIDOMNode * aNode, nsAReadableString & aAlignT
|
||||
{
|
||||
if (nsHTMLEditUtils::IsTable(child) || nsHTMLEditUtils::IsHR(child))
|
||||
{
|
||||
mHTMLEditor->SetCSSEquivalentToHTMLStyle(curElem, NS_LITERAL_STRING("align"), aAlignType);
|
||||
mHTMLEditor->SetAttributeOrEquivalent(curElem, NS_LITERAL_STRING("align"), aAlignType);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7533,7 +7533,7 @@ nsHTMLEditRules::AlignBlock(nsIDOMElement * aElement, const nsAReadableString *
|
||||
// and text-align for other block-level elements
|
||||
res = mHTMLEditor->RemoveAttribute(aElement, attr);
|
||||
if (NS_FAILED(res)) return res;
|
||||
mHTMLEditor->SetCSSEquivalentToHTMLStyle(aElement, attr, *aAlignType);
|
||||
mHTMLEditor->SetAttributeOrEquivalent(aElement, attr, *aAlignType);
|
||||
}
|
||||
else {
|
||||
// HTML case; this code is supposed to be called ONLY if the element
|
||||
|
@ -4990,9 +4990,9 @@ nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
|
||||
// add to aElement the CSS inline styles corresponding to the HTML attribute
|
||||
// aAttribute with its value aValue
|
||||
nsresult
|
||||
nsHTMLEditor::SetCSSEquivalentToHTMLStyle(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue)
|
||||
nsHTMLEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue)
|
||||
{
|
||||
PRBool useCSS;
|
||||
nsresult res = NS_OK;
|
||||
|
@ -190,6 +190,7 @@ public:
|
||||
NS_IMETHOD GetLinkedObjects(nsISupportsArray** aNodeList);
|
||||
|
||||
NS_IMETHOD SetCSSEnabled(PRBool aIsCSSPrefChecked);
|
||||
NS_IMETHOD IsCSSEnabled(PRBool * aIsCSSEnabled);
|
||||
|
||||
/* ------------ nsIEditorIMESupport overrides -------------- */
|
||||
|
||||
@ -379,10 +380,9 @@ public:
|
||||
/** make the given selection span the entire document */
|
||||
NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
|
||||
|
||||
NS_IMETHOD IsCSSEnabled(PRBool * aIsSet);
|
||||
NS_IMETHOD SetCSSEquivalentToHTMLStyle(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue);
|
||||
NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue);
|
||||
|
||||
/** join together any afjacent editable text nodes in the range */
|
||||
NS_IMETHOD CollapseAdjacentTextNodes(nsIDOMRange *aInRange);
|
||||
|
@ -1810,13 +1810,13 @@ nsHTMLEditor::GetFontColorState(PRBool *aMixed, nsAWritableString &aOutColor)
|
||||
// can handle CSS styles (for instance, Composer can, Messenger can't) and if
|
||||
// the CSS preference is checked
|
||||
nsresult
|
||||
nsHTMLEditor::IsCSSEnabled(PRBool *aIsSet)
|
||||
nsHTMLEditor::IsCSSEnabled(PRBool *aIsCSSEnabled)
|
||||
{
|
||||
*aIsSet = PR_FALSE;
|
||||
*aIsCSSEnabled = PR_FALSE;
|
||||
if (mCSSAware) {
|
||||
// TBD later : removal of mCSSAware and use only the presence of mHTMLCSSUtils
|
||||
if (mHTMLCSSUtils) {
|
||||
*aIsSet = mHTMLCSSUtils->IsCSSPrefChecked();
|
||||
*aIsCSSEnabled = mHTMLCSSUtils->IsCSSPrefChecked();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -255,15 +255,6 @@ nsPlaintextEditor::EndEditorInit()
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlaintextEditor::IsCSSEnabled(PRBool *aIsSet)
|
||||
{
|
||||
// STUB
|
||||
*aIsSet = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::SetDocumentCharacterSet(const nsAReadableString & characterSet)
|
||||
{
|
||||
@ -2115,10 +2106,10 @@ void nsPlaintextEditor::HandleEventListenerError()
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsPlaintextEditor::SetCSSEquivalentToHTMLStyle(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue)
|
||||
nsPlaintextEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue)
|
||||
{
|
||||
// STUB
|
||||
nsEditor::SetAttribute(aElement, aAttribute, aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -107,10 +107,9 @@ public:
|
||||
|
||||
/* ------------ Overrides of nsEditor interface methods -------------- */
|
||||
NS_IMETHOD BeginComposition(nsTextEventReply* aReply);
|
||||
NS_IMETHOD IsCSSEnabled(PRBool *aIsSet);
|
||||
NS_IMETHOD SetCSSEquivalentToHTMLStyle(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue);
|
||||
NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue);
|
||||
|
||||
/** prepare the editor for use */
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
|
||||
|
Loading…
Reference in New Issue
Block a user