2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "inDOMUtils.h"
|
|
|
|
#include "inLayoutUtils.h"
|
|
|
|
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIDocument.h"
|
2009-08-10 15:52:29 -07:00
|
|
|
#include "nsIPresShell.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMCharacterData.h"
|
|
|
|
#include "nsRuleNode.h"
|
|
|
|
#include "nsIStyleRule.h"
|
2011-03-10 18:48:57 -08:00
|
|
|
#include "mozilla/css/StyleRule.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsICSSStyleRuleDOMWrapper.h"
|
2011-07-15 03:31:34 -07:00
|
|
|
#include "nsIDOMWindow.h"
|
2009-08-10 15:52:29 -07:00
|
|
|
#include "nsXBLBinding.h"
|
|
|
|
#include "nsXBLPrototypeBinding.h"
|
|
|
|
#include "nsIMutableArray.h"
|
|
|
|
#include "nsBindingManager.h"
|
|
|
|
#include "nsComputedDOMStyle.h"
|
2011-04-21 10:35:52 -07:00
|
|
|
#include "nsEventStateManager.h"
|
2011-05-05 14:12:04 -07:00
|
|
|
#include "nsIAtom.h"
|
2012-01-10 06:19:54 -08:00
|
|
|
#include "nsRange.h"
|
2011-07-20 12:18:54 -07:00
|
|
|
#include "mozilla/dom/Element.h"
|
2012-06-03 09:54:38 -07:00
|
|
|
#include "nsCSSStyleSheet.h"
|
2011-07-20 12:18:54 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
inDOMUtils::inDOMUtils()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
inDOMUtils::~inDOMUtils()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(inDOMUtils, inIDOMUtils)
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// inIDOMUtils
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
inDOMUtils::IsIgnorableWhitespace(nsIDOMCharacterData *aDataNode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool *aReturn)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aReturn, "Must have an out parameter");
|
|
|
|
|
2008-12-16 03:26:42 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aDataNode);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
*aReturn = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aDataNode);
|
|
|
|
NS_ASSERTION(content, "Does not implement nsIContent!");
|
|
|
|
|
|
|
|
if (!content->TextIsOnlyWhitespace()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Okay. We have only white space. Let's check the white-space
|
|
|
|
// property now and make sure that this isn't preformatted text...
|
2009-12-24 13:20:06 -08:00
|
|
|
nsIFrame* frame = content->GetPrimaryFrame();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (frame) {
|
|
|
|
const nsStyleText* text = frame->GetStyleText();
|
2008-02-19 18:07:48 -08:00
|
|
|
*aReturn = !text->WhiteSpaceIsSignificant();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// empty inter-tag text node without frame, e.g., in between <table>\n<tr>
|
2011-10-17 07:59:28 -07:00
|
|
|
*aReturn = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
inDOMUtils::GetParentForNode(nsIDOMNode* aNode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aShowingAnonymousContent,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIDOMNode** aParent)
|
|
|
|
{
|
2008-12-16 03:26:42 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aNode);
|
|
|
|
|
|
|
|
// First do the special cases -- document nodes and anonymous content
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDOMDocument> doc(do_QueryInterface(aNode));
|
|
|
|
nsCOMPtr<nsIDOMNode> parent;
|
|
|
|
|
|
|
|
if (doc) {
|
|
|
|
parent = inLayoutUtils::GetContainerFor(doc);
|
|
|
|
} else if (aShowingAnonymousContent) {
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
|
|
|
if (content) {
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIContent* bparent = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRefPtr<nsBindingManager> bindingManager = inLayoutUtils::GetBindingManagerFor(aNode);
|
|
|
|
if (bindingManager) {
|
|
|
|
bparent = bindingManager->GetInsertionParent(content);
|
|
|
|
}
|
2012-05-09 09:23:57 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
parent = do_QueryInterface(bparent);
|
|
|
|
}
|
|
|
|
}
|
2012-05-09 09:23:57 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!parent) {
|
|
|
|
// Ok, just get the normal DOM parent node
|
|
|
|
aNode->GetParentNode(getter_AddRefs(parent));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IF_ADDREF(*aParent = parent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-30 14:51:09 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
inDOMUtils::GetChildrenForNode(nsIDOMNode* aNode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aShowingAnonymousContent,
|
2011-05-30 14:51:09 -07:00
|
|
|
nsIDOMNodeList** aChildren)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aNode);
|
|
|
|
NS_PRECONDITION(aChildren, "Must have an out parameter");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNodeList> kids;
|
|
|
|
|
|
|
|
if (aShowingAnonymousContent) {
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
|
|
|
if (content) {
|
|
|
|
nsRefPtr<nsBindingManager> bindingManager =
|
|
|
|
inLayoutUtils::GetBindingManagerFor(aNode);
|
|
|
|
if (bindingManager) {
|
|
|
|
bindingManager->GetAnonymousNodesFor(content, getter_AddRefs(kids));
|
|
|
|
if (!kids) {
|
|
|
|
bindingManager->GetContentListFor(content, getter_AddRefs(kids));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!kids) {
|
|
|
|
aNode->GetChildNodes(getter_AddRefs(kids));
|
|
|
|
}
|
|
|
|
|
|
|
|
kids.forget(aChildren);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
|
2011-05-05 14:12:04 -07:00
|
|
|
const nsAString& aPseudo,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsISupportsArray **_retval)
|
|
|
|
{
|
2008-12-16 03:26:42 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aElement);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
*_retval = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-05-05 14:12:04 -07:00
|
|
|
nsCOMPtr<nsIAtom> pseudoElt;
|
|
|
|
if (!aPseudo.IsEmpty()) {
|
|
|
|
pseudoElt = do_GetAtom(aPseudo);
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
nsRuleNode* ruleNode = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
|
2012-06-06 12:59:57 -07:00
|
|
|
NS_ENSURE_STATE(content);
|
2009-11-24 21:35:55 -08:00
|
|
|
nsRefPtr<nsStyleContext> styleContext;
|
2011-05-05 14:12:04 -07:00
|
|
|
GetRuleNodeForContent(content, pseudoElt, getter_AddRefs(styleContext), &ruleNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!ruleNode) {
|
|
|
|
// This can fail for content nodes that are not in the document or
|
|
|
|
// if the document they're in doesn't have a presshell. Bail out.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsArray> rules;
|
|
|
|
NS_NewISupportsArray(getter_AddRefs(rules));
|
|
|
|
if (!rules) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2011-03-10 18:48:57 -08:00
|
|
|
nsRefPtr<mozilla::css::StyleRule> cssRule;
|
2009-08-10 15:52:29 -07:00
|
|
|
for ( ; !ruleNode->IsRoot(); ruleNode = ruleNode->GetParent()) {
|
2011-03-10 18:48:57 -08:00
|
|
|
cssRule = do_QueryObject(ruleNode->GetRule());
|
2007-03-22 10:30:00 -07:00
|
|
|
if (cssRule) {
|
2011-04-07 23:36:09 -07:00
|
|
|
nsCOMPtr<nsIDOMCSSRule> domRule = cssRule->GetDOMRule();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (domRule)
|
|
|
|
rules->InsertElementAt(domRule, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*_retval = rules;
|
|
|
|
NS_ADDREF(*_retval);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
inDOMUtils::GetRuleLine(nsIDOMCSSStyleRule *aRule, uint32_t *_retval)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*_retval = 0;
|
2008-12-16 03:26:42 -08:00
|
|
|
|
|
|
|
NS_ENSURE_ARG_POINTER(aRule);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsICSSStyleRuleDOMWrapper> rule = do_QueryInterface(aRule);
|
2011-03-10 18:48:57 -08:00
|
|
|
nsRefPtr<mozilla::css::StyleRule> cssrule;
|
2008-12-16 03:26:42 -08:00
|
|
|
nsresult rv = rule->GetCSSStyleRule(getter_AddRefs(cssrule));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(cssrule != nullptr, NS_ERROR_FAILURE);
|
2008-12-16 03:26:42 -08:00
|
|
|
*_retval = cssrule->GetLineNumber();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-05 08:41:10 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
inDOMUtils::IsInheritedProperty(const nsAString &aPropertyName, bool *_retval)
|
|
|
|
{
|
2012-07-13 16:59:05 -07:00
|
|
|
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName,
|
|
|
|
nsCSSProps::eAny);
|
2011-11-05 08:41:10 -07:00
|
|
|
if (prop == eCSSProperty_UNKNOWN) {
|
|
|
|
*_retval = false;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsCSSProps::IsShorthand(prop)) {
|
|
|
|
prop = nsCSSProps::SubpropertyEntryFor(prop)[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleStructID sid = nsCSSProps::kSIDTable[prop];
|
|
|
|
*_retval = !nsCachedStyleData::IsReset(sid);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-09 09:23:57 -07:00
|
|
|
NS_IMETHODIMP
|
2007-03-22 10:30:00 -07:00
|
|
|
inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsIArray **_retval)
|
|
|
|
{
|
2008-12-16 03:26:42 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aElement);
|
2009-08-10 15:52:29 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
*_retval = nullptr;
|
2009-08-10 15:52:29 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIMutableArray> urls = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
|
|
|
if (!urls)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
|
2012-11-16 15:35:06 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(content);
|
2009-08-10 15:52:29 -07:00
|
|
|
|
2011-10-18 03:53:36 -07:00
|
|
|
nsIDocument *ownerDoc = content->OwnerDoc();
|
2011-10-18 04:19:44 -07:00
|
|
|
nsXBLBinding *binding = ownerDoc->BindingManager()->GetBinding(content);
|
2009-08-10 15:52:29 -07:00
|
|
|
|
2011-10-18 04:19:44 -07:00
|
|
|
while (binding) {
|
|
|
|
urls->AppendElement(binding->PrototypeBinding()->BindingURI(), false);
|
|
|
|
binding = binding->GetBaseBinding();
|
2009-08-10 15:52:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ADDREF(*_retval = urls);
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-10-20 04:26:32 -07:00
|
|
|
inDOMUtils::SetContentState(nsIDOMElement *aElement, nsEventStates::InternalType aState)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-12-16 03:26:42 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aElement);
|
2012-05-09 09:23:57 -07:00
|
|
|
|
2011-04-21 10:35:52 -07:00
|
|
|
nsRefPtr<nsEventStateManager> esm = inLayoutUtils::GetEventStateManagerFor(aElement);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (esm) {
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
content = do_QueryInterface(aElement);
|
2012-05-09 09:23:57 -07:00
|
|
|
|
2012-07-27 07:03:25 -07:00
|
|
|
// XXX Invalid cast of bool to nsresult (bug 778108)
|
|
|
|
return (nsresult)esm->SetContentState(content, nsEventStates(aState));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-05-09 09:23:57 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-10-20 04:26:32 -07:00
|
|
|
inDOMUtils::GetContentState(nsIDOMElement *aElement, nsEventStates::InternalType* aState)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*aState = 0;
|
2011-05-31 18:46:56 -07:00
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
|
|
|
|
NS_ENSURE_ARG_POINTER(content);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-05-31 18:46:56 -07:00
|
|
|
// NOTE: if this method is removed,
|
|
|
|
// please remove GetInternalValue from nsEventStates
|
|
|
|
*aState = content->AsElement()->State().GetInternalValue();
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-08-10 15:52:29 -07:00
|
|
|
/* static */ nsresult
|
2009-11-24 21:35:55 -08:00
|
|
|
inDOMUtils::GetRuleNodeForContent(nsIContent* aContent,
|
2011-05-05 14:12:04 -07:00
|
|
|
nsIAtom* aPseudo,
|
2009-11-24 21:35:55 -08:00
|
|
|
nsStyleContext** aStyleContext,
|
|
|
|
nsRuleNode** aRuleNode)
|
2009-08-10 15:52:29 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aRuleNode = nullptr;
|
|
|
|
*aStyleContext = nullptr;
|
2009-08-10 15:52:29 -07:00
|
|
|
|
2010-04-30 06:12:06 -07:00
|
|
|
if (!aContent->IsElement()) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2009-08-10 15:52:29 -07:00
|
|
|
nsIDocument* doc = aContent->GetDocument();
|
|
|
|
NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2010-06-25 06:59:57 -07:00
|
|
|
nsIPresShell *presShell = doc->GetShell();
|
2009-08-10 15:52:29 -07:00
|
|
|
NS_ENSURE_TRUE(presShell, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2009-12-31 07:56:33 -08:00
|
|
|
nsPresContext *presContext = presShell->GetPresContext();
|
|
|
|
NS_ENSURE_TRUE(presContext, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool safe = presContext->EnsureSafeToHandOutCSSRules();
|
2009-12-31 07:56:33 -08:00
|
|
|
NS_ENSURE_TRUE(safe, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
2009-08-10 15:52:29 -07:00
|
|
|
nsRefPtr<nsStyleContext> sContext =
|
2011-05-05 14:12:04 -07:00
|
|
|
nsComputedDOMStyle::GetStyleContextForElement(aContent->AsElement(), aPseudo, presShell);
|
|
|
|
if (sContext) {
|
|
|
|
*aRuleNode = sContext->GetRuleNode();
|
|
|
|
sContext.forget(aStyleContext);
|
|
|
|
}
|
2009-08-10 15:52:29 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-06-15 23:31:36 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
inDOMUtils::GetUsedFontFaces(nsIDOMRange* aRange,
|
|
|
|
nsIDOMFontFaceList** aFontFaceList)
|
|
|
|
{
|
2012-01-10 06:19:54 -08:00
|
|
|
return static_cast<nsRange*>(aRange)->GetUsedFontFaces(aFontFaceList);
|
2011-06-15 23:31:36 -07:00
|
|
|
}
|
2012-02-08 10:42:38 -08:00
|
|
|
|
|
|
|
static nsEventStates
|
|
|
|
GetStatesForPseudoClass(const nsAString& aStatePseudo)
|
|
|
|
{
|
|
|
|
// An array of the states that are relevant for various pseudoclasses.
|
|
|
|
// XXXbz this duplicates code in nsCSSRuleProcessor
|
|
|
|
static const nsEventStates sPseudoClassStates[] = {
|
|
|
|
#define CSS_PSEUDO_CLASS(_name, _value) \
|
|
|
|
nsEventStates(),
|
|
|
|
#define CSS_STATE_PSEUDO_CLASS(_name, _value, _states) \
|
|
|
|
_states,
|
|
|
|
#include "nsCSSPseudoClassList.h"
|
|
|
|
#undef CSS_STATE_PSEUDO_CLASS
|
|
|
|
#undef CSS_PSEUDO_CLASS
|
|
|
|
|
|
|
|
// Add more entries for our fake values to make sure we can't
|
|
|
|
// index out of bounds into this array no matter what.
|
|
|
|
nsEventStates(),
|
|
|
|
nsEventStates()
|
|
|
|
};
|
2012-04-02 17:21:24 -07:00
|
|
|
MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(sPseudoClassStates) ==
|
|
|
|
nsCSSPseudoClasses::ePseudoClass_NotPseudoClass + 1,
|
|
|
|
"Length of PseudoClassStates array is incorrect");
|
2012-02-08 10:42:38 -08:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAtom> atom = do_GetAtom(aStatePseudo);
|
|
|
|
|
|
|
|
// Ignore :moz-any-link so we don't give the element simultaneous
|
|
|
|
// visited and unvisited style state
|
|
|
|
if (nsCSSPseudoClasses::GetPseudoType(atom) ==
|
|
|
|
nsCSSPseudoClasses::ePseudoClass_mozAnyLink) {
|
|
|
|
return nsEventStates();
|
|
|
|
}
|
|
|
|
// Our array above is long enough that indexing into it with
|
|
|
|
// NotPseudoClass is ok.
|
|
|
|
return sPseudoClassStates[nsCSSPseudoClasses::GetPseudoType(atom)];
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
inDOMUtils::AddPseudoClassLock(nsIDOMElement *aElement,
|
|
|
|
const nsAString &aPseudoClass)
|
|
|
|
{
|
|
|
|
nsEventStates state = GetStatesForPseudoClass(aPseudoClass);
|
|
|
|
if (state.IsEmpty()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(aElement);
|
2012-05-09 09:23:57 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(element);
|
|
|
|
|
2012-02-08 10:42:38 -08:00
|
|
|
element->LockStyleStates(state);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
inDOMUtils::RemovePseudoClassLock(nsIDOMElement *aElement,
|
|
|
|
const nsAString &aPseudoClass)
|
|
|
|
{
|
|
|
|
nsEventStates state = GetStatesForPseudoClass(aPseudoClass);
|
|
|
|
if (state.IsEmpty()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(aElement);
|
2012-05-09 09:23:57 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(element);
|
|
|
|
|
2012-02-08 10:42:38 -08:00
|
|
|
element->UnlockStyleStates(state);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
inDOMUtils::HasPseudoClassLock(nsIDOMElement *aElement,
|
|
|
|
const nsAString &aPseudoClass,
|
|
|
|
bool *_retval)
|
|
|
|
{
|
|
|
|
nsEventStates state = GetStatesForPseudoClass(aPseudoClass);
|
|
|
|
if (state.IsEmpty()) {
|
|
|
|
*_retval = false;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(aElement);
|
2012-05-09 09:23:57 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(element);
|
|
|
|
|
2012-02-08 10:42:38 -08:00
|
|
|
nsEventStates locks = element->LockedStyleStates();
|
|
|
|
|
|
|
|
*_retval = locks.HasAllStates(state);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
inDOMUtils::ClearPseudoClassLocks(nsIDOMElement *aElement)
|
|
|
|
{
|
|
|
|
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(aElement);
|
2012-05-09 09:23:57 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(element);
|
|
|
|
|
2012-02-08 10:42:38 -08:00
|
|
|
element->ClearStyleStateLocks();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-06-03 09:54:38 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
inDOMUtils::ParseStyleSheet(nsIDOMCSSStyleSheet *aSheet,
|
|
|
|
const nsAString& aInput)
|
|
|
|
{
|
|
|
|
nsRefPtr<nsCSSStyleSheet> sheet = do_QueryObject(aSheet);
|
|
|
|
NS_ENSURE_ARG_POINTER(sheet);
|
|
|
|
|
|
|
|
return sheet->ParseSheet(aInput);
|
|
|
|
}
|