mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 768756 part 3 - Get rid of nsHTMLCSSUtils::GetDefaultViewCSS; r=ehsan
This commit is contained in:
parent
7070a755d7
commit
6161edba6d
@ -57,4 +57,5 @@ 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,6 +12,7 @@
|
||||
#include "nsAlgorithm.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditProperty.h"
|
||||
#include "nsEditRules.h"
|
||||
@ -656,13 +657,9 @@ nsHTMLEditor::CheckPositionedElementBGandFG(nsIDOMElement * aElement,
|
||||
bgColorStr);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (bgColorStr.EqualsLiteral("transparent")) {
|
||||
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);
|
||||
nsRefPtr<nsComputedDOMStyle> cssDecl =
|
||||
mHTMLCSSUtils->GetComputedStyle(aElement);
|
||||
NS_ENSURE_STATE(cssDecl);
|
||||
|
||||
// from these declarations, get the one we want and that one only
|
||||
nsCOMPtr<nsIDOMCSSValue> colorCssValue;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "nsAString.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditProperty.h"
|
||||
@ -420,14 +421,10 @@ 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
|
||||
res = window->GetComputedStyle(aElement, EmptyString(), getter_AddRefs(cssDecl));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsComputedDOMStyle> cssDecl =
|
||||
mHTMLCSSUtils->GetComputedStyle(aElement);
|
||||
NS_ENSURE_STATE(cssDecl);
|
||||
|
||||
aBorderLeft = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("border-left-width"));
|
||||
aBorderTop = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("border-top-width"));
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsDependentSubstring.h"
|
||||
@ -570,34 +571,28 @@ nsresult
|
||||
nsHTMLCSSUtils::GetSpecifiedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||
nsAString & aValue)
|
||||
{
|
||||
return GetCSSInlinePropertyBase(aNode, aProperty, aValue, nsnull, eSpecified);
|
||||
return GetCSSInlinePropertyBase(aNode, aProperty, aValue, eSpecified);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetComputedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||
nsAString & aValue)
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> window;
|
||||
nsresult res = GetDefaultViewCSS(aNode, getter_AddRefs(window));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
return GetCSSInlinePropertyBase(aNode, aProperty, aValue, window, eComputed);
|
||||
return GetCSSInlinePropertyBase(aNode, aProperty, aValue, eComputed);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
|
||||
nsAString& aValue,
|
||||
nsIDOMWindow* aWindow,
|
||||
StyleType aStyleType)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode);
|
||||
return GetCSSInlinePropertyBase(node, aProperty, aValue, aWindow, aStyleType);
|
||||
return GetCSSInlinePropertyBase(node, aProperty, aValue, aStyleType);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||
nsAString& aValue,
|
||||
nsIDOMWindow* aWindow,
|
||||
StyleType aStyleType)
|
||||
{
|
||||
aValue.Truncate();
|
||||
@ -608,16 +603,14 @@ nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||
|
||||
switch (aStyleType) {
|
||||
case eComputed:
|
||||
if (element && aWindow) {
|
||||
if (element) {
|
||||
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;
|
||||
nsRefPtr<nsComputedDOMStyle> cssDecl = GetComputedStyle(element);
|
||||
NS_ENSURE_STATE(cssDecl);
|
||||
// from these declarations, get the one we want and that one only
|
||||
res = cssDecl->GetPropertyValue(propString, value);
|
||||
nsresult res = cssDecl->GetPropertyValue(propString, value);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
aValue.Assign(value);
|
||||
}
|
||||
@ -639,25 +632,30 @@ nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetDefaultViewCSS(nsIDOMNode *aNode, nsIDOMWindow **aViewCSS)
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
nsHTMLCSSUtils::GetComputedStyle(nsIDOMElement* aElement)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||
return GetDefaultViewCSS(node, aViewCSS);
|
||||
nsCOMPtr<dom::Element> element = do_QueryInterface(aElement);
|
||||
return GetComputedStyle(element);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCSSUtils::GetDefaultViewCSS(nsINode* aNode, nsIDOMWindow** aViewCSS)
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
nsHTMLCSSUtils::GetComputedStyle(dom::Element* aElement)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
dom::Element* element = GetElementContainerOrSelf(aNode);
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
|
||||
MOZ_ASSERT(aElement);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window = element->OwnerDoc()->GetWindow();
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||
window.forget(aViewCSS);
|
||||
return NS_OK;
|
||||
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();
|
||||
}
|
||||
|
||||
// remove the CSS style "aProperty : aPropertyValue" and possibly remove the whole node
|
||||
@ -1078,12 +1076,6 @@ 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 (aStyleType == eComputed) {
|
||||
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
|
||||
@ -1095,7 +1087,7 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
nsAutoString valueString;
|
||||
// retrieve the specified/computed value of the property
|
||||
nsresult res = GetCSSInlinePropertyBase(theElement, cssPropertyArray[index],
|
||||
valueString, window, aStyleType);
|
||||
valueString, aStyleType);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
// append the value to aValueString (possibly with a leading whitespace)
|
||||
if (index) {
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "prtypes.h" // for PRUint8, PRInt32, PRUint32
|
||||
|
||||
class ChangeCSSInlineStyleTxn;
|
||||
class nsComputedDOMStyle;
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
@ -304,13 +305,12 @@ public:
|
||||
already_AddRefed<nsIDOMElement> GetElementContainerOrSelf(nsIDOMNode* aNode);
|
||||
|
||||
/**
|
||||
* Gets the default Window for a given node.
|
||||
*
|
||||
* @param aNode the node we want the default Window for
|
||||
* @param aWindow [OUT] the default Window
|
||||
* Gets the computed style for a given element. Can return null.
|
||||
*/
|
||||
nsresult GetDefaultViewCSS(nsINode* aNode, nsIDOMWindow** aWindow);
|
||||
nsresult GetDefaultViewCSS(nsIDOMNode* aNode, nsIDOMWindow** aWindow);
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
GetComputedStyle(nsIDOMElement* aElement);
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
GetComputedStyle(mozilla::dom::Element* aElement);
|
||||
|
||||
|
||||
private:
|
||||
@ -380,15 +380,12 @@ private:
|
||||
* @param aNode [IN] a DOM node
|
||||
* @param aProperty [IN] a CSS property
|
||||
* @param aValue [OUT] the retrieved value for this property
|
||||
* @param aWindow [IN] the window we need in case we query computed styles
|
||||
* @param aStyleType [IN] eSpecified or eComputed
|
||||
*/
|
||||
nsresult GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
|
||||
nsAString& aValue, nsIDOMWindow* aWindow,
|
||||
StyleType aStyleType);
|
||||
nsAString& aValue, StyleType aStyleType);
|
||||
nsresult GetCSSInlinePropertyBase(nsIDOMNode* aNode, nsIAtom* aProperty,
|
||||
nsAString& aValue, nsIDOMWindow* aWindow,
|
||||
StyleType aStyleType);
|
||||
nsAString& aValue, StyleType aStyleType);
|
||||
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user