mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backout 6ceeca8b4b73 (bug 772332), ce5629b973e4, 1dcff1db63b4, 108d06ef7755 & 7bf6519b3f43 (bug 768756) for bustage
This commit is contained in:
parent
fa64e8311b
commit
53c5da4c5a
@ -17,7 +17,7 @@ using namespace mozilla::dom;
|
||||
|
||||
// Helper function
|
||||
static bool
|
||||
GetCSSComputedValue(Element* aElem,
|
||||
GetCSSComputedValue(nsIContent* aElem,
|
||||
nsCSSProperty aPropID,
|
||||
nsAString& aResult)
|
||||
{
|
||||
@ -40,11 +40,16 @@ GetCSSComputedValue(Element* aElem,
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<nsComputedDOMStyle> computedStyle =
|
||||
NS_NewComputedDOMStyle(aElem, EmptyString(), shell);
|
||||
nsRefPtr<nsComputedDOMStyle> computedStyle;
|
||||
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(aElem));
|
||||
nsresult rv = NS_NewComputedDOMStyle(domElement, EmptyString(), shell,
|
||||
getter_AddRefs(computedStyle));
|
||||
|
||||
computedStyle->GetPropertyValue(aPropID, aResult);
|
||||
return true;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
computedStyle->GetPropertyValue(aPropID, aResult);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Class Methods
|
||||
|
@ -8170,10 +8170,10 @@ nsGlobalWindow::GetComputedStyle(nsIDOMElement* aElt,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<dom::Element> element = do_QueryInterface(aElt);
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
|
||||
nsRefPtr<nsComputedDOMStyle> compStyle =
|
||||
NS_NewComputedDOMStyle(element, aPseudoElt, presShell);
|
||||
nsRefPtr<nsComputedDOMStyle> compStyle;
|
||||
nsresult rv = NS_NewComputedDOMStyle(aElt, aPseudoElt, presShell,
|
||||
getter_AddRefs(compStyle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aReturn = compStyle.forget().get();
|
||||
|
||||
|
@ -48,8 +48,6 @@ CPPSRCS += nsHTMLEditorLog.cpp \
|
||||
DEFINES += -DENABLE_EDITOR_API_LOG
|
||||
endif
|
||||
|
||||
DEFINES += -D_IMPL_NS_LAYOUT
|
||||
|
||||
# don't want the shared lib; force the creation of a static lib.
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
@ -59,5 +57,4 @@ INCLUDES += -I$(topsrcdir)/editor/libeditor/base \
|
||||
-I$(topsrcdir)/editor/libeditor/text \
|
||||
-I$(topsrcdir)/editor/txmgr/src \
|
||||
-I$(topsrcdir)/content/base/src \
|
||||
-I$(topsrcdir)/layout/style \
|
||||
$(NULL)
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsAlgorithm.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditProperty.h"
|
||||
#include "nsEditRules.h"
|
||||
@ -657,9 +656,13 @@ nsHTMLEditor::CheckPositionedElementBGandFG(nsIDOMElement * aElement,
|
||||
bgColorStr);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (bgColorStr.EqualsLiteral("transparent")) {
|
||||
nsRefPtr<nsComputedDOMStyle> cssDecl =
|
||||
mHTMLCSSUtils->GetComputedStyle(aElement);
|
||||
NS_ENSURE_STATE(cssDecl);
|
||||
nsCOMPtr<nsIDOMWindow> window;
|
||||
res = mHTMLCSSUtils->GetDefaultViewCSS(aElement, getter_AddRefs(window));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||
res = window->GetComputedStyle(aElement, EmptyString(), getter_AddRefs(cssDecl));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// from these declarations, get the one we want and that one only
|
||||
nsCOMPtr<nsIDOMCSSValue> colorCssValue;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "nsAString.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditProperty.h"
|
||||
@ -421,10 +420,14 @@ nsHTMLEditor::GetPositionAndDimensions(nsIDOMElement * aElement,
|
||||
// Yes, it is absolutely positioned
|
||||
mResizedObjectIsAbsolutelyPositioned = true;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window;
|
||||
res = mHTMLCSSUtils->GetDefaultViewCSS(aElement, getter_AddRefs(window));
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||
// Get the all the computed css styles attached to the element node
|
||||
nsRefPtr<nsComputedDOMStyle> cssDecl =
|
||||
mHTMLCSSUtils->GetComputedStyle(aElement);
|
||||
NS_ENSURE_STATE(cssDecl);
|
||||
res = window->GetComputedStyle(aElement, EmptyString(), getter_AddRefs(cssDecl));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
aBorderLeft = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("border-left-width"));
|
||||
aBorderTop = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("border-top-width"));
|
||||
|
@ -7,15 +7,12 @@
|
||||
#include "EditTxn.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/css/Declaration.h"
|
||||
#include "mozilla/css/StyleRule.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/mozalloc.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsDependentSubstring.h"
|
||||
@ -573,85 +570,94 @@ nsresult
|
||||
nsHTMLCSSUtils::GetSpecifiedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||
nsAString & aValue)
|
||||
{
|
||||
return GetCSSInlinePropertyBase(aNode, aProperty, aValue, eSpecified);
|
||||
return GetCSSInlinePropertyBase(aNode, aProperty, aValue, nsnull, SPECIFIED_STYLE_TYPE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetComputedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||
nsAString & aValue)
|
||||
{
|
||||
return GetCSSInlinePropertyBase(aNode, aProperty, aValue, eComputed);
|
||||
}
|
||||
nsCOMPtr<nsIDOMWindow> window;
|
||||
nsresult res = GetDefaultViewCSS(aNode, getter_AddRefs(window));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsIDOMNode* aNode, nsIAtom* aProperty,
|
||||
nsAString& aValue,
|
||||
StyleType aStyleType)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return GetCSSInlinePropertyBase(node, aProperty, aValue, aStyleType);
|
||||
return GetCSSInlinePropertyBase(aNode, aProperty, aValue, window, COMPUTED_STYLE_TYPE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
|
||||
nsAString& aValue,
|
||||
StyleType aStyleType)
|
||||
nsIDOMWindow* aWindow,
|
||||
PRUint8 aStyleType)
|
||||
{
|
||||
MOZ_ASSERT(aNode && aProperty);
|
||||
aValue.Truncate();
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode);
|
||||
return GetCSSInlinePropertyBase(node, aProperty, aValue, aWindow, aStyleType);
|
||||
}
|
||||
|
||||
nsCOMPtr<dom::Element> element = GetElementContainerOrSelf(aNode);
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||
nsAString& aValue,
|
||||
nsIDOMWindow* aWindow,
|
||||
PRUint8 aStyleType)
|
||||
{
|
||||
aValue.Truncate();
|
||||
NS_ENSURE_TRUE(aProperty, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> element = GetElementContainerOrSelf(aNode);
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
|
||||
|
||||
if (aStyleType == eComputed) {
|
||||
// Get the all the computed css styles attached to the element node
|
||||
nsRefPtr<nsComputedDOMStyle> cssDecl = GetComputedStyle(element);
|
||||
NS_ENSURE_STATE(cssDecl);
|
||||
|
||||
// from these declarations, get the one we want and that one only
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
|
||||
cssDecl->GetPropertyValue(nsDependentAtomString(aProperty), aValue)));
|
||||
|
||||
return NS_OK;
|
||||
switch (aStyleType) {
|
||||
case COMPUTED_STYLE_TYPE:
|
||||
if (element && aWindow) {
|
||||
nsAutoString value, propString;
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||
aProperty->ToString(propString);
|
||||
// Get the all the computed css styles attached to the element node
|
||||
nsresult res = aWindow->GetComputedStyle(element, EmptyString(), getter_AddRefs(cssDecl));
|
||||
if (NS_FAILED(res) || !cssDecl)
|
||||
return res;
|
||||
// from these declarations, get the one we want and that one only
|
||||
res = cssDecl->GetPropertyValue(propString, value);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
aValue.Assign(value);
|
||||
}
|
||||
break;
|
||||
case SPECIFIED_STYLE_TYPE:
|
||||
if (element) {
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||
PRUint32 length;
|
||||
nsresult res = GetInlineStyles(element, getter_AddRefs(cssDecl), &length);
|
||||
if (NS_FAILED(res) || !cssDecl) return res;
|
||||
nsAutoString value, propString;
|
||||
aProperty->ToString(propString);
|
||||
res = cssDecl->GetPropertyValue(propString, value);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
aValue.Assign(value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aStyleType == eSpecified);
|
||||
nsRefPtr<css::StyleRule> rule = element->GetInlineStyleRule();
|
||||
if (!rule) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCSSProperty prop =
|
||||
nsCSSProps::LookupProperty(nsDependentAtomString(aProperty));
|
||||
MOZ_ASSERT(prop != eCSSProperty_UNKNOWN);
|
||||
rule->GetDeclaration()->GetValue(prop, aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
nsHTMLCSSUtils::GetComputedStyle(nsIDOMElement* aElement)
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetDefaultViewCSS(nsIDOMNode *aNode, nsIDOMWindow **aViewCSS)
|
||||
{
|
||||
nsCOMPtr<dom::Element> element = do_QueryInterface(aElement);
|
||||
return GetComputedStyle(element);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||
return GetDefaultViewCSS(node, aViewCSS);
|
||||
}
|
||||
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
nsHTMLCSSUtils::GetComputedStyle(dom::Element* aElement)
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetDefaultViewCSS(nsINode* aNode, nsIDOMWindow** aViewCSS)
|
||||
{
|
||||
MOZ_ASSERT(aElement);
|
||||
MOZ_ASSERT(aNode);
|
||||
dom::Element* element = GetElementContainerOrSelf(aNode);
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsIDocument* doc = aElement->GetCurrentDoc();
|
||||
NS_ASSERTION(doc, "Trying to compute style of detached element");
|
||||
NS_ENSURE_TRUE(doc, nsnull);
|
||||
|
||||
nsIPresShell* presShell = doc->GetShell();
|
||||
NS_ASSERTION(presShell, "Trying to compute style without PresShell");
|
||||
NS_ENSURE_TRUE(presShell, nsnull);
|
||||
|
||||
nsRefPtr<nsComputedDOMStyle> style =
|
||||
NS_NewComputedDOMStyle(aElement, EmptyString(), presShell);
|
||||
|
||||
return style.forget();
|
||||
nsCOMPtr<nsIDOMWindow> window = element->OwnerDoc()->GetWindow();
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||
window.forget(aViewCSS);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// remove the CSS style "aProperty : aPropertyValue" and possibly remove the whole node
|
||||
@ -1060,7 +1066,7 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
nsIAtom *aHTMLProperty,
|
||||
const nsAString *aAttribute,
|
||||
nsAString & aValueString,
|
||||
StyleType aStyleType)
|
||||
PRUint8 aStyleType)
|
||||
{
|
||||
aValueString.Truncate();
|
||||
nsCOMPtr<dom::Element> theElement = GetElementContainerOrSelf(aNode);
|
||||
@ -1072,6 +1078,12 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
}
|
||||
|
||||
// Yes, the requested HTML style has a CSS equivalence in this implementation
|
||||
// Retrieve the default ViewCSS if we are asked for computed styles
|
||||
nsCOMPtr<nsIDOMWindow> window;
|
||||
if (COMPUTED_STYLE_TYPE == aStyleType) {
|
||||
nsresult res = GetDefaultViewCSS(theElement, getter_AddRefs(window));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
nsTArray<nsIAtom*> cssPropertyArray;
|
||||
nsTArray<nsString> cssValueArray;
|
||||
// get the CSS equivalence with last param true indicating we want only the
|
||||
@ -1083,7 +1095,7 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
nsAutoString valueString;
|
||||
// retrieve the specified/computed value of the property
|
||||
nsresult res = GetCSSInlinePropertyBase(theElement, cssPropertyArray[index],
|
||||
valueString, aStyleType);
|
||||
valueString, window, aStyleType);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
// append the value to aValueString (possibly with a leading whitespace)
|
||||
if (index) {
|
||||
@ -1106,9 +1118,11 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIContent* aContent,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString& aValue,
|
||||
StyleType aStyleType)
|
||||
PRUint8 aStyleType)
|
||||
{
|
||||
MOZ_ASSERT(aContent && aProperty);
|
||||
MOZ_ASSERT(aStyleType == SPECIFIED_STYLE_TYPE ||
|
||||
aStyleType == COMPUTED_STYLE_TYPE);
|
||||
bool isSet;
|
||||
nsAutoString value(aValue);
|
||||
nsresult res = IsCSSEquivalentToHTMLInlineStyleSet(aContent->AsDOMNode(),
|
||||
@ -1125,7 +1139,7 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode *aNode,
|
||||
const nsAString *aHTMLAttribute,
|
||||
bool& aIsSet,
|
||||
nsAString& valueString,
|
||||
StyleType aStyleType)
|
||||
PRUint8 aStyleType)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "prtypes.h" // for PRUint8, PRInt32, PRUint32
|
||||
|
||||
class ChangeCSSInlineStyleTxn;
|
||||
class nsComputedDOMStyle;
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
@ -26,6 +25,9 @@ class Element;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#define SPECIFIED_STYLE_TYPE 1
|
||||
#define COMPUTED_STYLE_TYPE 2
|
||||
|
||||
class nsHTMLEditor;
|
||||
class nsIDOMWindow;
|
||||
|
||||
@ -62,8 +64,6 @@ public:
|
||||
eCSSEditableProperty_width
|
||||
};
|
||||
|
||||
enum StyleType { eSpecified, eComputed };
|
||||
|
||||
|
||||
struct CSSEquivTable {
|
||||
nsCSSEditableProperty cssProperty;
|
||||
@ -176,13 +176,14 @@ public:
|
||||
* @param aHTMLProperty [IN] an atom containing an HTML property
|
||||
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
|
||||
* @param aValueString [OUT] the list of css values
|
||||
* @param aStyleType [IN] eSpecified or eComputed
|
||||
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
|
||||
COMPUTED_STYLE_TYPE to query the computed style values
|
||||
*/
|
||||
nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
nsIAtom * aHTMLProperty,
|
||||
const nsAString * aAttribute,
|
||||
nsAString & aValueString,
|
||||
StyleType aStyleType);
|
||||
PRUint8 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 ?
|
||||
@ -192,7 +193,8 @@ public:
|
||||
* @param aAttribute [IN] a pointer to an attribute name or nsnull 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
|
||||
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
|
||||
* COMPUTED_STYLE_TYPE to query the computed style values
|
||||
*
|
||||
* The nsIContent variant returns aIsSet instead of using an out parameter.
|
||||
*/
|
||||
@ -200,14 +202,14 @@ public:
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString& aValue,
|
||||
StyleType aStyleType);
|
||||
PRUint8 aStyleType);
|
||||
|
||||
nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
|
||||
nsIAtom * aHTMLProperty,
|
||||
const nsAString * aAttribute,
|
||||
bool & aIsSet,
|
||||
nsAString & aValueString,
|
||||
StyleType aStyleType);
|
||||
PRUint8 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
|
||||
@ -305,12 +307,13 @@ public:
|
||||
already_AddRefed<nsIDOMElement> GetElementContainerOrSelf(nsIDOMNode* aNode);
|
||||
|
||||
/**
|
||||
* Gets the computed style for a given element. Can return null.
|
||||
* Gets the default Window for a given node.
|
||||
*
|
||||
* @param aNode the node we want the default Window for
|
||||
* @param aWindow [OUT] the default Window
|
||||
*/
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
GetComputedStyle(nsIDOMElement* aElement);
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
GetComputedStyle(mozilla::dom::Element* aElement);
|
||||
nsresult GetDefaultViewCSS(nsINode* aNode, nsIDOMWindow** aWindow);
|
||||
nsresult GetDefaultViewCSS(nsIDOMNode* aNode, nsIDOMWindow** aWindow);
|
||||
|
||||
|
||||
private:
|
||||
@ -380,12 +383,16 @@ private:
|
||||
* @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
|
||||
* @param aWindow [IN] the window we need in case we query computed styles
|
||||
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
|
||||
* COMPUTED_STYLE_TYPE to query the computed style values
|
||||
*/
|
||||
nsresult GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
|
||||
nsAString& aValue, StyleType aStyleType);
|
||||
nsAString& aValue, nsIDOMWindow* aWindow,
|
||||
PRUint8 aStyleType);
|
||||
nsresult GetCSSInlinePropertyBase(nsIDOMNode* aNode, nsIAtom* aProperty,
|
||||
nsAString& aValue, StyleType aStyleType);
|
||||
nsAString& aValue, nsIDOMWindow* aWindow,
|
||||
PRUint8 aStyleType);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -836,7 +836,7 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
|
||||
// let's get the value(s) of text-align or margin-left/margin-right
|
||||
mHTMLEditor->mHTMLCSSUtils->GetCSSEquivalentToHTMLInlineStyleSet(
|
||||
blockParentContent, dummyProperty, &typeAttrName, value,
|
||||
nsHTMLCSSUtils::eComputed);
|
||||
COMPUTED_STYLE_TYPE);
|
||||
if (value.EqualsLiteral("center") ||
|
||||
value.EqualsLiteral("-moz-center") ||
|
||||
value.EqualsLiteral("auto auto"))
|
||||
@ -2834,8 +2834,10 @@ nsHTMLEditRules::DeleteNonTableElements(nsINode* aNode)
|
||||
return mHTMLEditor->DeleteNode(aNode->AsDOMNode());
|
||||
}
|
||||
|
||||
for (PRInt32 i = aNode->GetChildCount() - 1; i >= 0; --i) {
|
||||
nsresult rv = DeleteNonTableElements(aNode->GetChildAt(i));
|
||||
for (nsCOMPtr<nsIContent> child = aNode->GetLastChild();
|
||||
child;
|
||||
child = child->GetPreviousSibling()) {
|
||||
nsresult rv = DeleteNonTableElements(child);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
return NS_OK;
|
||||
@ -7164,9 +7166,8 @@ nsHTMLEditRules::CacheInlineStyles(nsIDOMNode *aNode)
|
||||
}
|
||||
else
|
||||
{
|
||||
mHTMLEditor->mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(aNode,
|
||||
mCachedStyles[j].tag, &(mCachedStyles[j].attr), isSet, outValue,
|
||||
nsHTMLCSSUtils::eComputed);
|
||||
mHTMLEditor->mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(aNode, mCachedStyles[j].tag, &(mCachedStyles[j].attr),
|
||||
isSet, outValue, COMPUTED_STYLE_TYPE);
|
||||
}
|
||||
if (isSet)
|
||||
{
|
||||
@ -7212,7 +7213,7 @@ nsHTMLEditRules::ReapplyCachedStyles()
|
||||
// check computed style first in css case
|
||||
bAny = mHTMLEditor->mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(
|
||||
selNode, mCachedStyles[i].tag, &(mCachedStyles[i].attr), curValue,
|
||||
nsHTMLCSSUtils::eComputed);
|
||||
COMPUTED_STYLE_TYPE);
|
||||
}
|
||||
if (!bAny) {
|
||||
// then check typeinstate and html style
|
||||
|
@ -357,7 +357,7 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
|
||||
nsAutoString value(*aValue);
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node, aProperty, aAttribute,
|
||||
bHasProp, value,
|
||||
nsHTMLCSSUtils::eComputed);
|
||||
COMPUTED_STYLE_TYPE);
|
||||
} else {
|
||||
IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, bHasProp);
|
||||
}
|
||||
@ -463,7 +463,7 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent* aNode,
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(aNode, aProperty,
|
||||
aAttribute, aValue)) {
|
||||
if (mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(
|
||||
aNode, aProperty, aAttribute, *aValue, nsHTMLCSSUtils::eComputed)) {
|
||||
aNode, aProperty, aAttribute, *aValue, COMPUTED_STYLE_TYPE)) {
|
||||
return NS_OK;
|
||||
}
|
||||
} else if (IsTextPropertySetByContent(aNode, aProperty,
|
||||
@ -649,8 +649,9 @@ nsresult nsHTMLEditor::SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
|
||||
// the HTML style defined by aProperty/aAttribute has a CSS equivalence
|
||||
// in this implementation for the node tmp; let's check if it carries those css styles
|
||||
nsAutoString firstValue;
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(tmp, aProperty,
|
||||
aAttribute, isSet, firstValue, nsHTMLCSSUtils::eSpecified);
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(tmp, aProperty, aAttribute,
|
||||
isSet, firstValue,
|
||||
SPECIFIED_STYLE_TYPE);
|
||||
}
|
||||
if ( (aProperty && NodeIsType(tmp, aProperty)) || // node is the correct inline prop
|
||||
(aProperty == nsEditProperty::href && nsHTMLEditUtils::IsLink(tmp)) ||
|
||||
@ -860,8 +861,9 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
|
||||
// css styles
|
||||
nsAutoString propertyValue;
|
||||
bool isSet;
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(aNode, aProperty,
|
||||
aAttribute, isSet, propertyValue, nsHTMLCSSUtils::eSpecified);
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(aNode, aProperty, aAttribute,
|
||||
isSet, propertyValue,
|
||||
SPECIFIED_STYLE_TYPE);
|
||||
if (isSet) {
|
||||
// yes, tmp has the corresponding css declarations in its style attribute
|
||||
// let's remove them
|
||||
@ -1151,7 +1153,7 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
|
||||
aAttribute)) {
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(
|
||||
collapsedNode, aProperty, aAttribute, isSet, tOutString,
|
||||
nsHTMLCSSUtils::eComputed);
|
||||
COMPUTED_STYLE_TYPE);
|
||||
if (outValue) {
|
||||
outValue->Assign(tOutString);
|
||||
}
|
||||
@ -1243,8 +1245,9 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
|
||||
if (aValue) {
|
||||
firstValue.Assign(*aValue);
|
||||
}
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node, aProperty,
|
||||
aAttribute, isSet, firstValue, nsHTMLCSSUtils::eComputed);
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node, aProperty, aAttribute,
|
||||
isSet, firstValue,
|
||||
COMPUTED_STYLE_TYPE);
|
||||
} else {
|
||||
IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet,
|
||||
&firstValue);
|
||||
@ -1265,8 +1268,9 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
|
||||
if (aValue) {
|
||||
theValue.Assign(*aValue);
|
||||
}
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node, aProperty,
|
||||
aAttribute, isSet, theValue, nsHTMLCSSUtils::eComputed);
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node, aProperty, aAttribute,
|
||||
isSet, theValue,
|
||||
COMPUTED_STYLE_TYPE);
|
||||
} else {
|
||||
IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet,
|
||||
&theValue);
|
||||
@ -1431,8 +1435,11 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
|
||||
nsAutoString cssValue;
|
||||
bool isSet = false;
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(startNode,
|
||||
aProperty, aAttribute, isSet , cssValue,
|
||||
nsHTMLCSSUtils::eComputed);
|
||||
aProperty,
|
||||
aAttribute,
|
||||
isSet ,
|
||||
cssValue,
|
||||
COMPUTED_STYLE_TYPE);
|
||||
if (isSet) {
|
||||
// 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
|
||||
@ -1488,8 +1495,12 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
|
||||
// in this implementation for node
|
||||
nsAutoString cssValue;
|
||||
bool isSet = false;
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node, aProperty,
|
||||
aAttribute, isSet , cssValue, nsHTMLCSSUtils::eComputed);
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node,
|
||||
aProperty,
|
||||
aAttribute,
|
||||
isSet ,
|
||||
cssValue,
|
||||
COMPUTED_STYLE_TYPE);
|
||||
if (isSet) {
|
||||
// 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
|
||||
|
@ -60,9 +60,10 @@ using namespace mozilla::dom;
|
||||
|
||||
static nsComputedDOMStyle *sCachedComputedDOMStyle;
|
||||
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
NS_NewComputedDOMStyle(dom::Element* aElement, const nsAString& aPseudoElt,
|
||||
nsIPresShell* aPresShell)
|
||||
nsresult
|
||||
NS_NewComputedDOMStyle(nsIDOMElement *aElement, const nsAString &aPseudoElt,
|
||||
nsIPresShell *aPresShell,
|
||||
nsComputedDOMStyle **aComputedStyle)
|
||||
{
|
||||
nsRefPtr<nsComputedDOMStyle> computedStyle;
|
||||
if (sCachedComputedDOMStyle) {
|
||||
@ -70,17 +71,23 @@ NS_NewComputedDOMStyle(dom::Element* aElement, const nsAString& aPseudoElt,
|
||||
// But before we use it, re-initialize the object.
|
||||
|
||||
// Oh yeah baby, placement new!
|
||||
computedStyle = new (sCachedComputedDOMStyle)
|
||||
nsComputedDOMStyle(aElement, aPseudoElt, aPresShell);
|
||||
computedStyle = new (sCachedComputedDOMStyle) nsComputedDOMStyle();
|
||||
|
||||
sCachedComputedDOMStyle = nsnull;
|
||||
} else {
|
||||
// No nsComputedDOMStyle cached, create a new one.
|
||||
|
||||
computedStyle = new nsComputedDOMStyle(aElement, aPseudoElt, aPresShell);
|
||||
computedStyle = new nsComputedDOMStyle();
|
||||
NS_ENSURE_TRUE(computedStyle, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
return computedStyle.forget();
|
||||
nsresult rv = computedStyle->Init(aElement, aPseudoElt, aPresShell);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aComputedStyle = nsnull;
|
||||
computedStyle.swap(*aComputedStyle);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsIFrame*
|
||||
@ -91,46 +98,11 @@ GetContainingBlockFor(nsIFrame* aFrame) {
|
||||
return aFrame->GetContainingBlock();
|
||||
}
|
||||
|
||||
nsComputedDOMStyle::nsComputedDOMStyle(dom::Element* aElement,
|
||||
const nsAString& aPseudoElt,
|
||||
nsIPresShell* aPresShell)
|
||||
nsComputedDOMStyle::nsComputedDOMStyle()
|
||||
: mDocumentWeak(nsnull), mOuterFrame(nsnull),
|
||||
mInnerFrame(nsnull), mPresShell(nsnull),
|
||||
mExposeVisitedStyle(false)
|
||||
{
|
||||
MOZ_ASSERT(aElement && aPresShell);
|
||||
|
||||
mDocumentWeak = do_GetWeakReference(aPresShell->GetDocument());
|
||||
|
||||
mContent = aElement;
|
||||
|
||||
if (!DOMStringIsNull(aPseudoElt) && !aPseudoElt.IsEmpty() &&
|
||||
aPseudoElt.First() == PRUnichar(':')) {
|
||||
// deal with two-colon forms of aPseudoElt
|
||||
nsAString::const_iterator start, end;
|
||||
aPseudoElt.BeginReading(start);
|
||||
aPseudoElt.EndReading(end);
|
||||
NS_ASSERTION(start != end, "aPseudoElt is not empty!");
|
||||
++start;
|
||||
bool haveTwoColons = true;
|
||||
if (start == end || *start != PRUnichar(':')) {
|
||||
--start;
|
||||
haveTwoColons = false;
|
||||
}
|
||||
mPseudo = do_GetAtom(Substring(start, end));
|
||||
MOZ_ASSERT(mPseudo);
|
||||
|
||||
// There aren't any non-CSS2 pseudo-elements with a single ':'
|
||||
if (!haveTwoColons &&
|
||||
!nsCSSPseudoElements::IsCSS2PseudoElement(mPseudo)) {
|
||||
// XXXbz I'd really rather we threw an exception or something, but
|
||||
// the DOM spec sucks.
|
||||
mPseudo = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsPresContext *presCtx = aPresShell->GetPresContext();
|
||||
MOZ_ASSERT(presCtx);
|
||||
}
|
||||
|
||||
|
||||
@ -196,6 +168,54 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(nsComputedDOMStyle,
|
||||
doDestroyComputedDOMStyle(this))
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComputedDOMStyle::Init(nsIDOMElement *aElement,
|
||||
const nsAString& aPseudoElt,
|
||||
nsIPresShell *aPresShell)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aElement);
|
||||
NS_ENSURE_ARG_POINTER(aPresShell);
|
||||
|
||||
mDocumentWeak = do_GetWeakReference(aPresShell->GetDocument());
|
||||
|
||||
mContent = do_QueryInterface(aElement);
|
||||
if (!mContent) {
|
||||
// This should not happen, all our elements support nsIContent!
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!DOMStringIsNull(aPseudoElt) && !aPseudoElt.IsEmpty() &&
|
||||
aPseudoElt.First() == PRUnichar(':')) {
|
||||
// deal with two-colon forms of aPseudoElt
|
||||
nsAString::const_iterator start, end;
|
||||
aPseudoElt.BeginReading(start);
|
||||
aPseudoElt.EndReading(end);
|
||||
NS_ASSERTION(start != end, "aPseudoElt is not empty!");
|
||||
++start;
|
||||
bool haveTwoColons = true;
|
||||
if (start == end || *start != PRUnichar(':')) {
|
||||
--start;
|
||||
haveTwoColons = false;
|
||||
}
|
||||
mPseudo = do_GetAtom(Substring(start, end));
|
||||
NS_ENSURE_TRUE(mPseudo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// There aren't any non-CSS2 pseudo-elements with a single ':'
|
||||
if (!haveTwoColons &&
|
||||
!nsCSSPseudoElements::IsCSS2PseudoElement(mPseudo)) {
|
||||
// XXXbz I'd really rather we threw an exception or something, but
|
||||
// the DOM spec sucks.
|
||||
mPseudo = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsPresContext *presCtx = aPresShell->GetPresContext();
|
||||
NS_ENSURE_TRUE(presCtx, NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComputedDOMStyle::GetPropertyValue(const nsCSSProperty aPropID,
|
||||
nsAString& aValue)
|
||||
|
@ -32,13 +32,15 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS_AMBIGUOUS(nsComputedDOMStyle,
|
||||
nsICSSDeclaration)
|
||||
|
||||
NS_IMETHOD Init(nsIDOMElement *aElement,
|
||||
const nsAString& aPseudoElt,
|
||||
nsIPresShell *aPresShell);
|
||||
|
||||
NS_DECL_NSICSSDECLARATION
|
||||
|
||||
NS_DECL_NSIDOMCSSSTYLEDECLARATION
|
||||
|
||||
nsComputedDOMStyle(mozilla::dom::Element* aElement,
|
||||
const nsAString& aPseudoElt,
|
||||
nsIPresShell* aPresShell);
|
||||
nsComputedDOMStyle();
|
||||
virtual ~nsComputedDOMStyle();
|
||||
|
||||
static void Shutdown();
|
||||
@ -509,10 +511,10 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
NS_NewComputedDOMStyle(mozilla::dom::Element* aElement,
|
||||
const nsAString& aPseudoElt,
|
||||
nsIPresShell* aPresShell);
|
||||
nsresult
|
||||
NS_NewComputedDOMStyle(nsIDOMElement *aElement, const nsAString &aPseudoElt,
|
||||
nsIPresShell *aPresShell,
|
||||
nsComputedDOMStyle **aComputedStyle);
|
||||
|
||||
#endif /* nsComputedDOMStyle_h__ */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user