зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1260651 part.45 Rename nsHTMLCSSUtils to mozilla::CSSEditUtils (and also their file names) r=mccr8
This patch also renames nsHTMLEditor::mHTMLCSSUtils to nsHTMLEditor::mCSSEditUtils. MozReview-Commit-ID: 1ZZBTqkVOm9 --HG-- rename : editor/libeditor/nsHTMLCSSUtils.cpp => editor/libeditor/CSSEditUtils.cpp rename : editor/libeditor/nsHTMLCSSUtils.h => editor/libeditor/CSSEditUtils.h
This commit is contained in:
Родитель
0306bbfb8d
Коммит
0f406c126d
|
@ -3,7 +3,7 @@
|
|||
* 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/. */
|
||||
|
||||
#include "nsHTMLCSSUtils.h"
|
||||
#include "CSSEditUtils.h"
|
||||
|
||||
#include "ChangeStyleTransaction.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
|
@ -42,13 +42,16 @@
|
|||
#include "nsSubstringTuple.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
||||
static
|
||||
void ProcessBValue(const nsAString * aInputString, nsAString & aOutputString,
|
||||
const char * aDefaultValueString,
|
||||
const char * aPrependString, const char* aAppendString)
|
||||
void ProcessBValue(const nsAString* aInputString,
|
||||
nsAString& aOutputString,
|
||||
const char* aDefaultValueString,
|
||||
const char* aPrependString,
|
||||
const char* aAppendString)
|
||||
{
|
||||
if (aInputString && aInputString->EqualsLiteral("-moz-editor-invert-value")) {
|
||||
aOutputString.AssignLiteral("normal");
|
||||
|
@ -59,17 +62,21 @@ void ProcessBValue(const nsAString * aInputString, nsAString & aOutputString,
|
|||
}
|
||||
|
||||
static
|
||||
void ProcessDefaultValue(const nsAString * aInputString, nsAString & aOutputString,
|
||||
const char * aDefaultValueString,
|
||||
const char * aPrependString, const char* aAppendString)
|
||||
void ProcessDefaultValue(const nsAString* aInputString,
|
||||
nsAString& aOutputString,
|
||||
const char* aDefaultValueString,
|
||||
const char* aPrependString,
|
||||
const char* aAppendString)
|
||||
{
|
||||
CopyASCIItoUTF16(aDefaultValueString, aOutputString);
|
||||
}
|
||||
|
||||
static
|
||||
void ProcessSameValue(const nsAString * aInputString, nsAString & aOutputString,
|
||||
const char * aDefaultValueString,
|
||||
const char * aPrependString, const char* aAppendString)
|
||||
void ProcessSameValue(const nsAString* aInputString,
|
||||
nsAString & aOutputString,
|
||||
const char* aDefaultValueString,
|
||||
const char* aPrependString,
|
||||
const char* aAppendString)
|
||||
{
|
||||
if (aInputString) {
|
||||
aOutputString.Assign(*aInputString);
|
||||
|
@ -79,9 +86,11 @@ void ProcessSameValue(const nsAString * aInputString, nsAString & aOutputString,
|
|||
}
|
||||
|
||||
static
|
||||
void ProcessExtendedValue(const nsAString * aInputString, nsAString & aOutputString,
|
||||
const char * aDefaultValueString,
|
||||
const char * aPrependString, const char* aAppendString)
|
||||
void ProcessExtendedValue(const nsAString* aInputString,
|
||||
nsAString& aOutputString,
|
||||
const char* aDefaultValueString,
|
||||
const char* aPrependString,
|
||||
const char* aAppendString)
|
||||
{
|
||||
aOutputString.Truncate();
|
||||
if (aInputString) {
|
||||
|
@ -96,9 +105,11 @@ void ProcessExtendedValue(const nsAString * aInputString, nsAString & aOutputStr
|
|||
}
|
||||
|
||||
static
|
||||
void ProcessLengthValue(const nsAString * aInputString, nsAString & aOutputString,
|
||||
const char * aDefaultValueString,
|
||||
const char * aPrependString, const char* aAppendString)
|
||||
void ProcessLengthValue(const nsAString* aInputString,
|
||||
nsAString& aOutputString,
|
||||
const char* aDefaultValueString,
|
||||
const char* aPrependString,
|
||||
const char* aAppendString)
|
||||
{
|
||||
aOutputString.Truncate();
|
||||
if (aInputString) {
|
||||
|
@ -110,9 +121,11 @@ void ProcessLengthValue(const nsAString * aInputString, nsAString & aOutputStrin
|
|||
}
|
||||
|
||||
static
|
||||
void ProcessListStyleTypeValue(const nsAString * aInputString, nsAString & aOutputString,
|
||||
const char * aDefaultValueString,
|
||||
const char * aPrependString, const char* aAppendString)
|
||||
void ProcessListStyleTypeValue(const nsAString* aInputString,
|
||||
nsAString& aOutputString,
|
||||
const char* aDefaultValueString,
|
||||
const char* aPrependString,
|
||||
const char* aAppendString)
|
||||
{
|
||||
aOutputString.Truncate();
|
||||
if (aInputString) {
|
||||
|
@ -140,9 +153,11 @@ void ProcessListStyleTypeValue(const nsAString * aInputString, nsAString & aOutp
|
|||
}
|
||||
|
||||
static
|
||||
void ProcessMarginLeftValue(const nsAString * aInputString, nsAString & aOutputString,
|
||||
const char * aDefaultValueString,
|
||||
const char * aPrependString, const char* aAppendString)
|
||||
void ProcessMarginLeftValue(const nsAString* aInputString,
|
||||
nsAString& aOutputString,
|
||||
const char* aDefaultValueString,
|
||||
const char* aPrependString,
|
||||
const char* aAppendString)
|
||||
{
|
||||
aOutputString.Truncate();
|
||||
if (aInputString) {
|
||||
|
@ -161,9 +176,11 @@ void ProcessMarginLeftValue(const nsAString * aInputString, nsAString & aOutputS
|
|||
}
|
||||
|
||||
static
|
||||
void ProcessMarginRightValue(const nsAString * aInputString, nsAString & aOutputString,
|
||||
const char * aDefaultValueString,
|
||||
const char * aPrependString, const char* aAppendString)
|
||||
void ProcessMarginRightValue(const nsAString* aInputString,
|
||||
nsAString& aOutputString,
|
||||
const char* aDefaultValueString,
|
||||
const char* aPrependString,
|
||||
const char* aAppendString)
|
||||
{
|
||||
aOutputString.Truncate();
|
||||
if (aInputString) {
|
||||
|
@ -181,125 +198,126 @@ void ProcessMarginRightValue(const nsAString * aInputString, nsAString & aOutput
|
|||
}
|
||||
}
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable boldEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_font_weight, ProcessBValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable boldEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_font_weight, ProcessBValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable italicEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_font_style, ProcessDefaultValue, "italic", nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable italicEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_font_style, ProcessDefaultValue, "italic", nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable underlineEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_text_decoration, ProcessDefaultValue, "underline", nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable underlineEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_text_decoration, ProcessDefaultValue, "underline", nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable strikeEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_text_decoration, ProcessDefaultValue, "line-through", nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable strikeEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_text_decoration, ProcessDefaultValue, "line-through", nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable ttEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_font_family, ProcessDefaultValue, "monospace", nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable ttEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_font_family, ProcessDefaultValue, "monospace", nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable fontColorEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_color, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable fontColorEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_color, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable fontFaceEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_font_family, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable fontFaceEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_font_family, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable bgcolorEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_background_color, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable bgcolorEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_background_color, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable backgroundImageEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_background_image, ProcessExtendedValue, nullptr, "url(", ")", true, true },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable backgroundImageEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_background_image, ProcessExtendedValue, nullptr, "url(", ")", true, true },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable textColorEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_color, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable textColorEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_color, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable borderEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_border, ProcessExtendedValue, nullptr, nullptr, "px solid", true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable borderEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_border, ProcessExtendedValue, nullptr, nullptr, "px solid", true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable textAlignEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_text_align, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable textAlignEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_text_align, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable captionAlignEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_caption_side, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable captionAlignEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_caption_side, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable verticalAlignEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_vertical_align, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable verticalAlignEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_vertical_align, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable nowrapEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_whitespace, ProcessDefaultValue, "nowrap", nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable nowrapEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_whitespace, ProcessDefaultValue, "nowrap", nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable widthEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_width, ProcessLengthValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable widthEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_width, ProcessLengthValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable heightEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_height, ProcessLengthValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable heightEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_height, ProcessLengthValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable listStyleTypeEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_list_style_type, ProcessListStyleTypeValue, nullptr, nullptr, nullptr, true, true },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable listStyleTypeEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_list_style_type, ProcessListStyleTypeValue, nullptr, nullptr, nullptr, true, true },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable tableAlignEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_text_align, ProcessDefaultValue, "left", nullptr, nullptr, false, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_margin_left, ProcessMarginLeftValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_margin_right, ProcessMarginRightValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable tableAlignEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_text_align, ProcessDefaultValue, "left", nullptr, nullptr, false, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_margin_left, ProcessMarginLeftValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_margin_right, ProcessMarginRightValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable hrAlignEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_margin_left, ProcessMarginLeftValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_margin_right, ProcessMarginRightValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
const CSSEditUtils::CSSEquivTable hrAlignEquivTable[] = {
|
||||
{ CSSEditUtils::eCSSEditableProperty_margin_left, ProcessMarginLeftValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_margin_right, ProcessMarginRightValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ CSSEditUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
nsHTMLCSSUtils::nsHTMLCSSUtils(nsHTMLEditor* aEditor)
|
||||
: mHTMLEditor(aEditor)
|
||||
CSSEditUtils::CSSEditUtils(nsHTMLEditor* aHTMLEditor)
|
||||
: mHTMLEditor(aHTMLEditor)
|
||||
, mIsCSSPrefChecked(true)
|
||||
{
|
||||
// let's retrieve the value of the "CSS editing" pref
|
||||
mIsCSSPrefChecked = Preferences::GetBool("editor.use_css", mIsCSSPrefChecked);
|
||||
}
|
||||
|
||||
nsHTMLCSSUtils::~nsHTMLCSSUtils()
|
||||
CSSEditUtils::~CSSEditUtils()
|
||||
{
|
||||
}
|
||||
|
||||
// Answers true if we have some CSS equivalence for the HTML style defined
|
||||
// by aProperty and/or aAttribute for the node aNode
|
||||
bool
|
||||
nsHTMLCSSUtils::IsCSSEditableProperty(nsINode* aNode, nsIAtom* aProperty,
|
||||
CSSEditUtils::IsCSSEditableProperty(nsINode* aNode,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
|
@ -430,8 +448,10 @@ nsHTMLCSSUtils::IsCSSEditableProperty(nsINode* aNode, nsIAtom* aProperty,
|
|||
// The lowest level above the transaction; adds the CSS declaration
|
||||
// "aProperty : aValue" to the inline styles carried by aElement
|
||||
nsresult
|
||||
nsHTMLCSSUtils::SetCSSProperty(Element& aElement, nsIAtom& aProperty,
|
||||
const nsAString& aValue, bool aSuppressTxn)
|
||||
CSSEditUtils::SetCSSProperty(Element& aElement,
|
||||
nsIAtom& aProperty,
|
||||
const nsAString& aValue,
|
||||
bool aSuppressTxn)
|
||||
{
|
||||
RefPtr<ChangeStyleTransaction> transaction =
|
||||
CreateCSSPropertyTxn(aElement, aProperty, aValue,
|
||||
|
@ -443,7 +463,8 @@ nsHTMLCSSUtils::SetCSSProperty(Element& aElement, nsIAtom& aProperty,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::SetCSSPropertyPixels(Element& aElement, nsIAtom& aProperty,
|
||||
CSSEditUtils::SetCSSPropertyPixels(Element& aElement,
|
||||
nsIAtom& aProperty,
|
||||
int32_t aIntValue)
|
||||
{
|
||||
nsAutoString s;
|
||||
|
@ -456,8 +477,10 @@ nsHTMLCSSUtils::SetCSSPropertyPixels(Element& aElement, nsIAtom& aProperty,
|
|||
// list of values specified for the CSS property aProperty, or totally remove
|
||||
// the declaration if this property accepts only one value
|
||||
nsresult
|
||||
nsHTMLCSSUtils::RemoveCSSProperty(Element& aElement, nsIAtom& aProperty,
|
||||
const nsAString& aValue, bool aSuppressTxn)
|
||||
CSSEditUtils::RemoveCSSProperty(Element& aElement,
|
||||
nsIAtom& aProperty,
|
||||
const nsAString& aValue,
|
||||
bool aSuppressTxn)
|
||||
{
|
||||
RefPtr<ChangeStyleTransaction> transaction =
|
||||
CreateCSSPropertyTxn(aElement, aProperty, aValue,
|
||||
|
@ -469,7 +492,7 @@ nsHTMLCSSUtils::RemoveCSSProperty(Element& aElement, nsIAtom& aProperty,
|
|||
}
|
||||
|
||||
already_AddRefed<ChangeStyleTransaction>
|
||||
nsHTMLCSSUtils::CreateCSSPropertyTxn(
|
||||
CSSEditUtils::CreateCSSPropertyTxn(
|
||||
Element& aElement,
|
||||
nsIAtom& aAttribute,
|
||||
const nsAString& aValue,
|
||||
|
@ -481,28 +504,31 @@ nsHTMLCSSUtils::CreateCSSPropertyTxn(
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetSpecifiedProperty(nsINode& aNode, nsIAtom& aProperty,
|
||||
CSSEditUtils::GetSpecifiedProperty(nsINode& aNode,
|
||||
nsIAtom& aProperty,
|
||||
nsAString& aValue)
|
||||
{
|
||||
return GetCSSInlinePropertyBase(&aNode, &aProperty, aValue, eSpecified);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetComputedProperty(nsINode& aNode, nsIAtom& aProperty,
|
||||
CSSEditUtils::GetComputedProperty(nsINode& aNode,
|
||||
nsIAtom& aProperty,
|
||||
nsAString& aValue)
|
||||
{
|
||||
return GetCSSInlinePropertyBase(&aNode, &aProperty, aValue, eComputed);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
|
||||
CSSEditUtils::GetCSSInlinePropertyBase(nsINode* aNode,
|
||||
nsIAtom* aProperty,
|
||||
nsAString& aValue,
|
||||
StyleType aStyleType)
|
||||
{
|
||||
MOZ_ASSERT(aNode && aProperty);
|
||||
aValue.Truncate();
|
||||
|
||||
nsCOMPtr<dom::Element> element = GetElementContainerOrSelf(aNode);
|
||||
nsCOMPtr<Element> element = GetElementContainerOrSelf(aNode);
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
|
||||
|
||||
if (aStyleType == eComputed) {
|
||||
|
@ -532,7 +558,7 @@ nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
|
|||
}
|
||||
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
nsHTMLCSSUtils::GetComputedStyle(dom::Element* aElement)
|
||||
CSSEditUtils::GetComputedStyle(Element* aElement)
|
||||
{
|
||||
MOZ_ASSERT(aElement);
|
||||
|
||||
|
@ -551,7 +577,9 @@ nsHTMLCSSUtils::GetComputedStyle(dom::Element* aElement)
|
|||
// remove the CSS style "aProperty : aPropertyValue" and possibly remove the whole node
|
||||
// if it is a span and if its only attribute is _moz_dirty
|
||||
nsresult
|
||||
nsHTMLCSSUtils::RemoveCSSInlineStyle(nsIDOMNode *aNode, nsIAtom *aProperty, const nsAString & aPropertyValue)
|
||||
CSSEditUtils::RemoveCSSInlineStyle(nsIDOMNode* aNode,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString& aPropertyValue)
|
||||
{
|
||||
nsCOMPtr<Element> element = do_QueryInterface(aNode);
|
||||
NS_ENSURE_STATE(element);
|
||||
|
@ -571,14 +599,15 @@ nsHTMLCSSUtils::RemoveCSSInlineStyle(nsIDOMNode *aNode, nsIAtom *aProperty, cons
|
|||
// Answers true if the property can be removed by setting a "none" CSS value
|
||||
// on a node
|
||||
bool
|
||||
nsHTMLCSSUtils::IsCSSInvertible(nsIAtom& aProperty, const nsAString* aAttribute)
|
||||
CSSEditUtils::IsCSSInvertible(nsIAtom& aProperty,
|
||||
const nsAString* aAttribute)
|
||||
{
|
||||
return nsGkAtoms::b == &aProperty;
|
||||
}
|
||||
|
||||
// Get the default browser background color if we need it for GetCSSBackgroundColorState
|
||||
void
|
||||
nsHTMLCSSUtils::GetDefaultBackgroundColor(nsAString & aColor)
|
||||
CSSEditUtils::GetDefaultBackgroundColor(nsAString& aColor)
|
||||
{
|
||||
if (Preferences::GetBool("editor.use_custom_colors", false)) {
|
||||
nsresult rv = Preferences::GetString("editor.background_color", &aColor);
|
||||
|
@ -605,7 +634,7 @@ nsHTMLCSSUtils::GetDefaultBackgroundColor(nsAString & aColor)
|
|||
|
||||
// Get the default length unit used for CSS Indent/Outdent
|
||||
void
|
||||
nsHTMLCSSUtils::GetDefaultLengthUnit(nsAString & aLengthUnit)
|
||||
CSSEditUtils::GetDefaultLengthUnit(nsAString& aLengthUnit)
|
||||
{
|
||||
nsresult rv =
|
||||
Preferences::GetString("editor.css.default_length_unit", &aLengthUnit);
|
||||
|
@ -619,7 +648,8 @@ nsHTMLCSSUtils::GetDefaultLengthUnit(nsAString & aLengthUnit)
|
|||
// implemented... We need then a way to determine the number part and the unit
|
||||
// from aString, aString being the result of a GetPropertyValue query...
|
||||
void
|
||||
nsHTMLCSSUtils::ParseLength(const nsAString& aString, float* aValue,
|
||||
CSSEditUtils::ParseLength(const nsAString& aString,
|
||||
float* aValue,
|
||||
nsIAtom** aUnit)
|
||||
{
|
||||
if (aString.IsEmpty()) {
|
||||
|
@ -667,7 +697,8 @@ nsHTMLCSSUtils::ParseLength(const nsAString& aString, float* aValue,
|
|||
}
|
||||
|
||||
void
|
||||
nsHTMLCSSUtils::GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom)
|
||||
CSSEditUtils::GetCSSPropertyAtom(nsCSSEditableProperty aProperty,
|
||||
nsIAtom** aAtom)
|
||||
{
|
||||
*aAtom = nullptr;
|
||||
switch (aProperty) {
|
||||
|
@ -737,10 +768,10 @@ nsHTMLCSSUtils::GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** a
|
|||
// Populate aProperty and aValueArray with the CSS declarations equivalent to the
|
||||
// value aValue according to the equivalence table aEquivTable
|
||||
void
|
||||
nsHTMLCSSUtils::BuildCSSDeclarations(nsTArray<nsIAtom*> & aPropertyArray,
|
||||
nsTArray<nsString> & aValueArray,
|
||||
const CSSEquivTable * aEquivTable,
|
||||
const nsAString * aValue,
|
||||
CSSEditUtils::BuildCSSDeclarations(nsTArray<nsIAtom*>& aPropertyArray,
|
||||
nsTArray<nsString>& aValueArray,
|
||||
const CSSEquivTable* aEquivTable,
|
||||
const nsAString* aValue,
|
||||
bool aGetOrRemoveRequest)
|
||||
{
|
||||
// clear arrays
|
||||
|
@ -780,7 +811,8 @@ nsHTMLCSSUtils::BuildCSSDeclarations(nsTArray<nsIAtom*> & aPropertyArray,
|
|||
// Populate cssPropertyArray and cssValueArray with the declarations equivalent
|
||||
// to aHTMLProperty/aAttribute/aValue for the node aNode
|
||||
void
|
||||
nsHTMLCSSUtils::GenerateCSSDeclarationsFromHTMLStyle(dom::Element* aElement,
|
||||
CSSEditUtils::GenerateCSSDeclarationsFromHTMLStyle(
|
||||
Element* aElement,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
|
@ -789,7 +821,7 @@ nsHTMLCSSUtils::GenerateCSSDeclarationsFromHTMLStyle(dom::Element* aElement,
|
|||
bool aGetOrRemoveRequest)
|
||||
{
|
||||
MOZ_ASSERT(aElement);
|
||||
const nsHTMLCSSUtils::CSSEquivTable* equivTable = nullptr;
|
||||
const CSSEditUtils::CSSEquivTable* equivTable = nullptr;
|
||||
|
||||
if (nsGkAtoms::b == aHTMLProperty) {
|
||||
equivTable = boldEquivTable;
|
||||
|
@ -852,9 +884,9 @@ nsHTMLCSSUtils::GenerateCSSDeclarationsFromHTMLStyle(dom::Element* aElement,
|
|||
|
||||
// Add to aNode the CSS inline style equivalent to HTMLProperty/aAttribute/
|
||||
// aValue for the node, and return in aCount the number of CSS properties set
|
||||
// by the call. The dom::Element version returns aCount instead.
|
||||
// by the call. The Element version returns aCount instead.
|
||||
int32_t
|
||||
nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(dom::Element* aElement,
|
||||
CSSEditUtils::SetCSSEquivalentToHTMLStyle(Element* aElement,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
|
@ -877,14 +909,14 @@ nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(dom::Element* aElement,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
||||
nsIAtom *aHTMLProperty,
|
||||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
int32_t * aCount,
|
||||
CSSEditUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode* aNode,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
int32_t* aCount,
|
||||
bool aSuppressTransaction)
|
||||
{
|
||||
nsCOMPtr<dom::Element> element = do_QueryInterface(aNode);
|
||||
nsCOMPtr<Element> element = do_QueryInterface(aNode);
|
||||
*aCount = 0;
|
||||
if (!element || !IsCSSEditableProperty(element, aHTMLProperty, aAttribute)) {
|
||||
return NS_OK;
|
||||
|
@ -912,13 +944,13 @@ nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|||
|
||||
// Remove from aNode the CSS inline style equivalent to HTMLProperty/aAttribute/aValue for the node
|
||||
nsresult
|
||||
nsHTMLCSSUtils::RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
||||
nsIAtom *aHTMLProperty,
|
||||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
CSSEditUtils::RemoveCSSEquivalentToHTMLStyle(nsIDOMNode* aNode,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
bool aSuppressTransaction)
|
||||
{
|
||||
nsCOMPtr<dom::Element> element = do_QueryInterface(aNode);
|
||||
nsCOMPtr<Element> element = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(element, NS_OK);
|
||||
|
||||
return RemoveCSSEquivalentToHTMLStyle(element, aHTMLProperty, aAttribute,
|
||||
|
@ -926,7 +958,7 @@ nsHTMLCSSUtils::RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::RemoveCSSEquivalentToHTMLStyle(dom::Element* aElement,
|
||||
CSSEditUtils::RemoveCSSEquivalentToHTMLStyle(Element* aElement,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
|
@ -965,14 +997,14 @@ nsHTMLCSSUtils::RemoveCSSEquivalentToHTMLStyle(dom::Element* aElement,
|
|||
// the value of aStyleType controls the styles we retrieve : specified or
|
||||
// computed.
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
nsIAtom *aHTMLProperty,
|
||||
const nsAString *aAttribute,
|
||||
nsAString & aValueString,
|
||||
CSSEditUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
nsAString& aValueString,
|
||||
StyleType aStyleType)
|
||||
{
|
||||
aValueString.Truncate();
|
||||
nsCOMPtr<dom::Element> theElement = GetElementContainerOrSelf(aNode);
|
||||
nsCOMPtr<Element> theElement = GetElementContainerOrSelf(aNode);
|
||||
NS_ENSURE_TRUE(theElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
if (!theElement || !IsCSSEditableProperty(theElement, aHTMLProperty, aAttribute)) {
|
||||
|
@ -1010,7 +1042,7 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
|||
// The nsIContent variant returns aIsSet instead of using an out parameter, and
|
||||
// does not modify aValue.
|
||||
bool
|
||||
nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString& aValue,
|
||||
|
@ -1023,7 +1055,7 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
|||
}
|
||||
|
||||
bool
|
||||
nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
nsAString& aValue,
|
||||
|
@ -1039,9 +1071,10 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode *aNode,
|
||||
nsIAtom *aHTMLProperty,
|
||||
const nsAString *aHTMLAttribute,
|
||||
CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet(
|
||||
nsIDOMNode* aNode,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aHTMLAttribute,
|
||||
bool& aIsSet,
|
||||
nsAString& valueString,
|
||||
StyleType aStyleType)
|
||||
|
@ -1187,13 +1220,13 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode *aNode,
|
|||
}
|
||||
|
||||
void
|
||||
nsHTMLCSSUtils::SetCSSEnabled(bool aIsCSSPrefChecked)
|
||||
CSSEditUtils::SetCSSEnabled(bool aIsCSSPrefChecked)
|
||||
{
|
||||
mIsCSSPrefChecked = aIsCSSPrefChecked;
|
||||
}
|
||||
|
||||
bool
|
||||
nsHTMLCSSUtils::IsCSSPrefChecked()
|
||||
CSSEditUtils::IsCSSPrefChecked()
|
||||
{
|
||||
return mIsCSSPrefChecked ;
|
||||
}
|
||||
|
@ -1202,10 +1235,11 @@ nsHTMLCSSUtils::IsCSSPrefChecked()
|
|||
// specified CSS declarations in the STYLE attribute
|
||||
// The answer is always negative if at least one of them carries an ID or a class
|
||||
bool
|
||||
nsHTMLCSSUtils::ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode)
|
||||
CSSEditUtils::ElementsSameStyle(nsIDOMNode* aFirstNode,
|
||||
nsIDOMNode* aSecondNode)
|
||||
{
|
||||
nsCOMPtr<dom::Element> firstElement = do_QueryInterface(aFirstNode);
|
||||
nsCOMPtr<dom::Element> secondElement = do_QueryInterface(aSecondNode);
|
||||
nsCOMPtr<Element> firstElement = do_QueryInterface(aFirstNode);
|
||||
nsCOMPtr<Element> secondElement = do_QueryInterface(aSecondNode);
|
||||
|
||||
NS_ASSERTION((firstElement && secondElement), "Non element nodes passed to ElementsSameStyle.");
|
||||
NS_ENSURE_TRUE(firstElement, false);
|
||||
|
@ -1215,8 +1249,8 @@ nsHTMLCSSUtils::ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNod
|
|||
}
|
||||
|
||||
bool
|
||||
nsHTMLCSSUtils::ElementsSameStyle(dom::Element* aFirstElement,
|
||||
dom::Element* aSecondElement)
|
||||
CSSEditUtils::ElementsSameStyle(Element* aFirstElement,
|
||||
Element* aSecondElement)
|
||||
{
|
||||
MOZ_ASSERT(aFirstElement);
|
||||
MOZ_ASSERT(aSecondElement);
|
||||
|
@ -1291,7 +1325,7 @@ nsHTMLCSSUtils::ElementsSameStyle(dom::Element* aFirstElement,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetInlineStyles(dom::Element* aElement,
|
||||
CSSEditUtils::GetInlineStyles(Element* aElement,
|
||||
nsIDOMCSSStyleDeclaration** aCssDecl,
|
||||
uint32_t* aLength)
|
||||
{
|
||||
|
@ -1299,7 +1333,7 @@ nsHTMLCSSUtils::GetInlineStyles(dom::Element* aElement,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetInlineStyles(nsIDOMElement* aElement,
|
||||
CSSEditUtils::GetInlineStyles(nsIDOMElement* aElement,
|
||||
nsIDOMCSSStyleDeclaration** aCssDecl,
|
||||
uint32_t* aLength)
|
||||
{
|
||||
|
@ -1307,9 +1341,9 @@ nsHTMLCSSUtils::GetInlineStyles(nsIDOMElement* aElement,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetInlineStyles(nsISupports *aElement,
|
||||
nsIDOMCSSStyleDeclaration **aCssDecl,
|
||||
uint32_t *aLength)
|
||||
CSSEditUtils::GetInlineStyles(nsISupports* aElement,
|
||||
nsIDOMCSSStyleDeclaration** aCssDecl,
|
||||
uint32_t* aLength)
|
||||
{
|
||||
NS_ENSURE_TRUE(aElement && aLength, NS_ERROR_NULL_POINTER);
|
||||
*aLength = 0;
|
||||
|
@ -1325,7 +1359,7 @@ nsHTMLCSSUtils::GetInlineStyles(nsISupports *aElement,
|
|||
}
|
||||
|
||||
already_AddRefed<nsIDOMElement>
|
||||
nsHTMLCSSUtils::GetElementContainerOrSelf(nsIDOMNode* aNode)
|
||||
CSSEditUtils::GetElementContainerOrSelf(nsIDOMNode* aNode)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(node, nullptr);
|
||||
|
@ -1334,8 +1368,8 @@ nsHTMLCSSUtils::GetElementContainerOrSelf(nsIDOMNode* aNode)
|
|||
return element.forget();
|
||||
}
|
||||
|
||||
dom::Element*
|
||||
nsHTMLCSSUtils::GetElementContainerOrSelf(nsINode* aNode)
|
||||
Element*
|
||||
CSSEditUtils::GetElementContainerOrSelf(nsINode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
if (nsIDOMNode::DOCUMENT_NODE == aNode->NodeType()) {
|
||||
|
@ -1353,9 +1387,9 @@ nsHTMLCSSUtils::GetElementContainerOrSelf(nsINode* aNode)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::SetCSSProperty(nsIDOMElement * aElement,
|
||||
const nsAString & aProperty,
|
||||
const nsAString & aValue)
|
||||
CSSEditUtils::SetCSSProperty(nsIDOMElement* aElement,
|
||||
const nsAString& aProperty,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||
uint32_t length;
|
||||
|
@ -1368,11 +1402,13 @@ nsHTMLCSSUtils::SetCSSProperty(nsIDOMElement * aElement,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::SetCSSPropertyPixels(nsIDOMElement * aElement,
|
||||
const nsAString & aProperty,
|
||||
CSSEditUtils::SetCSSPropertyPixels(nsIDOMElement* aElement,
|
||||
const nsAString& aProperty,
|
||||
int32_t aIntValue)
|
||||
{
|
||||
nsAutoString s;
|
||||
s.AppendInt(aIntValue);
|
||||
return SetCSSProperty(aElement, aProperty, s + NS_LITERAL_STRING("px"));
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,473 @@
|
|||
/* -*- 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 CSSEditUtils_h
|
||||
#define CSSEditUtils_h
|
||||
|
||||
#include "ChangeStyleTransaction.h" // for ChangeStyleTransaction::EChangeType
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
#include "nscore.h" // for nsAString, nsresult, nullptr
|
||||
|
||||
class nsComputedDOMStyle;
|
||||
class nsHTMLEditor;
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNode;
|
||||
class nsINode;
|
||||
class nsString;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
class Element;
|
||||
} // namespace dom
|
||||
|
||||
typedef void (*nsProcessValueFunc)(const nsAString* aInputString,
|
||||
nsAString& aOutputString,
|
||||
const char* aDefaultValueString,
|
||||
const char* aPrependString,
|
||||
const char* aAppendString);
|
||||
|
||||
class CSSEditUtils final
|
||||
{
|
||||
public:
|
||||
explicit CSSEditUtils(nsHTMLEditor* aEditor);
|
||||
~CSSEditUtils();
|
||||
|
||||
enum nsCSSEditableProperty
|
||||
{
|
||||
eCSSEditableProperty_NONE=0,
|
||||
eCSSEditableProperty_background_color,
|
||||
eCSSEditableProperty_background_image,
|
||||
eCSSEditableProperty_border,
|
||||
eCSSEditableProperty_caption_side,
|
||||
eCSSEditableProperty_color,
|
||||
eCSSEditableProperty_float,
|
||||
eCSSEditableProperty_font_family,
|
||||
eCSSEditableProperty_font_size,
|
||||
eCSSEditableProperty_font_style,
|
||||
eCSSEditableProperty_font_weight,
|
||||
eCSSEditableProperty_height,
|
||||
eCSSEditableProperty_list_style_type,
|
||||
eCSSEditableProperty_margin_left,
|
||||
eCSSEditableProperty_margin_right,
|
||||
eCSSEditableProperty_text_align,
|
||||
eCSSEditableProperty_text_decoration,
|
||||
eCSSEditableProperty_vertical_align,
|
||||
eCSSEditableProperty_whitespace,
|
||||
eCSSEditableProperty_width
|
||||
};
|
||||
|
||||
enum StyleType { eSpecified, eComputed };
|
||||
|
||||
|
||||
struct CSSEquivTable
|
||||
{
|
||||
nsCSSEditableProperty cssProperty;
|
||||
nsProcessValueFunc processValueFunctor;
|
||||
const char* defaultValue;
|
||||
const char* prependValue;
|
||||
const char* appendValue;
|
||||
bool gettable;
|
||||
bool caseSensitiveValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Answers true if the given combination element_name/attribute_name
|
||||
* has a CSS equivalence in this implementation.
|
||||
*
|
||||
* @param aNode [IN] A DOM node.
|
||||
* @param aProperty [IN] An atom containing a HTML tag name.
|
||||
* @param aAttribute [IN] A string containing the name of a HTML
|
||||
* attribute carried by the element above.
|
||||
* @return A boolean saying if the tag/attribute has a CSS
|
||||
* equiv.
|
||||
*/
|
||||
bool IsCSSEditableProperty(nsINode* aNode, nsIAtom* aProperty,
|
||||
const nsAString* aAttribute);
|
||||
|
||||
/**
|
||||
* Adds/remove a CSS declaration to the STYLE atrribute carried by a given
|
||||
* element.
|
||||
*
|
||||
* @param aElement [IN] A DOM element.
|
||||
* @param aProperty [IN] An atom containing the CSS property to set.
|
||||
* @param aValue [IN] A string containing the value of the CSS
|
||||
* property.
|
||||
* @param aSuppressTransaction [IN] A boolean indicating, when true,
|
||||
* that no transaction should be recorded.
|
||||
*/
|
||||
nsresult SetCSSProperty(dom::Element& aElement, nsIAtom& aProperty,
|
||||
const nsAString& aValue, bool aSuppressTxn = false);
|
||||
nsresult SetCSSPropertyPixels(dom::Element& aElement,
|
||||
nsIAtom& aProperty, int32_t aIntValue);
|
||||
nsresult RemoveCSSProperty(dom::Element& aElement,
|
||||
nsIAtom& aProperty,
|
||||
const nsAString& aPropertyValue,
|
||||
bool aSuppressTxn = false);
|
||||
|
||||
/**
|
||||
* Directly adds/remove a CSS declaration to the STYLE atrribute carried by
|
||||
* a given element without going through the transaction manager.
|
||||
*
|
||||
* @param aElement [IN] A DOM element.
|
||||
* @param aProperty [IN] A string containing the CSS property to
|
||||
* set/remove.
|
||||
* @param aValue [IN] A string containing the new value of the CSS
|
||||
* property.
|
||||
*/
|
||||
nsresult SetCSSProperty(nsIDOMElement* aElement,
|
||||
const nsAString& aProperty,
|
||||
const nsAString& aValue);
|
||||
nsresult SetCSSPropertyPixels(nsIDOMElement* aElement,
|
||||
const nsAString& aProperty,
|
||||
int32_t aIntValue);
|
||||
|
||||
/**
|
||||
* Gets the specified/computed style value of a CSS property for a given
|
||||
* node (or its element ancestor if it is not an element).
|
||||
*
|
||||
* @param aNode [IN] A DOM node.
|
||||
* @param aProperty [IN] An atom containing the CSS property to get.
|
||||
* @param aPropertyValue [OUT] The retrieved value of the property.
|
||||
*/
|
||||
nsresult GetSpecifiedProperty(nsINode& aNode, nsIAtom& aProperty,
|
||||
nsAString& aValue);
|
||||
nsresult GetComputedProperty(nsINode& aNode, nsIAtom& aProperty,
|
||||
nsAString& aValue);
|
||||
|
||||
/**
|
||||
* Removes a CSS property from the specified declarations in STYLE attribute
|
||||
* and removes the node if it is an useless span.
|
||||
*
|
||||
* @param aNode [IN] The specific node we want to remove a style
|
||||
* from.
|
||||
* @param aProperty [IN] The CSS property atom to remove.
|
||||
* @param aPropertyValue [IN] The value of the property we have to remove
|
||||
* if the property accepts more than one value.
|
||||
*/
|
||||
nsresult RemoveCSSInlineStyle(nsIDOMNode* aNode, nsIAtom* aProperty,
|
||||
const nsAString& aPropertyValue);
|
||||
|
||||
/**
|
||||
* Answers true is the property can be removed by setting a "none" CSS value
|
||||
* on a node.
|
||||
*
|
||||
* @param aProperty [IN] An atom containing a CSS property.
|
||||
* @param aAttribute [IN] Pointer to an attribute name or null if this
|
||||
* information is irrelevant.
|
||||
* @return A boolean saying if the property can be remove by
|
||||
* setting a "none" value.
|
||||
*/
|
||||
bool IsCSSInvertible(nsIAtom& aProperty, const nsAString* aAttribute);
|
||||
|
||||
/**
|
||||
* Get the default browser background color if we need it for
|
||||
* GetCSSBackgroundColorState().
|
||||
*
|
||||
* @param aColor [OUT] The default color as it is defined in prefs.
|
||||
*/
|
||||
void GetDefaultBackgroundColor(nsAString& aColor);
|
||||
|
||||
/**
|
||||
* Get the default length unit used for CSS Indent/Outdent.
|
||||
*
|
||||
* @param aLengthUnit [OUT] The default length unit as it is defined in
|
||||
* prefs.
|
||||
*/
|
||||
void GetDefaultLengthUnit(nsAString & aLengthUnit);
|
||||
|
||||
/**
|
||||
* Returns the list of values for the CSS equivalences to
|
||||
* the passed HTML style for the passed node.
|
||||
*
|
||||
* @param aNode [IN] A DOM node.
|
||||
* @param aHTMLProperty [IN] An atom containing an HTML property.
|
||||
* @param aAttribute [IN] A pointer to an attribute name or nullptr if
|
||||
* irrelevant.
|
||||
* @param aValueString [OUT] The list of CSS values.
|
||||
* @param aStyleType [IN] eSpecified or eComputed.
|
||||
*/
|
||||
nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
nsAString& aValueString,
|
||||
StyleType aStyleType);
|
||||
|
||||
/**
|
||||
* Does the node aNode (or his parent if it is not an element node) carries
|
||||
* the CSS equivalent styles to the HTML style for this node ?
|
||||
*
|
||||
* @param aNode [IN] A DOM node.
|
||||
* @param aHTMLProperty [IN] An atom containing an HTML property.
|
||||
* @param aAttribute [IN] A pointer to an attribute name or nullptr if
|
||||
* irrelevant.
|
||||
* @param aIsSet [OUT] A boolean being true if the css properties are
|
||||
* set.
|
||||
* @param aValueString [IN/OUT] The attribute value (in) the list of CSS
|
||||
* values (out).
|
||||
* @param aStyleType [IN] eSpecified or eComputed.
|
||||
*
|
||||
* The nsIContent variant returns aIsSet instead of using an out parameter.
|
||||
*/
|
||||
bool IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aContent,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString& aValue,
|
||||
StyleType aStyleType);
|
||||
|
||||
bool IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aContent,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
nsAString& aValue,
|
||||
StyleType aStyleType);
|
||||
|
||||
nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode* aNode,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
bool& aIsSet,
|
||||
nsAString& aValueString,
|
||||
StyleType aStyleType);
|
||||
|
||||
/**
|
||||
* Adds to the node the CSS inline styles equivalent to the HTML style
|
||||
* and return the number of CSS properties set by the call.
|
||||
*
|
||||
* @param aNode [IN] A DOM node.
|
||||
* @param aHTMLProperty [IN] An atom containing an HTML property.
|
||||
* @param aAttribute [IN] A pointer to an attribute name or nullptr if
|
||||
* irrelevant.
|
||||
* @param aValue [IN] The attribute value.
|
||||
* @param aCount [OUT] The number of CSS properties set by the call.
|
||||
* @param aSuppressTransaction [IN] A boolean indicating, when true,
|
||||
* that no transaction should be recorded.
|
||||
*
|
||||
* aCount is returned by the dom::Element variant instead of being an out
|
||||
* parameter.
|
||||
*/
|
||||
int32_t SetCSSEquivalentToHTMLStyle(dom::Element* aElement,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
bool aSuppressTransaction);
|
||||
nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode* aNode,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
int32_t* aCount,
|
||||
bool aSuppressTransaction);
|
||||
|
||||
/**
|
||||
* Removes from the node the CSS inline styles equivalent to the HTML style.
|
||||
*
|
||||
* @param aNode [IN] A DOM node.
|
||||
* @param aHTMLProperty [IN] An atom containing an HTML property.
|
||||
* @param aAttribute [IN] A pointer to an attribute name or nullptr if
|
||||
* irrelevant.
|
||||
* @param aValue [IN] The attribute value.
|
||||
* @param aSuppressTransaction [IN] A boolean indicating, when true,
|
||||
* that no transaction should be recorded.
|
||||
*/
|
||||
nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode* aNode,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
bool aSuppressTransaction);
|
||||
|
||||
/**
|
||||
* Removes from the node the CSS inline styles equivalent to the HTML style.
|
||||
*
|
||||
* @param aElement [IN] A DOM Element (must not be null).
|
||||
* @param aHTMLProperty [IN] An atom containing an HTML property.
|
||||
* @param aAttribute [IN] A pointer to an attribute name or nullptr if
|
||||
* irrelevant.
|
||||
* @param aValue [IN] The attribute value.
|
||||
* @param aSuppressTransaction [IN] A boolean indicating, when true,
|
||||
* that no transaction should be recorded.
|
||||
*/
|
||||
nsresult RemoveCSSEquivalentToHTMLStyle(dom::Element* aElement,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
bool aSuppressTransaction);
|
||||
|
||||
/**
|
||||
* Parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
|
||||
* we need such a parser because
|
||||
* nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not implemented.
|
||||
*
|
||||
* @param aString [IN] Input string to parse.
|
||||
* @param aValue [OUT] Numeric part.
|
||||
* @param aUnit [OUT] Unit part.
|
||||
*/
|
||||
void ParseLength(const nsAString& aString, float* aValue, nsIAtom** aUnit);
|
||||
|
||||
/**
|
||||
* Sets the mIsCSSPrefChecked private member; used as callback from observer
|
||||
* when the CSS pref state is changed.
|
||||
*
|
||||
* @param aIsCSSPrefChecked [IN] The new boolean state for the pref.
|
||||
*/
|
||||
void SetCSSEnabled(bool aIsCSSPrefChecked);
|
||||
|
||||
/**
|
||||
* Retrieves the mIsCSSPrefChecked private member, true if the CSS pref is
|
||||
* checked, false if it is not.
|
||||
*
|
||||
* @return the boolean value of the CSS pref.
|
||||
*/
|
||||
bool IsCSSPrefChecked();
|
||||
|
||||
/**
|
||||
* ElementsSameStyle compares two elements and checks if they have the same
|
||||
* specified CSS declarations in the STYLE attribute.
|
||||
* The answer is always false if at least one of them carries an ID or a
|
||||
* class.
|
||||
*
|
||||
* @param aFirstNode [IN] A DOM node.
|
||||
* @param aSecondNode [IN] A DOM node.
|
||||
* @return true if the two elements are considered to
|
||||
* have same styles.
|
||||
*/
|
||||
bool ElementsSameStyle(dom::Element* aFirstNode,
|
||||
dom::Element* aSecondNode);
|
||||
bool ElementsSameStyle(nsIDOMNode* aFirstNode, nsIDOMNode* aSecondNode);
|
||||
|
||||
/**
|
||||
* Get the specified inline styles (style attribute) for an element.
|
||||
*
|
||||
* @param aElement [IN] The element node.
|
||||
* @param aCssDecl [OUT] The CSS declaration corresponding to the
|
||||
* style attribute.
|
||||
* @param aLength [OUT] The number of declarations in aCssDecl.
|
||||
*/
|
||||
nsresult GetInlineStyles(dom::Element* aElement,
|
||||
nsIDOMCSSStyleDeclaration** aCssDecl,
|
||||
uint32_t* aLength);
|
||||
nsresult GetInlineStyles(nsIDOMElement* aElement,
|
||||
nsIDOMCSSStyleDeclaration** aCssDecl,
|
||||
uint32_t* aLength);
|
||||
private:
|
||||
nsresult GetInlineStyles(nsISupports* aElement,
|
||||
nsIDOMCSSStyleDeclaration** aCssDecl,
|
||||
uint32_t* aLength);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Returns aNode itself if it is an element node, or the first ancestors
|
||||
* being an element node if aNode is not one itself.
|
||||
*
|
||||
* @param aNode [IN] A node
|
||||
* @param aElement [OUT] The deepest element node containing aNode
|
||||
* (possibly aNode itself)
|
||||
*/
|
||||
dom::Element* GetElementContainerOrSelf(nsINode* aNode);
|
||||
already_AddRefed<nsIDOMElement> GetElementContainerOrSelf(nsIDOMNode* aNode);
|
||||
|
||||
/**
|
||||
* Gets the computed style for a given element. Can return null.
|
||||
*/
|
||||
already_AddRefed<nsComputedDOMStyle> GetComputedStyle(dom::Element* aElement);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Retrieves the CSS property atom from an enum.
|
||||
*
|
||||
* @param aProperty [IN] The enum value for the property.
|
||||
* @param aAtom [OUT] The corresponding atom.
|
||||
*/
|
||||
void GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom** aAtom);
|
||||
|
||||
/**
|
||||
* Retrieves the CSS declarations equivalent to a HTML style value for
|
||||
* a given equivalence table.
|
||||
*
|
||||
* @param aPropertyArray [OUT] The array of css properties.
|
||||
* @param aValueArray [OUT] The array of values for the CSS properties
|
||||
* above.
|
||||
* @param aEquivTable [IN] The equivalence table.
|
||||
* @param aValue [IN] The HTML style value.
|
||||
* @param aGetOrRemoveRequest [IN] A boolean value being true if the call to
|
||||
* the current method is made for
|
||||
* GetCSSEquivalentToHTMLInlineStyleSet() or
|
||||
* RemoveCSSEquivalentToHTMLInlineStyleSet().
|
||||
*/
|
||||
void BuildCSSDeclarations(nsTArray<nsIAtom*>& aPropertyArray,
|
||||
nsTArray<nsString>& cssValueArray,
|
||||
const CSSEquivTable* aEquivTable,
|
||||
const nsAString* aValue,
|
||||
bool aGetOrRemoveRequest);
|
||||
|
||||
/**
|
||||
* Retrieves the CSS declarations equivalent to the given HTML
|
||||
* property/attribute/value for a given node.
|
||||
*
|
||||
* @param aNode [IN] The DOM node.
|
||||
* @param aHTMLProperty [IN] An atom containing an HTML property.
|
||||
* @param aAttribute [IN] A pointer to an attribute name or nullptr
|
||||
* if irrelevant
|
||||
* @param aValue [IN] The attribute value.
|
||||
* @param aPropertyArray [OUT] The array of CSS properties.
|
||||
* @param aValueArray [OUT] The array of values for the CSS properties
|
||||
* above.
|
||||
* @param aGetOrRemoveRequest [IN] A boolean value being true if the call to
|
||||
* the current method is made for
|
||||
* GetCSSEquivalentToHTMLInlineStyleSet() or
|
||||
* RemoveCSSEquivalentToHTMLInlineStyleSet().
|
||||
*/
|
||||
void GenerateCSSDeclarationsFromHTMLStyle(dom::Element* aNode,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
nsTArray<nsIAtom*>& aPropertyArray,
|
||||
nsTArray<nsString>& aValueArray,
|
||||
bool aGetOrRemoveRequest);
|
||||
|
||||
/**
|
||||
* Creates a Transaction for setting or removing a CSS property. Never
|
||||
* returns null.
|
||||
*
|
||||
* @param aElement [IN] A DOM element.
|
||||
* @param aProperty [IN] A CSS property.
|
||||
* @param aValue [IN] The value to set for this CSS property.
|
||||
* @param aChangeType [IN] eSet to set, eRemove to remove.
|
||||
*/
|
||||
already_AddRefed<ChangeStyleTransaction>
|
||||
CreateCSSPropertyTxn(dom::Element& aElement,
|
||||
nsIAtom& aProperty, const nsAString& aValue,
|
||||
ChangeStyleTransaction::EChangeType aChangeType);
|
||||
|
||||
/**
|
||||
* Back-end for GetSpecifiedProperty and GetComputedProperty.
|
||||
*
|
||||
* @param aNode [IN] A DOM node.
|
||||
* @param aProperty [IN] A CSS property.
|
||||
* @param aValue [OUT] The retrieved value for this property.
|
||||
* @param aStyleType [IN] eSpecified or eComputed.
|
||||
*/
|
||||
nsresult GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
|
||||
nsAString& aValue, StyleType aStyleType);
|
||||
|
||||
private:
|
||||
nsHTMLEditor* mHTMLEditor;
|
||||
bool mIsCSSPrefChecked;
|
||||
};
|
||||
|
||||
#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
|
||||
#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
|
||||
#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f
|
||||
#define NS_EDITOR_INDENT_INCREMENT_PT 29.76f
|
||||
#define NS_EDITOR_INDENT_INCREMENT_PC 2.48f
|
||||
#define NS_EDITOR_INDENT_INCREMENT_EM 3
|
||||
#define NS_EDITOR_INDENT_INCREMENT_EX 6
|
||||
#define NS_EDITOR_INDENT_INCREMENT_PX 40
|
||||
#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // #ifndef CSSEditUtils_h
|
|
@ -22,6 +22,7 @@ UNIFIED_SOURCES += [
|
|||
'ChangeStyleTransaction.cpp',
|
||||
'CompositionTransaction.cpp',
|
||||
'CreateElementTransaction.cpp',
|
||||
'CSSEditUtils.cpp',
|
||||
'DeleteNodeTransaction.cpp',
|
||||
'DeleteRangeTransaction.cpp',
|
||||
'DeleteTextTransaction.cpp',
|
||||
|
@ -39,7 +40,6 @@ UNIFIED_SOURCES += [
|
|||
'nsEditorEventListener.cpp',
|
||||
'nsHTMLAbsPosition.cpp',
|
||||
'nsHTMLAnonymousUtils.cpp',
|
||||
'nsHTMLCSSUtils.cpp',
|
||||
'nsHTMLDataTransfer.cpp',
|
||||
'nsHTMLEditor.cpp',
|
||||
'nsHTMLEditorEventListener.cpp',
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsHTMLCSSUtils.h"
|
||||
#include "nsHTMLEditRules.h"
|
||||
#include "nsHTMLEditor.h"
|
||||
#include "nsHTMLObjectResizer.h"
|
||||
|
@ -88,7 +87,7 @@ nsHTMLEditor::GetAbsolutelyPositionedSelectionContainer(nsIDOMElement **_retval)
|
|||
|
||||
while (!resultNode && node && !node->IsHTMLElement(nsGkAtoms::html)) {
|
||||
nsresult res =
|
||||
mHTMLCSSUtils->GetComputedProperty(*node, *nsGkAtoms::position,
|
||||
mCSSEditUtils->GetComputedProperty(*node, *nsGkAtoms::position,
|
||||
positionStr);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (positionStr.EqualsLiteral("absolute"))
|
||||
|
@ -154,7 +153,7 @@ nsHTMLEditor::SetElementZIndex(nsIDOMElement* aElement, int32_t aZindex)
|
|||
nsAutoString zIndexStr;
|
||||
zIndexStr.AppendInt(aZindex);
|
||||
|
||||
mHTMLCSSUtils->SetCSSProperty(*element, *nsGkAtoms::z_index, zIndexStr);
|
||||
mCSSEditUtils->SetCSSProperty(*element, *nsGkAtoms::z_index, zIndexStr);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -192,7 +191,7 @@ nsHTMLEditor::GetElementZIndex(nsIDOMElement * aElement,
|
|||
nsAutoString zIndexStr;
|
||||
*aZindex = 0;
|
||||
|
||||
nsresult res = mHTMLCSSUtils->GetSpecifiedProperty(*element,
|
||||
nsresult res = mCSSEditUtils->GetSpecifiedProperty(*element,
|
||||
*nsGkAtoms::z_index,
|
||||
zIndexStr);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
@ -206,13 +205,13 @@ nsHTMLEditor::GetElementZIndex(nsIDOMElement * aElement,
|
|||
nsAutoString positionStr;
|
||||
while (node && zIndexStr.EqualsLiteral("auto") &&
|
||||
!node->IsHTMLElement(nsGkAtoms::body)) {
|
||||
res = mHTMLCSSUtils->GetComputedProperty(*node, *nsGkAtoms::position,
|
||||
res = mCSSEditUtils->GetComputedProperty(*node, *nsGkAtoms::position,
|
||||
positionStr);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (positionStr.EqualsLiteral("absolute")) {
|
||||
// ah, we found one, what's its z-index ? If its z-index is auto,
|
||||
// we have to continue climbing the document's tree
|
||||
res = mHTMLCSSUtils->GetComputedProperty(*node, *nsGkAtoms::z_index,
|
||||
res = mCSSEditUtils->GetComputedProperty(*node, *nsGkAtoms::z_index,
|
||||
zIndexStr);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
|
@ -346,9 +345,9 @@ nsHTMLEditor::StartMoving(nsIDOMElement *aHandle)
|
|||
mPositioningShadow->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class, true);
|
||||
|
||||
// position it
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::width,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::width,
|
||||
mPositionedObjectWidth);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::height,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::height,
|
||||
mPositionedObjectHeight);
|
||||
|
||||
mIsMoving = true;
|
||||
|
@ -446,9 +445,9 @@ nsHTMLEditor::SetFinalPosition(int32_t aX, int32_t aY)
|
|||
nsCOMPtr<Element> absolutelyPositionedObject =
|
||||
do_QueryInterface(mAbsolutelyPositionedObject);
|
||||
NS_ENSURE_STATE(absolutelyPositionedObject);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*absolutelyPositionedObject,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*absolutelyPositionedObject,
|
||||
*nsGkAtoms::top, newY);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*absolutelyPositionedObject,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*absolutelyPositionedObject,
|
||||
*nsGkAtoms::left, newX);
|
||||
// keep track of that size
|
||||
mPositionedObjectX = newX;
|
||||
|
@ -476,7 +475,7 @@ nsHTMLEditor::AbsolutelyPositionElement(nsIDOMElement* aElement,
|
|||
NS_ENSURE_ARG_POINTER(element);
|
||||
|
||||
nsAutoString positionStr;
|
||||
mHTMLCSSUtils->GetComputedProperty(*element, *nsGkAtoms::position,
|
||||
mCSSEditUtils->GetComputedProperty(*element, *nsGkAtoms::position,
|
||||
positionStr);
|
||||
bool isPositioned = (positionStr.EqualsLiteral("absolute"));
|
||||
|
||||
|
@ -490,7 +489,7 @@ nsHTMLEditor::AbsolutelyPositionElement(nsIDOMElement* aElement,
|
|||
int32_t x, y;
|
||||
GetElementOrigin(aElement, x, y);
|
||||
|
||||
mHTMLCSSUtils->SetCSSProperty(*element, *nsGkAtoms::position,
|
||||
mCSSEditUtils->SetCSSProperty(*element, *nsGkAtoms::position,
|
||||
NS_LITERAL_STRING("absolute"));
|
||||
|
||||
AddPositioningOffset(x, y);
|
||||
|
@ -510,19 +509,19 @@ nsHTMLEditor::AbsolutelyPositionElement(nsIDOMElement* aElement,
|
|||
}
|
||||
}
|
||||
else {
|
||||
mHTMLCSSUtils->RemoveCSSProperty(*element, *nsGkAtoms::position,
|
||||
mCSSEditUtils->RemoveCSSProperty(*element, *nsGkAtoms::position,
|
||||
EmptyString());
|
||||
mHTMLCSSUtils->RemoveCSSProperty(*element, *nsGkAtoms::top,
|
||||
mCSSEditUtils->RemoveCSSProperty(*element, *nsGkAtoms::top,
|
||||
EmptyString());
|
||||
mHTMLCSSUtils->RemoveCSSProperty(*element, *nsGkAtoms::left,
|
||||
mCSSEditUtils->RemoveCSSProperty(*element, *nsGkAtoms::left,
|
||||
EmptyString());
|
||||
mHTMLCSSUtils->RemoveCSSProperty(*element, *nsGkAtoms::z_index,
|
||||
mCSSEditUtils->RemoveCSSProperty(*element, *nsGkAtoms::z_index,
|
||||
EmptyString());
|
||||
|
||||
if (!HTMLEditUtils::IsImage(aElement)) {
|
||||
mHTMLCSSUtils->RemoveCSSProperty(*element, *nsGkAtoms::width,
|
||||
mCSSEditUtils->RemoveCSSProperty(*element, *nsGkAtoms::width,
|
||||
EmptyString());
|
||||
mHTMLCSSUtils->RemoveCSSProperty(*element, *nsGkAtoms::height,
|
||||
mCSSEditUtils->RemoveCSSProperty(*element, *nsGkAtoms::height,
|
||||
EmptyString());
|
||||
}
|
||||
|
||||
|
@ -583,8 +582,8 @@ void
|
|||
nsHTMLEditor::SetElementPosition(dom::Element& aElement, int32_t aX, int32_t aY)
|
||||
{
|
||||
AutoEditBatch batchIt(this);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::left, aX);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::top, aY);
|
||||
mCSSEditUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::left, aX);
|
||||
mCSSEditUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::top, aY);
|
||||
}
|
||||
|
||||
// self-explanatory
|
||||
|
@ -618,18 +617,18 @@ nsHTMLEditor::CheckPositionedElementBGandFG(nsIDOMElement * aElement,
|
|||
|
||||
nsAutoString bgImageStr;
|
||||
nsresult res =
|
||||
mHTMLCSSUtils->GetComputedProperty(*element, *nsGkAtoms::background_image,
|
||||
mCSSEditUtils->GetComputedProperty(*element, *nsGkAtoms::background_image,
|
||||
bgImageStr);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (bgImageStr.EqualsLiteral("none")) {
|
||||
nsAutoString bgColorStr;
|
||||
res =
|
||||
mHTMLCSSUtils->GetComputedProperty(*element, *nsGkAtoms::backgroundColor,
|
||||
mCSSEditUtils->GetComputedProperty(*element, *nsGkAtoms::backgroundColor,
|
||||
bgColorStr);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (bgColorStr.EqualsLiteral("transparent")) {
|
||||
RefPtr<nsComputedDOMStyle> cssDecl =
|
||||
mHTMLCSSUtils->GetComputedStyle(element);
|
||||
mCSSEditUtils->GetComputedStyle(element);
|
||||
NS_ENSURE_STATE(cssDecl);
|
||||
|
||||
// from these declarations, get the one we want and that one only
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "nsDebug.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsHTMLCSSUtils.h"
|
||||
#include "nsHTMLEditor.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -424,7 +423,7 @@ nsHTMLEditor::GetPositionAndDimensions(nsIDOMElement * aElement,
|
|||
if (!isPositioned) {
|
||||
// hmmm... the expensive way now...
|
||||
nsAutoString positionStr;
|
||||
mHTMLCSSUtils->GetComputedProperty(*element, *nsGkAtoms::position,
|
||||
mCSSEditUtils->GetComputedProperty(*element, *nsGkAtoms::position,
|
||||
positionStr);
|
||||
isPositioned = positionStr.EqualsLiteral("absolute");
|
||||
}
|
||||
|
@ -435,7 +434,7 @@ nsHTMLEditor::GetPositionAndDimensions(nsIDOMElement * aElement,
|
|||
|
||||
// Get the all the computed css styles attached to the element node
|
||||
RefPtr<nsComputedDOMStyle> cssDecl =
|
||||
mHTMLCSSUtils->GetComputedStyle(element);
|
||||
mCSSEditUtils->GetComputedStyle(element);
|
||||
NS_ENSURE_STATE(cssDecl);
|
||||
|
||||
aBorderLeft = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("border-left-width"));
|
||||
|
@ -474,6 +473,6 @@ nsHTMLEditor::GetPositionAndDimensions(nsIDOMElement * aElement,
|
|||
void
|
||||
nsHTMLEditor::SetAnonymousElementPosition(int32_t aX, int32_t aY, nsIDOMElement *aElement)
|
||||
{
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(aElement, NS_LITERAL_STRING("left"), aX);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(aElement, NS_LITERAL_STRING("top"), aY);
|
||||
mCSSEditUtils->SetCSSPropertyPixels(aElement, NS_LITERAL_STRING("left"), aX);
|
||||
mCSSEditUtils->SetCSSPropertyPixels(aElement, NS_LITERAL_STRING("top"), aY);
|
||||
}
|
||||
|
|
|
@ -1,420 +0,0 @@
|
|||
/* -*- 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 nsHTMLCSSUtils_h__
|
||||
#define nsHTMLCSSUtils_h__
|
||||
|
||||
#include "ChangeStyleTransaction.h" // for ChangeStyleTransaction::EChangeType
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
#include "nscore.h" // for nsAString, nsresult, nullptr
|
||||
|
||||
class nsComputedDOMStyle;
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNode;
|
||||
class nsINode;
|
||||
class nsString;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Element;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class nsHTMLEditor;
|
||||
|
||||
typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
|
||||
const char * aDefaultValueString,
|
||||
const char * aPrependString, const char* aAppendString);
|
||||
|
||||
class nsHTMLCSSUtils
|
||||
{
|
||||
public:
|
||||
explicit nsHTMLCSSUtils(nsHTMLEditor* aEditor);
|
||||
~nsHTMLCSSUtils();
|
||||
|
||||
enum nsCSSEditableProperty {
|
||||
eCSSEditableProperty_NONE=0,
|
||||
eCSSEditableProperty_background_color,
|
||||
eCSSEditableProperty_background_image,
|
||||
eCSSEditableProperty_border,
|
||||
eCSSEditableProperty_caption_side,
|
||||
eCSSEditableProperty_color,
|
||||
eCSSEditableProperty_float,
|
||||
eCSSEditableProperty_font_family,
|
||||
eCSSEditableProperty_font_size,
|
||||
eCSSEditableProperty_font_style,
|
||||
eCSSEditableProperty_font_weight,
|
||||
eCSSEditableProperty_height,
|
||||
eCSSEditableProperty_list_style_type,
|
||||
eCSSEditableProperty_margin_left,
|
||||
eCSSEditableProperty_margin_right,
|
||||
eCSSEditableProperty_text_align,
|
||||
eCSSEditableProperty_text_decoration,
|
||||
eCSSEditableProperty_vertical_align,
|
||||
eCSSEditableProperty_whitespace,
|
||||
eCSSEditableProperty_width
|
||||
};
|
||||
|
||||
enum StyleType { eSpecified, eComputed };
|
||||
|
||||
|
||||
struct CSSEquivTable {
|
||||
nsCSSEditableProperty cssProperty;
|
||||
nsProcessValueFunc processValueFunctor;
|
||||
const char * defaultValue;
|
||||
const char * prependValue;
|
||||
const char * appendValue;
|
||||
bool gettable;
|
||||
bool caseSensitiveValue;
|
||||
};
|
||||
|
||||
/** answers true if the given combination element_name/attribute_name
|
||||
* has a CSS equivalence in this implementation
|
||||
*
|
||||
* @return a boolean saying if the tag/attribute has a css equiv
|
||||
* @param aNode [IN] a DOM node
|
||||
* @param aProperty [IN] an atom containing a HTML tag name
|
||||
* @param aAttribute [IN] a string containing the name of a HTML
|
||||
* attribute carried by the element above
|
||||
*/
|
||||
bool IsCSSEditableProperty(nsINode* aNode, nsIAtom* aProperty,
|
||||
const nsAString* aAttribute);
|
||||
|
||||
/** adds/remove a CSS declaration to the STYLE atrribute carried by a given element
|
||||
*
|
||||
* @param aElement [IN] a DOM element
|
||||
* @param aProperty [IN] an atom containing the CSS property to set
|
||||
* @param aValue [IN] a string containing the value of the CSS property
|
||||
* @param aSuppressTransaction [IN] a boolean indicating, when true,
|
||||
* that no transaction should be recorded
|
||||
*/
|
||||
nsresult SetCSSProperty(mozilla::dom::Element& aElement, nsIAtom& aProperty,
|
||||
const nsAString& aValue, bool aSuppressTxn = false);
|
||||
nsresult SetCSSPropertyPixels(mozilla::dom::Element& aElement,
|
||||
nsIAtom& aProperty, int32_t aIntValue);
|
||||
nsresult RemoveCSSProperty(mozilla::dom::Element& aElement,
|
||||
nsIAtom& aProperty,
|
||||
const nsAString& aPropertyValue,
|
||||
bool aSuppressTxn = false);
|
||||
|
||||
/** directly adds/remove a CSS declaration to the STYLE atrribute carried by
|
||||
* a given element without going through the txn manager
|
||||
*
|
||||
* @param aElement [IN] a DOM element
|
||||
* @param aProperty [IN] a string containing the CSS property to set/remove
|
||||
* @param aValue [IN] a string containing the new value of the CSS property
|
||||
*/
|
||||
nsresult SetCSSProperty(nsIDOMElement * aElement,
|
||||
const nsAString & aProperty,
|
||||
const nsAString & aValue);
|
||||
nsresult SetCSSPropertyPixels(nsIDOMElement * aElement,
|
||||
const nsAString & aProperty,
|
||||
int32_t aIntValue);
|
||||
|
||||
/** Gets the specified/computed style value of a CSS property for a given
|
||||
* node (or its element ancestor if it is not an element)
|
||||
*
|
||||
* @param aNode [IN] a DOM node
|
||||
* @param aProperty [IN] an atom containing the CSS property to get
|
||||
* @param aPropertyValue [OUT] the retrieved value of the property
|
||||
*/
|
||||
nsresult GetSpecifiedProperty(nsINode& aNode, nsIAtom& aProperty,
|
||||
nsAString& aValue);
|
||||
nsresult GetComputedProperty(nsINode& aNode, nsIAtom& aProperty,
|
||||
nsAString& aValue);
|
||||
|
||||
/** Removes a CSS property from the specified declarations in STYLE attribute
|
||||
** and removes the node if it is an useless span
|
||||
*
|
||||
* @param aNode [IN] the specific node we want to remove a style from
|
||||
* @param aProperty [IN] the CSS property atom to remove
|
||||
* @param aPropertyValue [IN] the value of the property we have to rremove if the property
|
||||
* accepts more than one value
|
||||
*/
|
||||
nsresult RemoveCSSInlineStyle(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString & aPropertyValue);
|
||||
|
||||
/** Answers true is the property can be removed by setting a "none" CSS value
|
||||
* on a node
|
||||
*
|
||||
* @return a boolean saying if the property can be remove by setting a "none" value
|
||||
* @param aProperty [IN] an atom containing a CSS property
|
||||
* @param aAttribute [IN] pointer to an attribute name or null if this information is irrelevant
|
||||
*/
|
||||
bool IsCSSInvertible(nsIAtom& aProperty, const nsAString* aAttribute);
|
||||
|
||||
/** Get the default browser background color if we need it for GetCSSBackgroundColorState
|
||||
*
|
||||
* @param aColor [OUT] the default color as it is defined in prefs
|
||||
*/
|
||||
void GetDefaultBackgroundColor(nsAString & aColor);
|
||||
|
||||
/** Get the default length unit used for CSS Indent/Outdent
|
||||
*
|
||||
* @param aLengthUnit [OUT] the default length unit as it is defined in prefs
|
||||
*/
|
||||
void GetDefaultLengthUnit(nsAString & aLengthUnit);
|
||||
|
||||
/** returns the list of values for the CSS equivalences to
|
||||
* the passed HTML style for the passed node
|
||||
*
|
||||
* @param aNode [IN] a DOM node
|
||||
* @param aHTMLProperty [IN] an atom containing an HTML property
|
||||
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
||||
* @param aValueString [OUT] the list of css values
|
||||
* @param aStyleType [IN] eSpecified or eComputed
|
||||
*/
|
||||
nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
nsIAtom * aHTMLProperty,
|
||||
const nsAString * aAttribute,
|
||||
nsAString & aValueString,
|
||||
StyleType aStyleType);
|
||||
|
||||
/** Does the node aNode (or his parent if it is not an element node) carries
|
||||
* the CSS equivalent styles to the HTML style for this node ?
|
||||
*
|
||||
* @param aNode [IN] a DOM node
|
||||
* @param aHTMLProperty [IN] an atom containing an HTML property
|
||||
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
||||
* @param aIsSet [OUT] a boolean being true if the css properties are set
|
||||
* @param aValueString [IN/OUT] the attribute value (in) the list of css values (out)
|
||||
* @param aStyleType [IN] eSpecified or eComputed
|
||||
*
|
||||
* The nsIContent variant returns aIsSet instead of using an out parameter.
|
||||
*/
|
||||
bool IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aContent,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString& aValue,
|
||||
StyleType aStyleType);
|
||||
|
||||
bool IsCSSEquivalentToHTMLInlineStyleSet(nsINode* aContent,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
nsAString& aValue,
|
||||
StyleType aStyleType);
|
||||
|
||||
nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
|
||||
nsIAtom * aHTMLProperty,
|
||||
const nsAString * aAttribute,
|
||||
bool & aIsSet,
|
||||
nsAString & aValueString,
|
||||
StyleType aStyleType);
|
||||
|
||||
/** Adds to the node the CSS inline styles equivalent to the HTML style
|
||||
* and return the number of CSS properties set by the call
|
||||
*
|
||||
* @param aNode [IN] a DOM node
|
||||
* @param aHTMLProperty [IN] an atom containing an HTML property
|
||||
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
||||
* @param aValue [IN] the attribute value
|
||||
* @param aCount [OUT] the number of CSS properties set by the call
|
||||
* @param aSuppressTransaction [IN] a boolean indicating, when true,
|
||||
* that no transaction should be recorded
|
||||
*
|
||||
* aCount is returned by the dom::Element variant instead of being an out
|
||||
* parameter.
|
||||
*/
|
||||
int32_t SetCSSEquivalentToHTMLStyle(mozilla::dom::Element* aElement,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
bool aSuppressTransaction);
|
||||
nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
||||
nsIAtom * aHTMLProperty,
|
||||
const nsAString * aAttribute,
|
||||
const nsAString * aValue,
|
||||
int32_t * aCount,
|
||||
bool aSuppressTransaction);
|
||||
|
||||
/** removes from the node the CSS inline styles equivalent to the HTML style
|
||||
*
|
||||
* @param aNode [IN] a DOM node
|
||||
* @param aHTMLProperty [IN] an atom containing an HTML property
|
||||
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
||||
* @param aValue [IN] the attribute value
|
||||
* @param aSuppressTransaction [IN] a boolean indicating, when true,
|
||||
* that no transaction should be recorded
|
||||
*/
|
||||
nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
||||
nsIAtom *aHTMLProperty,
|
||||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
bool aSuppressTransaction);
|
||||
/** removes from the node the CSS inline styles equivalent to the HTML style
|
||||
*
|
||||
* @param aElement [IN] a DOM Element (must not be null)
|
||||
* @param aHTMLProperty [IN] an atom containing an HTML property
|
||||
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
||||
* @param aValue [IN] the attribute value
|
||||
* @param aSuppressTransaction [IN] a boolean indicating, when true,
|
||||
* that no transaction should be recorded
|
||||
*/
|
||||
nsresult RemoveCSSEquivalentToHTMLStyle(mozilla::dom::Element* aElement,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
bool aSuppressTransaction);
|
||||
|
||||
/** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
|
||||
* we need such a parser because nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not
|
||||
* implemented
|
||||
*
|
||||
* @param aString [IN] input string to parse
|
||||
* @param aValue [OUT] numeric part
|
||||
* @param aUnit [OUT] unit part
|
||||
*/
|
||||
void ParseLength(const nsAString & aString, float * aValue, nsIAtom ** aUnit);
|
||||
|
||||
/** sets the mIsCSSPrefChecked private member ; used as callback from observer when
|
||||
* the css pref state is changed
|
||||
*
|
||||
* @param aIsCSSPrefChecked [IN] the new boolean state for the pref
|
||||
*/
|
||||
void SetCSSEnabled(bool aIsCSSPrefChecked);
|
||||
|
||||
/** retrieves the mIsCSSPrefChecked private member, true if the css pref is checked,
|
||||
* false if it is not
|
||||
*
|
||||
* @return the boolean value of the css pref
|
||||
*/
|
||||
bool IsCSSPrefChecked();
|
||||
|
||||
/** ElementsSameStyle compares two elements and checks if they have the same
|
||||
* specified CSS declarations in the STYLE attribute
|
||||
* The answer is always false if at least one of them carries an ID or a class
|
||||
*
|
||||
* @return true if the two elements are considered to have same styles
|
||||
* @param aFirstNode [IN] a DOM node
|
||||
* @param aSecondNode [IN] a DOM node
|
||||
*/
|
||||
bool ElementsSameStyle(mozilla::dom::Element* aFirstNode,
|
||||
mozilla::dom::Element* aSecondNode);
|
||||
bool ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode);
|
||||
|
||||
/** get the specified inline styles (style attribute) for an element
|
||||
*
|
||||
* @param aElement [IN] the element node
|
||||
* @param aCssDecl [OUT] the CSS declaration corresponding to the style attr
|
||||
* @param aLength [OUT] the number of declarations in aCssDecl
|
||||
*/
|
||||
nsresult GetInlineStyles(mozilla::dom::Element* aElement,
|
||||
nsIDOMCSSStyleDeclaration** aCssDecl,
|
||||
uint32_t* aLength);
|
||||
nsresult GetInlineStyles(nsIDOMElement* aElement,
|
||||
nsIDOMCSSStyleDeclaration** aCssDecl,
|
||||
uint32_t* aLength);
|
||||
private:
|
||||
nsresult GetInlineStyles(nsISupports* aElement,
|
||||
nsIDOMCSSStyleDeclaration** aCssDecl,
|
||||
uint32_t* aLength);
|
||||
|
||||
public:
|
||||
/** returns aNode itself if it is an element node, or the first ancestors being an element
|
||||
* node if aNode is not one itself
|
||||
*
|
||||
* @param aNode [IN] a node
|
||||
* @param aElement [OUT] the deepest element node containing aNode (possibly aNode itself)
|
||||
*/
|
||||
mozilla::dom::Element* GetElementContainerOrSelf(nsINode* aNode);
|
||||
already_AddRefed<nsIDOMElement> GetElementContainerOrSelf(nsIDOMNode* aNode);
|
||||
|
||||
/**
|
||||
* Gets the computed style for a given element. Can return null.
|
||||
*/
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
GetComputedStyle(mozilla::dom::Element* aElement);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/** retrieves the css property atom from an enum
|
||||
*
|
||||
* @param aProperty [IN] the enum value for the property
|
||||
* @param aAtom [OUT] the corresponding atom
|
||||
*/
|
||||
void GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom);
|
||||
|
||||
/** retrieves the CSS declarations equivalent to a HTML style value for
|
||||
* a given equivalence table
|
||||
*
|
||||
* @param aPropertyArray [OUT] the array of css properties
|
||||
* @param aValueArray [OUT] the array of values for the css properties above
|
||||
* @param aEquivTable [IN] the equivalence table
|
||||
* @param aValue [IN] the HTML style value
|
||||
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
|
||||
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
|
||||
* RemoveCSSEquivalentToHTMLInlineStyleSet
|
||||
*/
|
||||
|
||||
void BuildCSSDeclarations(nsTArray<nsIAtom*> & aPropertyArray,
|
||||
nsTArray<nsString> & cssValueArray,
|
||||
const CSSEquivTable * aEquivTable,
|
||||
const nsAString * aValue,
|
||||
bool aGetOrRemoveRequest);
|
||||
|
||||
/** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
|
||||
* for a given node
|
||||
*
|
||||
* @param aNode [IN] the DOM node
|
||||
* @param aHTMLProperty [IN] an atom containing an HTML property
|
||||
* @param aAttribute [IN] a pointer to an attribute name or nullptr if irrelevant
|
||||
* @param aValue [IN] the attribute value
|
||||
* @param aPropertyArray [OUT] the array of css properties
|
||||
* @param aValueArray [OUT] the array of values for the css properties above
|
||||
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
|
||||
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
|
||||
* RemoveCSSEquivalentToHTMLInlineStyleSet
|
||||
*/
|
||||
void GenerateCSSDeclarationsFromHTMLStyle(mozilla::dom::Element* aNode,
|
||||
nsIAtom* aHTMLProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue,
|
||||
nsTArray<nsIAtom*>& aPropertyArray,
|
||||
nsTArray<nsString>& aValueArray,
|
||||
bool aGetOrRemoveRequest);
|
||||
|
||||
/** Creates a Transaction for setting or removing a CSS property. Never
|
||||
* returns null.
|
||||
*
|
||||
* @param aElement [IN] a DOM element
|
||||
* @param aProperty [IN] a CSS property
|
||||
* @param aValue [IN] the value to set for this CSS property
|
||||
* @param aChangeType [IN] eSet to set, eRemove to remove
|
||||
*/
|
||||
already_AddRefed<mozilla::ChangeStyleTransaction>
|
||||
CreateCSSPropertyTxn(mozilla::dom::Element& aElement,
|
||||
nsIAtom& aProperty, const nsAString& aValue,
|
||||
mozilla::ChangeStyleTransaction::EChangeType aChangeType);
|
||||
|
||||
/** back-end for GetSpecifiedProperty and GetComputedProperty
|
||||
*
|
||||
* @param aNode [IN] a DOM node
|
||||
* @param aProperty [IN] a CSS property
|
||||
* @param aValue [OUT] the retrieved value for this property
|
||||
* @param aStyleType [IN] eSpecified or eComputed
|
||||
*/
|
||||
nsresult GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
|
||||
nsAString& aValue, StyleType aStyleType);
|
||||
|
||||
|
||||
private:
|
||||
nsHTMLEditor *mHTMLEditor;
|
||||
bool mIsCSSPrefChecked;
|
||||
};
|
||||
|
||||
#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
|
||||
#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
|
||||
#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f
|
||||
#define NS_EDITOR_INDENT_INCREMENT_PT 29.76f
|
||||
#define NS_EDITOR_INDENT_INCREMENT_PC 2.48f
|
||||
#define NS_EDITOR_INDENT_INCREMENT_EM 3
|
||||
#define NS_EDITOR_INDENT_INCREMENT_EX 6
|
||||
#define NS_EDITOR_INDENT_INCREMENT_PX 40
|
||||
#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
|
||||
|
||||
#endif /* nsHTMLCSSUtils_h__ */
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "CSSEditUtils.h"
|
||||
#include "EditorUtils.h"
|
||||
#include "HTMLEditUtils.h"
|
||||
#include "TextEditUtils.h"
|
||||
|
@ -29,7 +30,6 @@
|
|||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsHTMLCSSUtils.h"
|
||||
#include "nsHTMLEditor.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -867,13 +867,13 @@ nsHTMLEditRules::GetAlignment(bool* aMixed, nsIHTMLEditor::EAlignment* aAlign)
|
|||
NS_ENSURE_TRUE(blockParent, NS_ERROR_FAILURE);
|
||||
|
||||
if (mHTMLEditor->IsCSSEnabled() &&
|
||||
mHTMLEditor->mHTMLCSSUtils->IsCSSEditableProperty(blockParent, nullptr,
|
||||
mHTMLEditor->mCSSEditUtils->IsCSSEditableProperty(blockParent, nullptr,
|
||||
&typeAttrName)) {
|
||||
// We are in CSS mode and we know how to align this element with CSS
|
||||
nsAutoString value;
|
||||
// Let's get the value(s) of text-align or margin-left/margin-right
|
||||
mHTMLEditor->mHTMLCSSUtils->GetCSSEquivalentToHTMLInlineStyleSet(
|
||||
blockParent, nullptr, &typeAttrName, value, nsHTMLCSSUtils::eComputed);
|
||||
mHTMLEditor->mCSSEditUtils->GetCSSEquivalentToHTMLInlineStyleSet(
|
||||
blockParent, nullptr, &typeAttrName, value, CSSEditUtils::eComputed);
|
||||
if (value.EqualsLiteral("center") ||
|
||||
value.EqualsLiteral("-moz-center") ||
|
||||
value.EqualsLiteral("auto auto")) {
|
||||
|
@ -928,7 +928,7 @@ nsHTMLEditRules::GetAlignment(bool* aMixed, nsIHTMLEditor::EAlignment* aAlign)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsIAtom& MarginPropertyAtomForIndent(nsHTMLCSSUtils& aHTMLCSSUtils,
|
||||
static nsIAtom& MarginPropertyAtomForIndent(CSSEditUtils& aHTMLCSSUtils,
|
||||
nsINode& aNode)
|
||||
{
|
||||
nsAutoString direction;
|
||||
|
@ -968,17 +968,17 @@ nsHTMLEditRules::GetIndentState(bool *aCanIndent, bool *aCanOutdent)
|
|||
// we are in CSS mode, indentation is done using the margin-left (or margin-right) property
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
nsIAtom& marginProperty =
|
||||
MarginPropertyAtomForIndent(*mHTMLEditor->mHTMLCSSUtils, curNode);
|
||||
MarginPropertyAtomForIndent(*mHTMLEditor->mCSSEditUtils, curNode);
|
||||
nsAutoString value;
|
||||
// retrieve its specified value
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(*curNode,
|
||||
mHTMLEditor->mCSSEditUtils->GetSpecifiedProperty(*curNode,
|
||||
marginProperty, value);
|
||||
float f;
|
||||
nsCOMPtr<nsIAtom> unit;
|
||||
// get its number part and its unit
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
mHTMLEditor->mHTMLCSSUtils->ParseLength(value, &f, getter_AddRefs(unit));
|
||||
mHTMLEditor->mCSSEditUtils->ParseLength(value, &f, getter_AddRefs(unit));
|
||||
// if the number part is strictly positive, outdent is possible
|
||||
if (0 < f) {
|
||||
*aCanOutdent = true;
|
||||
|
@ -3988,15 +3988,16 @@ nsHTMLEditRules::WillOutdent(Selection& aSelection,
|
|||
// Is it a block with a 'margin' property?
|
||||
if (useCSS && IsBlockNode(curNode)) {
|
||||
nsIAtom& marginProperty =
|
||||
MarginPropertyAtomForIndent(*mHTMLEditor->mHTMLCSSUtils, curNode);
|
||||
MarginPropertyAtomForIndent(*mHTMLEditor->mCSSEditUtils, curNode);
|
||||
nsAutoString value;
|
||||
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(curNode,
|
||||
mHTMLEditor->mCSSEditUtils->GetSpecifiedProperty(curNode,
|
||||
marginProperty,
|
||||
value);
|
||||
float f;
|
||||
nsCOMPtr<nsIAtom> unit;
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
mHTMLEditor->mHTMLCSSUtils->ParseLength(value, &f, getter_AddRefs(unit));
|
||||
mHTMLEditor->mCSSEditUtils->ParseLength(value, &f,
|
||||
getter_AddRefs(unit));
|
||||
if (f > 0) {
|
||||
ChangeIndentation(*curNode->AsElement(), Change::minus);
|
||||
continue;
|
||||
|
@ -4069,13 +4070,13 @@ nsHTMLEditRules::WillOutdent(Selection& aSelection,
|
|||
break;
|
||||
} else if (useCSS) {
|
||||
nsIAtom& marginProperty =
|
||||
MarginPropertyAtomForIndent(*mHTMLEditor->mHTMLCSSUtils, curNode);
|
||||
MarginPropertyAtomForIndent(*mHTMLEditor->mCSSEditUtils, curNode);
|
||||
nsAutoString value;
|
||||
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(*n, marginProperty,
|
||||
mHTMLEditor->mCSSEditUtils->GetSpecifiedProperty(*n, marginProperty,
|
||||
value);
|
||||
float f;
|
||||
nsCOMPtr<nsIAtom> unit;
|
||||
mHTMLEditor->mHTMLCSSUtils->ParseLength(value, &f, getter_AddRefs(unit));
|
||||
mHTMLEditor->mCSSEditUtils->ParseLength(value, &f, getter_AddRefs(unit));
|
||||
if (f > 0 && !(HTMLEditUtils::IsList(curParent) &&
|
||||
HTMLEditUtils::IsList(curNode))) {
|
||||
curBlockQuote = n->AsElement();
|
||||
|
@ -4623,7 +4624,7 @@ nsHTMLEditRules::WillAlign(Selection& aSelection,
|
|||
rv = RemoveAlignment(GetAsDOMNode(curNode), aAlignType, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (useCSS) {
|
||||
mHTMLEditor->mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(
|
||||
mHTMLEditor->mCSSEditUtils->SetCSSEquivalentToHTMLStyle(
|
||||
curNode->AsElement(), nullptr, &NS_LITERAL_STRING("align"),
|
||||
&aAlignType, false);
|
||||
curDiv = nullptr;
|
||||
|
@ -6948,7 +6949,7 @@ nsHTMLEditRules::JoinNodesSmart(nsIContent& aNodeLeft, nsIContent& aNodeRight)
|
|||
mHTMLEditor->AreNodesSameType(lastLeft, firstRight) &&
|
||||
(lastLeft->GetAsText() || !mHTMLEditor ||
|
||||
(lastLeft->IsElement() && firstRight->IsElement() &&
|
||||
mHTMLEditor->mHTMLCSSUtils->ElementsSameStyle(lastLeft->AsElement(),
|
||||
mHTMLEditor->mCSSEditUtils->ElementsSameStyle(lastLeft->AsElement(),
|
||||
firstRight->AsElement())))) {
|
||||
NS_ENSURE_TRUE(mHTMLEditor, EditorDOMPoint());
|
||||
return JoinNodesSmart(*lastLeft, *firstRight);
|
||||
|
@ -6999,9 +7000,9 @@ nsHTMLEditRules::CacheInlineStyles(nsIDOMNode *aNode)
|
|||
else
|
||||
{
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
mHTMLEditor->mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(aNode,
|
||||
mHTMLEditor->mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(aNode,
|
||||
mCachedStyles[j].tag, &(mCachedStyles[j].attr), isSet, outValue,
|
||||
nsHTMLCSSUtils::eComputed);
|
||||
CSSEditUtils::eComputed);
|
||||
}
|
||||
if (isSet)
|
||||
{
|
||||
|
@ -7053,9 +7054,9 @@ nsHTMLEditRules::ReapplyCachedStyles()
|
|||
if (useCSS) {
|
||||
// check computed style first in css case
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
bAny = mHTMLEditor->mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(
|
||||
bAny = mHTMLEditor->mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(
|
||||
selNode, mCachedStyles[i].tag, &(mCachedStyles[i].attr), curValue,
|
||||
nsHTMLCSSUtils::eComputed);
|
||||
CSSEditUtils::eComputed);
|
||||
}
|
||||
if (!bAny) {
|
||||
// then check typeinstate and html style
|
||||
|
@ -8258,7 +8259,7 @@ nsHTMLEditRules::RemoveAlignment(nsIDOMNode * aNode, const nsAString & aAlignTyp
|
|||
} else {
|
||||
nsAutoString dummyCssValue;
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
res = mHTMLEditor->mHTMLCSSUtils->RemoveCSSInlineStyle(child,
|
||||
res = mHTMLEditor->mCSSEditUtils->RemoveCSSInlineStyle(child,
|
||||
nsGkAtoms::textAlign, dummyCssValue);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
@ -8399,16 +8400,16 @@ nsHTMLEditRules::ChangeIndentation(Element& aElement, Change aChange)
|
|||
nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
|
||||
|
||||
nsIAtom& marginProperty =
|
||||
MarginPropertyAtomForIndent(*mHTMLEditor->mHTMLCSSUtils, aElement);
|
||||
MarginPropertyAtomForIndent(*mHTMLEditor->mCSSEditUtils, aElement);
|
||||
nsAutoString value;
|
||||
mHTMLEditor->mHTMLCSSUtils->GetSpecifiedProperty(aElement, marginProperty,
|
||||
mHTMLEditor->mCSSEditUtils->GetSpecifiedProperty(aElement, marginProperty,
|
||||
value);
|
||||
float f;
|
||||
nsCOMPtr<nsIAtom> unit;
|
||||
mHTMLEditor->mHTMLCSSUtils->ParseLength(value, &f, getter_AddRefs(unit));
|
||||
mHTMLEditor->mCSSEditUtils->ParseLength(value, &f, getter_AddRefs(unit));
|
||||
if (0 == f) {
|
||||
nsAutoString defaultLengthUnit;
|
||||
mHTMLEditor->mHTMLCSSUtils->GetDefaultLengthUnit(defaultLengthUnit);
|
||||
mHTMLEditor->mCSSEditUtils->GetDefaultLengthUnit(defaultLengthUnit);
|
||||
unit = NS_Atomize(defaultLengthUnit);
|
||||
}
|
||||
int8_t multiplier = aChange == Change::plus ? +1 : -1;
|
||||
|
@ -8436,12 +8437,12 @@ nsHTMLEditRules::ChangeIndentation(Element& aElement, Change aChange)
|
|||
nsAutoString newValue;
|
||||
newValue.AppendFloat(f);
|
||||
newValue.Append(nsDependentAtomString(unit));
|
||||
mHTMLEditor->mHTMLCSSUtils->SetCSSProperty(aElement, marginProperty,
|
||||
mHTMLEditor->mCSSEditUtils->SetCSSProperty(aElement, marginProperty,
|
||||
newValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mHTMLEditor->mHTMLCSSUtils->RemoveCSSProperty(aElement, marginProperty,
|
||||
mHTMLEditor->mCSSEditUtils->RemoveCSSProperty(aElement, marginProperty,
|
||||
value);
|
||||
|
||||
// Remove unnecessary divs
|
||||
|
|
|
@ -284,7 +284,7 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc,
|
|||
}
|
||||
|
||||
// Init the HTML-CSS utils
|
||||
mHTMLCSSUtils = new nsHTMLCSSUtils(this);
|
||||
mCSSEditUtils = new CSSEditUtils(this);
|
||||
|
||||
// disable links
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
|
@ -1787,7 +1787,7 @@ nsHTMLEditor::GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor, boo
|
|||
// Make sure to not walk off onto the Document node
|
||||
do {
|
||||
// retrieve the computed style of background-color for blockParent
|
||||
mHTMLCSSUtils->GetComputedProperty(*blockParent,
|
||||
mCSSEditUtils->GetComputedProperty(*blockParent,
|
||||
*nsGkAtoms::backgroundColor,
|
||||
aOutColor);
|
||||
blockParent = blockParent->GetParentElement();
|
||||
|
@ -1798,7 +1798,7 @@ nsHTMLEditor::GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor, boo
|
|||
// we have hit the root of the document and the color is still transparent !
|
||||
// Grumble... Let's look at the default background color because that's the
|
||||
// color we are looking for
|
||||
mHTMLCSSUtils->GetDefaultBackgroundColor(aOutColor);
|
||||
mCSSEditUtils->GetDefaultBackgroundColor(aOutColor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1817,7 +1817,7 @@ nsHTMLEditor::GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor, boo
|
|||
else {
|
||||
// no, it's not; let's retrieve the computed style of background-color for the
|
||||
// node to examine
|
||||
mHTMLCSSUtils->GetComputedProperty(*nodeToExamine,
|
||||
mCSSEditUtils->GetComputedProperty(*nodeToExamine,
|
||||
*nsGkAtoms::backgroundColor,
|
||||
aOutColor);
|
||||
if (!aOutColor.EqualsLiteral("transparent")) {
|
||||
|
@ -4406,9 +4406,11 @@ nsHTMLEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
|||
nsAutoScriptBlocker scriptBlocker;
|
||||
|
||||
nsresult res = NS_OK;
|
||||
if (IsCSSEnabled() && mHTMLCSSUtils) {
|
||||
if (IsCSSEnabled() && mCSSEditUtils) {
|
||||
int32_t count;
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(aElement, nullptr, &aAttribute, &aValue, &count,
|
||||
res = mCSSEditUtils->SetCSSEquivalentToHTMLStyle(aElement, nullptr,
|
||||
&aAttribute, &aValue,
|
||||
&count,
|
||||
aSuppressTransaction);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (count) {
|
||||
|
@ -4474,8 +4476,8 @@ nsHTMLEditor::RemoveAttributeOrEquivalent(nsIDOMElement* aElement,
|
|||
MOZ_ASSERT(attribute);
|
||||
|
||||
nsresult res = NS_OK;
|
||||
if (IsCSSEnabled() && mHTMLCSSUtils) {
|
||||
res = mHTMLCSSUtils->RemoveCSSEquivalentToHTMLStyle(
|
||||
if (IsCSSEnabled() && mCSSEditUtils) {
|
||||
res = mCSSEditUtils->RemoveCSSEquivalentToHTMLStyle(
|
||||
element, nullptr, &aAttribute, nullptr, aSuppressTransaction);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
|
@ -4494,11 +4496,11 @@ nsHTMLEditor::RemoveAttributeOrEquivalent(nsIDOMElement* aElement,
|
|||
nsresult
|
||||
nsHTMLEditor::SetIsCSSEnabled(bool aIsCSSPrefChecked)
|
||||
{
|
||||
if (!mHTMLCSSUtils) {
|
||||
if (!mCSSEditUtils) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
mHTMLCSSUtils->SetCSSEnabled(aIsCSSPrefChecked);
|
||||
mCSSEditUtils->SetCSSEnabled(aIsCSSPrefChecked);
|
||||
|
||||
// Disable the eEditorNoCSSMask flag if we're enabling StyleWithCSS.
|
||||
uint32_t flags = mFlags;
|
||||
|
@ -4558,13 +4560,13 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
// And apply the background color to that block container
|
||||
if (blockParent && cachedBlockParent != blockParent) {
|
||||
cachedBlockParent = blockParent;
|
||||
mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(blockParent, nullptr,
|
||||
mCSSEditUtils->SetCSSEquivalentToHTMLStyle(blockParent, nullptr,
|
||||
&bgcolor, &aColor, false);
|
||||
}
|
||||
} else if (startNode == endNode &&
|
||||
startNode->IsHTMLElement(nsGkAtoms::body) && isCollapsed) {
|
||||
// No block in the document, let's apply the background to the body
|
||||
mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(startNode->AsElement(),
|
||||
mCSSEditUtils->SetCSSEquivalentToHTMLStyle(startNode->AsElement(),
|
||||
nullptr, &bgcolor, &aColor,
|
||||
false);
|
||||
} else if (startNode == endNode && (endOffset - startOffset == 1 ||
|
||||
|
@ -4575,7 +4577,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
nsCOMPtr<Element> blockParent = GetBlock(*selectedNode);
|
||||
if (blockParent && cachedBlockParent != blockParent) {
|
||||
cachedBlockParent = blockParent;
|
||||
mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(blockParent, nullptr,
|
||||
mCSSEditUtils->SetCSSEquivalentToHTMLStyle(blockParent, nullptr,
|
||||
&bgcolor, &aColor, false);
|
||||
}
|
||||
} else {
|
||||
|
@ -4618,7 +4620,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
nsCOMPtr<Element> blockParent = GetBlockNodeParent(startNode);
|
||||
if (blockParent && cachedBlockParent != blockParent) {
|
||||
cachedBlockParent = blockParent;
|
||||
mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(blockParent, nullptr,
|
||||
mCSSEditUtils->SetCSSEquivalentToHTMLStyle(blockParent, nullptr,
|
||||
&bgcolor, &aColor,
|
||||
false);
|
||||
}
|
||||
|
@ -4629,7 +4631,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
nsCOMPtr<Element> blockParent = GetBlock(node);
|
||||
if (blockParent && cachedBlockParent != blockParent) {
|
||||
cachedBlockParent = blockParent;
|
||||
mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(blockParent, nullptr,
|
||||
mCSSEditUtils->SetCSSEquivalentToHTMLStyle(blockParent, nullptr,
|
||||
&bgcolor, &aColor,
|
||||
false);
|
||||
}
|
||||
|
@ -4643,7 +4645,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
nsCOMPtr<Element> blockParent = GetBlockNodeParent(endNode);
|
||||
if (blockParent && cachedBlockParent != blockParent) {
|
||||
cachedBlockParent = blockParent;
|
||||
mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(blockParent, nullptr,
|
||||
mCSSEditUtils->SetCSSEquivalentToHTMLStyle(blockParent, nullptr,
|
||||
&bgcolor, &aColor,
|
||||
false);
|
||||
}
|
||||
|
@ -4695,7 +4697,7 @@ nsHTMLEditor::AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2)
|
|||
}
|
||||
|
||||
// If CSS is enabled, we are stricter about span nodes.
|
||||
return mHTMLCSSUtils->ElementsSameStyle(aNode1->AsDOMNode(),
|
||||
return mCSSEditUtils->ElementsSameStyle(aNode1->AsDOMNode(),
|
||||
aNode2->AsDOMNode());
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "nsEditRules.h"
|
||||
|
||||
#include "nsHTMLCSSUtils.h"
|
||||
#include "CSSEditUtils.h"
|
||||
|
||||
#include "nsHTMLObjectResizer.h"
|
||||
#include "nsIHTMLAbsPosEditor.h"
|
||||
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
|
||||
class nsDocumentFragment;
|
||||
|
@ -57,7 +58,6 @@ class TypeInState;
|
|||
struct PropItem;
|
||||
template<class T> class OwningNonNull;
|
||||
namespace dom {
|
||||
class BlobImpl;
|
||||
class DocumentFragment;
|
||||
} // namespace dom
|
||||
namespace widget {
|
||||
|
@ -396,8 +396,8 @@ public:
|
|||
|
||||
bool IsCSSEnabled()
|
||||
{
|
||||
// TODO: removal of mCSSAware and use only the presence of mHTMLCSSUtils
|
||||
return mCSSAware && mHTMLCSSUtils && mHTMLCSSUtils->IsCSSPrefChecked();
|
||||
// TODO: removal of mCSSAware and use only the presence of mCSSEditUtils
|
||||
return mCSSAware && mCSSEditUtils && mCSSEditUtils->IsCSSPrefChecked();
|
||||
}
|
||||
|
||||
static bool HasAttributes(Element* aElement)
|
||||
|
@ -791,7 +791,7 @@ protected:
|
|||
bool mCRInParagraphCreatesParagraph;
|
||||
|
||||
bool mCSSAware;
|
||||
nsAutoPtr<nsHTMLCSSUtils> mHTMLCSSUtils;
|
||||
nsAutoPtr<mozilla::CSSEditUtils> mCSSEditUtils;
|
||||
|
||||
// Used by GetFirstSelectedCell and GetNextSelectedCell
|
||||
int32_t mSelectedCellIndex;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
/* 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/. */
|
||||
|
||||
#include "EditorUtils.h"
|
||||
#include "HTMLEditUtils.h"
|
||||
#include "SelectionState.h"
|
||||
|
@ -21,7 +22,6 @@
|
|||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsHTMLCSSUtils.h"
|
||||
#include "nsHTMLEditor.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -278,7 +278,7 @@ nsHTMLEditor::IsSimpleModifiableNode(nsIContent* aContent,
|
|||
// No luck so far. Now we check for a <span> with a single style=""
|
||||
// attribute that sets only the style we're looking for, if this type of
|
||||
// style supports it
|
||||
if (!mHTMLCSSUtils->IsCSSEditableProperty(element, aProperty, aAttribute) ||
|
||||
if (!mCSSEditUtils->IsCSSEditableProperty(element, aProperty, aAttribute) ||
|
||||
!element->IsHTMLElement(nsGkAtoms::span) ||
|
||||
element->GetAttrCount() != 1 ||
|
||||
!element->HasAttr(kNameSpaceID_None, nsGkAtoms::style)) {
|
||||
|
@ -292,11 +292,11 @@ nsHTMLEditor::IsSimpleModifiableNode(nsIContent* aContent,
|
|||
nsCOMPtr<Element> newSpan = CreateHTMLContent(nsGkAtoms::span);
|
||||
NS_ASSERTION(newSpan, "CreateHTMLContent failed");
|
||||
NS_ENSURE_TRUE(newSpan, false);
|
||||
mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(newSpan, aProperty,
|
||||
mCSSEditUtils->SetCSSEquivalentToHTMLStyle(newSpan, aProperty,
|
||||
aAttribute, aValue,
|
||||
/*suppress transaction*/ true);
|
||||
|
||||
return mHTMLCSSUtils->ElementsSameStyle(newSpan, element);
|
||||
return mCSSEditUtils->ElementsSameStyle(newSpan, element);
|
||||
}
|
||||
|
||||
|
||||
|
@ -319,11 +319,11 @@ nsHTMLEditor::SetInlinePropertyOnTextNode(Text& aText,
|
|||
}
|
||||
|
||||
// Don't need to do anything if property already set on node
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(&aText, &aProperty, aAttribute)) {
|
||||
if (mCSSEditUtils->IsCSSEditableProperty(&aText, &aProperty, aAttribute)) {
|
||||
// The HTML styles defined by aProperty/aAttribute have a CSS equivalence
|
||||
// for node; let's check if it carries those CSS styles
|
||||
if (mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(&aText, &aProperty,
|
||||
aAttribute, aValue, nsHTMLCSSUtils::eComputed)) {
|
||||
if (mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(&aText, &aProperty,
|
||||
aAttribute, aValue, CSSEditUtils::eComputed)) {
|
||||
return NS_OK;
|
||||
}
|
||||
} else if (IsTextPropertySetByContent(&aText, &aProperty, aAttribute,
|
||||
|
@ -418,9 +418,9 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent& aNode,
|
|||
}
|
||||
|
||||
// Don't need to do anything if property already set on node
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(&aNode, &aProperty, aAttribute)) {
|
||||
if (mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(
|
||||
&aNode, &aProperty, aAttribute, aValue, nsHTMLCSSUtils::eComputed)) {
|
||||
if (mCSSEditUtils->IsCSSEditableProperty(&aNode, &aProperty, aAttribute)) {
|
||||
if (mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(
|
||||
&aNode, &aProperty, aAttribute, aValue, CSSEditUtils::eComputed)) {
|
||||
return NS_OK;
|
||||
}
|
||||
} else if (IsTextPropertySetByContent(&aNode, &aProperty,
|
||||
|
@ -429,7 +429,8 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent& aNode,
|
|||
}
|
||||
|
||||
bool useCSS = (IsCSSEnabled() &&
|
||||
mHTMLCSSUtils->IsCSSEditableProperty(&aNode, &aProperty, aAttribute)) ||
|
||||
mCSSEditUtils->IsCSSEditableProperty(&aNode, &aProperty,
|
||||
aAttribute)) ||
|
||||
// bgcolor is always done using CSS
|
||||
aAttribute->EqualsLiteral("bgcolor");
|
||||
|
||||
|
@ -447,7 +448,7 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent& aNode,
|
|||
|
||||
// Add the CSS styles corresponding to the HTML style request
|
||||
int32_t count;
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(tmp->AsDOMNode(),
|
||||
res = mCSSEditUtils->SetCSSEquivalentToHTMLStyle(tmp->AsDOMNode(),
|
||||
&aProperty, aAttribute,
|
||||
&aValue, &count, false);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
@ -570,14 +571,14 @@ nsHTMLEditor::SplitStyleAbovePoint(nsCOMPtr<nsINode>* aNode,
|
|||
while (!IsBlockNode(node) && node->GetParent() &&
|
||||
IsEditable(node->GetParent())) {
|
||||
isSet = false;
|
||||
if (useCSS && mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty,
|
||||
if (useCSS && mCSSEditUtils->IsCSSEditableProperty(node, aProperty,
|
||||
aAttribute)) {
|
||||
// The HTML style defined by aProperty/aAttribute has a CSS equivalence
|
||||
// in this implementation for the node; let's check if it carries those
|
||||
// CSS styles
|
||||
nsAutoString firstValue;
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(GetAsDOMNode(node),
|
||||
aProperty, aAttribute, isSet, firstValue, nsHTMLCSSUtils::eSpecified);
|
||||
mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(GetAsDOMNode(node),
|
||||
aProperty, aAttribute, isSet, firstValue, CSSEditUtils::eSpecified);
|
||||
}
|
||||
if (// node is the correct inline prop
|
||||
(aProperty && node->IsHTMLElement(aProperty)) ||
|
||||
|
@ -779,17 +780,17 @@ nsHTMLEditor::RemoveStyleInside(nsIContent& aNode,
|
|||
}
|
||||
|
||||
if (!aChildrenOnly &&
|
||||
mHTMLCSSUtils->IsCSSEditableProperty(&aNode, aProperty, aAttribute)) {
|
||||
mCSSEditUtils->IsCSSEditableProperty(&aNode, aProperty, aAttribute)) {
|
||||
// the HTML style defined by aProperty/aAttribute has a CSS equivalence in
|
||||
// this implementation for the node aNode; let's check if it carries those
|
||||
// css styles
|
||||
nsAutoString propertyValue;
|
||||
bool isSet = mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(&aNode,
|
||||
aProperty, aAttribute, propertyValue, nsHTMLCSSUtils::eSpecified);
|
||||
bool isSet = mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(&aNode,
|
||||
aProperty, aAttribute, propertyValue, CSSEditUtils::eSpecified);
|
||||
if (isSet && aNode.IsElement()) {
|
||||
// yes, tmp has the corresponding css declarations in its style attribute
|
||||
// let's remove them
|
||||
mHTMLCSSUtils->RemoveCSSEquivalentToHTMLStyle(aNode.AsElement(),
|
||||
mCSSEditUtils->RemoveCSSEquivalentToHTMLStyle(aNode.AsElement(),
|
||||
aProperty,
|
||||
aAttribute,
|
||||
&propertyValue,
|
||||
|
@ -1001,14 +1002,14 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom& aProperty,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(collapsedNode, &aProperty,
|
||||
if (mCSSEditUtils->IsCSSEditableProperty(collapsedNode, &aProperty,
|
||||
aAttribute)) {
|
||||
if (aValue) {
|
||||
tOutString.Assign(*aValue);
|
||||
}
|
||||
*aFirst = *aAny = *aAll =
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(collapsedNode,
|
||||
&aProperty, aAttribute, tOutString, nsHTMLCSSUtils::eComputed);
|
||||
mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(collapsedNode,
|
||||
&aProperty, aAttribute, tOutString, CSSEditUtils::eComputed);
|
||||
if (outValue) {
|
||||
outValue->Assign(tOutString);
|
||||
}
|
||||
|
@ -1075,7 +1076,7 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom& aProperty,
|
|||
|
||||
bool isSet = false;
|
||||
if (first) {
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(content, &aProperty,
|
||||
if (mCSSEditUtils->IsCSSEditableProperty(content, &aProperty,
|
||||
aAttribute)) {
|
||||
// The HTML styles defined by aProperty/aAttribute have a CSS
|
||||
// equivalence in this implementation for node; let's check if it
|
||||
|
@ -1083,8 +1084,8 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom& aProperty,
|
|||
if (aValue) {
|
||||
firstValue.Assign(*aValue);
|
||||
}
|
||||
isSet = mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(content,
|
||||
&aProperty, aAttribute, firstValue, nsHTMLCSSUtils::eComputed);
|
||||
isSet = mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(content,
|
||||
&aProperty, aAttribute, firstValue, CSSEditUtils::eComputed);
|
||||
} else {
|
||||
isSet = IsTextPropertySetByContent(content, &aProperty, aAttribute,
|
||||
aValue, &firstValue);
|
||||
|
@ -1095,7 +1096,7 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom& aProperty,
|
|||
*outValue = firstValue;
|
||||
}
|
||||
} else {
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(content, &aProperty,
|
||||
if (mCSSEditUtils->IsCSSEditableProperty(content, &aProperty,
|
||||
aAttribute)) {
|
||||
// The HTML styles defined by aProperty/aAttribute have a CSS
|
||||
// equivalence in this implementation for node; let's check if it
|
||||
|
@ -1103,8 +1104,8 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom& aProperty,
|
|||
if (aValue) {
|
||||
theValue.Assign(*aValue);
|
||||
}
|
||||
isSet = mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(content,
|
||||
&aProperty, aAttribute, theValue, nsHTMLCSSUtils::eComputed);
|
||||
isSet = mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(content,
|
||||
&aProperty, aAttribute, theValue, CSSEditUtils::eComputed);
|
||||
} else {
|
||||
isSet = IsTextPropertySetByContent(content, &aProperty, aAttribute,
|
||||
aValue, &theValue);
|
||||
|
@ -1250,18 +1251,18 @@ nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom* aProperty,
|
|||
if (startNode && startNode == endNode && startNode->GetAsText()) {
|
||||
// We're done with this range!
|
||||
if (IsCSSEnabled() &&
|
||||
mHTMLCSSUtils->IsCSSEditableProperty(startNode, aProperty,
|
||||
mCSSEditUtils->IsCSSEditableProperty(startNode, aProperty,
|
||||
aAttribute)) {
|
||||
// The HTML style defined by aProperty/aAttribute has a CSS
|
||||
// equivalence in this implementation for startNode
|
||||
if (mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(startNode,
|
||||
if (mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(startNode,
|
||||
aProperty, aAttribute, EmptyString(),
|
||||
nsHTMLCSSUtils::eComputed)) {
|
||||
CSSEditUtils::eComputed)) {
|
||||
// startNode's computed style indicates the CSS equivalence to the
|
||||
// HTML style to remove is applied; but we found no element in the
|
||||
// ancestors of startNode carrying specified styles; assume it
|
||||
// comes from a rule and try to insert a span "inverting" the style
|
||||
if (mHTMLCSSUtils->IsCSSInvertible(*aProperty, aAttribute)) {
|
||||
if (mCSSEditUtils->IsCSSInvertible(*aProperty, aAttribute)) {
|
||||
NS_NAMED_LITERAL_STRING(value, "-moz-editor-invert-value");
|
||||
SetInlinePropertyOnTextNode(*startNode->GetAsText(),
|
||||
range->StartOffset(),
|
||||
|
@ -1291,17 +1292,17 @@ nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom* aProperty,
|
|||
res = RemoveStyleInside(node, aProperty, aAttribute);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (IsCSSEnabled() &&
|
||||
mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty,
|
||||
mCSSEditUtils->IsCSSEditableProperty(node, aProperty,
|
||||
aAttribute) &&
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node,
|
||||
mCSSEditUtils->IsCSSEquivalentToHTMLInlineStyleSet(node,
|
||||
aProperty, aAttribute, EmptyString(),
|
||||
nsHTMLCSSUtils::eComputed) &&
|
||||
CSSEditUtils::eComputed) &&
|
||||
// startNode's computed style indicates the CSS equivalence to
|
||||
// the HTML style to remove is applied; but we found no element
|
||||
// in the ancestors of startNode carrying specified styles;
|
||||
// assume it comes from a rule and let's try to insert a span
|
||||
// "inverting" the style
|
||||
mHTMLCSSUtils->IsCSSInvertible(*aProperty, aAttribute)) {
|
||||
mCSSEditUtils->IsCSSInvertible(*aProperty, aAttribute)) {
|
||||
NS_NAMED_LITERAL_STRING(value, "-moz-editor-invert-value");
|
||||
SetInlinePropertyOnNode(node, *aProperty, aAttribute, value);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "nsDebug.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsHTMLCSSUtils.h"
|
||||
#include "nsHTMLEditor.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -250,12 +249,12 @@ nsHTMLEditor::SetAllResizersPosition()
|
|||
nsAutoString value;
|
||||
float resizerWidth, resizerHeight;
|
||||
nsCOMPtr<nsIAtom> dummyUnit;
|
||||
mHTMLCSSUtils->GetComputedProperty(*mTopLeftHandle, *nsGkAtoms::width,
|
||||
mCSSEditUtils->GetComputedProperty(*mTopLeftHandle, *nsGkAtoms::width,
|
||||
value);
|
||||
mHTMLCSSUtils->ParseLength(value, &resizerWidth, getter_AddRefs(dummyUnit));
|
||||
mHTMLCSSUtils->GetComputedProperty(*mTopLeftHandle, *nsGkAtoms::height,
|
||||
mCSSEditUtils->ParseLength(value, &resizerWidth, getter_AddRefs(dummyUnit));
|
||||
mCSSEditUtils->GetComputedProperty(*mTopLeftHandle, *nsGkAtoms::height,
|
||||
value);
|
||||
mHTMLCSSUtils->ParseLength(value, &resizerHeight, getter_AddRefs(dummyUnit));
|
||||
mCSSEditUtils->ParseLength(value, &resizerHeight, getter_AddRefs(dummyUnit));
|
||||
|
||||
int32_t rw = (int32_t)((resizerWidth + 1) / 2);
|
||||
int32_t rh = (int32_t)((resizerHeight+ 1) / 2);
|
||||
|
@ -543,9 +542,9 @@ nsHTMLEditor::StartResizing(nsIDOMElement *aHandle)
|
|||
mResizingShadow->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class, true);
|
||||
|
||||
// position it
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::width,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::width,
|
||||
mResizedObjectWidth);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::height,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::height,
|
||||
mResizedObjectHeight);
|
||||
|
||||
// add a mouse move listener to the editor
|
||||
|
@ -673,9 +672,9 @@ nsHTMLEditor::SetResizingInfoPosition(int32_t aX, int32_t aY, int32_t aW, int32_
|
|||
|
||||
// Offset info box by 20 so it's not directly under the mouse cursor.
|
||||
const int mouseCursorOffset = 20;
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mResizingInfo, *nsGkAtoms::left,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizingInfo, *nsGkAtoms::left,
|
||||
infoXPosition + mouseCursorOffset);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mResizingInfo, *nsGkAtoms::top,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizingInfo, *nsGkAtoms::top,
|
||||
infoYPosition + mouseCursorOffset);
|
||||
|
||||
nsCOMPtr<nsIContent> textInfo = mResizingInfo->GetFirstChild();
|
||||
|
@ -829,13 +828,13 @@ nsHTMLEditor::MouseMove(nsIDOMEvent* aMouseEvent)
|
|||
int32_t newWidth = GetNewResizingWidth(clientX, clientY);
|
||||
int32_t newHeight = GetNewResizingHeight(clientX, clientY);
|
||||
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::left,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::left,
|
||||
newX);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::top,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::top,
|
||||
newY);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::width,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::width,
|
||||
newWidth);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::height,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mResizingShadow, *nsGkAtoms::height,
|
||||
newHeight);
|
||||
|
||||
return SetResizingInfoPosition(newX, newY, newWidth, newHeight);
|
||||
|
@ -869,9 +868,9 @@ nsHTMLEditor::MouseMove(nsIDOMEvent* aMouseEvent)
|
|||
|
||||
SnapToGrid(newX, newY);
|
||||
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::left,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::left,
|
||||
newX);
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::top,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::top,
|
||||
newY);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -914,9 +913,9 @@ nsHTMLEditor::SetFinalSize(int32_t aX, int32_t aY)
|
|||
NS_ENSURE_TRUE(resizedObject, );
|
||||
if (mResizedObjectIsAbsolutelyPositioned) {
|
||||
if (setHeight)
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::top, y);
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::top, y);
|
||||
if (setWidth)
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::left, x);
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::left, x);
|
||||
}
|
||||
if (IsCSSEnabled() || mResizedObjectIsAbsolutelyPositioned) {
|
||||
if (setWidth && mResizedObject->HasAttr(kNameSpaceID_None, nsGkAtoms::width)) {
|
||||
|
@ -929,10 +928,10 @@ nsHTMLEditor::SetFinalSize(int32_t aX, int32_t aY)
|
|||
}
|
||||
|
||||
if (setWidth)
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::width,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::width,
|
||||
width);
|
||||
if (setHeight)
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::height,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::height,
|
||||
height);
|
||||
}
|
||||
else {
|
||||
|
@ -942,10 +941,10 @@ nsHTMLEditor::SetFinalSize(int32_t aX, int32_t aY)
|
|||
// triggering an immediate reflow; otherwise, we have problems
|
||||
// with asynchronous reflow
|
||||
if (setWidth)
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::width,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::width,
|
||||
width);
|
||||
if (setHeight)
|
||||
mHTMLCSSUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::height,
|
||||
mCSSEditUtils->SetCSSPropertyPixels(*resizedObject, *nsGkAtoms::height,
|
||||
height);
|
||||
|
||||
if (setWidth) {
|
||||
|
@ -960,10 +959,10 @@ nsHTMLEditor::SetFinalSize(int32_t aX, int32_t aY)
|
|||
}
|
||||
|
||||
if (setWidth)
|
||||
mHTMLCSSUtils->RemoveCSSProperty(*resizedObject, *nsGkAtoms::width,
|
||||
mCSSEditUtils->RemoveCSSProperty(*resizedObject, *nsGkAtoms::width,
|
||||
EmptyString());
|
||||
if (setHeight)
|
||||
mHTMLCSSUtils->RemoveCSSProperty(*resizedObject, *nsGkAtoms::height,
|
||||
mCSSEditUtils->RemoveCSSProperty(*resizedObject, *nsGkAtoms::height,
|
||||
EmptyString());
|
||||
}
|
||||
// finally notify the listeners if any
|
||||
|
|
Загрузка…
Ссылка в новой задаче