Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Static Private Member Functions
nsInspectorCSSUtils Class Reference

#include <nsInspectorCSSUtils.h>

Inheritance diagram for nsInspectorCSSUtils:
Inheritance graph
[legend]
Collaboration diagram for nsInspectorCSSUtils:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsInspectorCSSUtils ()
virtual ~nsInspectorCSSUtils ()
NS_DECL_ISUPPORTS NS_IMETHOD LookupCSSProperty (const nsAString &aName, nsCSSProperty *aProp)
NS_IMETHOD GetRuleNodeParent (nsRuleNode *aNode, nsRuleNode **aParent)
NS_IMETHOD GetRuleNodeRule (nsRuleNode *aNode, nsIStyleRule **aRule)
NS_IMETHOD IsRuleNodeRoot (nsRuleNode *aNode, PRBool *aIsRoot)
NS_IMETHOD AdjustRectForMargins (nsIFrame *aFrame, nsRect &aRect)
NS_IMETHOD GetRuleNodeForContent (nsIContent *aContent, nsRuleNode **aRuleNode)
NS_IMETHOD GetBindingURLs (nsIDOMElement *aElement, nsIArray **aResult)

Static Public Member Functions

static already_AddRefed
< nsStyleContext
GetStyleContextForContent (nsIContent *aContent, nsIAtom *aPseudo, nsIPresShell *aPresShell)

Static Private Member Functions

static nsStyleContextGetStyleContextForFrame (nsIFrame *aFrame)

Detailed Description

Definition at line 49 of file nsInspectorCSSUtils.h.


Constructor & Destructor Documentation

Definition at line 55 of file nsInspectorCSSUtils.cpp.

Here is the call graph for this function:

Definition at line 60 of file nsInspectorCSSUtils.cpp.

Here is the call graph for this function:


Member Function Documentation

Implements nsIInspectorCSSUtils.

Definition at line 97 of file nsInspectorCSSUtils.cpp.

{
    const nsStyleMargin* margins = aFrame->GetStyleMargin();

    // adjust coordinates for margins
    nsStyleCoord coord;
    if (margins->mMargin.GetTopUnit() == eStyleUnit_Coord) {
        margins->mMargin.GetTop(coord);
        aRect.y -= coord.GetCoordValue();
        aRect.height += coord.GetCoordValue();
    }
    if (margins->mMargin.GetLeftUnit() == eStyleUnit_Coord) {
        margins->mMargin.GetLeft(coord);
        aRect.x -= coord.GetCoordValue();
        aRect.width += coord.GetCoordValue();
    }
    if (margins->mMargin.GetRightUnit() == eStyleUnit_Coord) {
        margins->mMargin.GetRight(coord);
        aRect.width += coord.GetCoordValue();
    }
    if (margins->mMargin.GetBottomUnit() == eStyleUnit_Coord) {
        margins->mMargin.GetBottom(coord);
        aRect.height += coord.GetCoordValue();
    }

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsInspectorCSSUtils::GetBindingURLs ( nsIDOMElement aElement,
nsIArray **  aResult 
) [virtual]

Implements nsIInspectorCSSUtils.

Definition at line 207 of file nsInspectorCSSUtils.cpp.

{
    *aResult = nsnull;

    nsCOMArray<nsIURI> urls;

    nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
    NS_ASSERTION(content, "elements must implement nsIContent");

    nsIDocument *ownerDoc = content->GetOwnerDoc();
    if (ownerDoc) {
        nsXBLBinding *binding =
            ownerDoc->BindingManager()->GetBinding(content);

        while (binding) {
            urls.AppendObject(binding->PrototypeBinding()->BindingURI());
            binding = binding->GetBaseBinding();
        }
    }

    nsIMutableArray *mutableResult = nsnull;
    nsresult rv = NS_NewArray(&mutableResult, urls);
    *aResult = mutableResult;
    return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsInspectorCSSUtils::GetRuleNodeForContent ( nsIContent aContent,
nsRuleNode **  aRuleNode 
) [virtual]

Implements nsIInspectorCSSUtils.

Definition at line 189 of file nsInspectorCSSUtils.cpp.

{
    *aRuleNode = nsnull;

    nsIDocument* doc = aContent->GetDocument();
    NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);

    nsIPresShell *presShell = doc->GetShellAt(0);
    NS_ENSURE_TRUE(presShell, NS_ERROR_UNEXPECTED);

    nsRefPtr<nsStyleContext> sContext =
        GetStyleContextForContent(aContent, nsnull, presShell);
    *aRuleNode = sContext->GetRuleNode();
    return NS_OK;
}

Here is the call graph for this function:

Implements nsIInspectorCSSUtils.

Definition at line 75 of file nsInspectorCSSUtils.cpp.

{
    *aParent = aNode->GetParent();
    return NS_OK;
}

Here is the call graph for this function:

Implements nsIInspectorCSSUtils.

Definition at line 82 of file nsInspectorCSSUtils.cpp.

{
    *aRule = aNode->GetRule();
    NS_IF_ADDREF(*aRule);
    return NS_OK;
}

Here is the call graph for this function:

Definition at line 146 of file nsInspectorCSSUtils.cpp.

{
    if (!aPseudo) {
        nsIFrame* frame = nsnull;
        aPresShell->FlushPendingNotifications(Flush_StyleReresolves);
        aPresShell->GetPrimaryFrameFor(aContent, &frame);
        if (frame) {
            nsStyleContext* result = GetStyleContextForFrame(frame);
            // this function returns an addrefed style context
            if (result)
                result->AddRef();
            return result;
        }
    }

    // No frame has been created or we have a pseudo, so resolve the
    // style ourselves
    nsRefPtr<nsStyleContext> parentContext;
    nsIContent* parent = aPseudo ? aContent : aContent->GetParent();
    if (parent)
        parentContext = GetStyleContextForContent(parent, nsnull, aPresShell);

    nsPresContext *presContext = aPresShell->GetPresContext();
    if (!presContext)
        return nsnull;

    nsStyleSet *styleSet = aPresShell->StyleSet();

    if (!aContent->IsContentOfType(nsIContent::eELEMENT)) {
        NS_ASSERTION(!aPseudo, "Shouldn't have a pseudo for a non-element!");
        return styleSet->ResolveStyleForNonElement(parentContext);
    }

    if (aPseudo) {
        return styleSet->ResolvePseudoStyleFor(aContent, aPseudo, parentContext);
    }
    
    return styleSet->ResolveStyleFor(aContent, parentContext);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 127 of file nsInspectorCSSUtils.cpp.

{
    nsStyleContext* styleContext = aFrame->GetStyleContext();
    if (!styleContext)
        return nsnull;

    /* For tables the primary frame is the "outer frame" but the style
     * rules are applied to the "inner frame".  Luckily, the "outer
     * frame" actually inherits style from the "inner frame" so we can
     * just move one level up in the style context hierarchy....
     */
    if (aFrame->GetType() == nsLayoutAtoms::tableOuterFrame)
        return styleContext->GetParent();

    return styleContext;
}    

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsInspectorCSSUtils::IsRuleNodeRoot ( nsRuleNode aNode,
PRBool aIsRoot 
) [virtual]

Implements nsIInspectorCSSUtils.

Definition at line 90 of file nsInspectorCSSUtils.cpp.

{
    *aIsRoot = aNode->IsRoot();
    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsInspectorCSSUtils::LookupCSSProperty ( const nsAString &  aName,
nsCSSProperty aProp 
) [virtual]

Implements nsIInspectorCSSUtils.

Definition at line 68 of file nsInspectorCSSUtils.cpp.

{
    *aProp = nsCSSProps::LookupProperty(aName);
    return NS_OK;
}

Here is the call graph for this function:


The documentation for this class was generated from the following files: