2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-05-14 03:42:18 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
1998-05-14 03:42:18 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-05-14 03:42:18 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Contributor(s):
|
2000-02-03 01:24:56 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-02-27 04:35:25 +03:00
|
|
|
|
1998-05-14 03:42:18 +04:00
|
|
|
#include "nsIHTMLCSSStyleSheet.h"
|
|
|
|
#include "nsIArena.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsIURL.h"
|
|
|
|
#include "nsISupportsArray.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSPseudoElements.h"
|
1998-05-14 03:42:18 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
#include "nsIStyleRule.h"
|
1998-05-19 01:11:08 +04:00
|
|
|
#include "nsIFrame.h"
|
1998-09-12 06:46:59 +04:00
|
|
|
#include "nsICSSStyleRule.h"
|
1999-10-08 07:09:31 +04:00
|
|
|
#include "nsIStyleRuleProcessor.h"
|
1998-09-17 04:19:47 +04:00
|
|
|
#include "nsIPresContext.h"
|
1998-11-26 04:34:53 +03:00
|
|
|
#include "nsIDocument.h"
|
2000-03-31 11:08:36 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
|
|
|
#include "nsIStyleSet.h"
|
2001-10-24 04:01:09 +04:00
|
|
|
#include "nsRuleWalker.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
|
1999-04-20 04:28:40 +04:00
|
|
|
class CSSFirstLineRule : public nsIStyleRule {
|
|
|
|
public:
|
|
|
|
CSSFirstLineRule(nsIHTMLCSSStyleSheet* aSheet);
|
|
|
|
virtual ~CSSFirstLineRule();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
// The new mapping function.
|
|
|
|
NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
|
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
1999-04-20 04:28:40 +04:00
|
|
|
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2000-03-31 11:08:36 +04:00
|
|
|
|
1999-04-20 04:28:40 +04:00
|
|
|
nsIHTMLCSSStyleSheet* mSheet;
|
|
|
|
};
|
|
|
|
|
|
|
|
CSSFirstLineRule::CSSFirstLineRule(nsIHTMLCSSStyleSheet* aSheet)
|
|
|
|
: mSheet(aSheet)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CSSFirstLineRule::~CSSFirstLineRule()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-08-21 05:48:11 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(CSSFirstLineRule, nsIStyleRule)
|
1999-04-20 04:28:40 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSFirstLineRule::GetStyleSheet(nsIStyleSheet*& aSheet) const
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(mSheet);
|
|
|
|
aSheet = mSheet;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-06-01 02:19:43 +04:00
|
|
|
CSSFirstLineRule::MapRuleInfoInto(nsRuleData* aData)
|
1999-04-20 04:28:40 +04:00
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!aData)
|
|
|
|
return NS_OK;
|
1999-04-20 04:28:40 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aData->mSID == eStyleStruct_Border && aData->mMarginData) {
|
|
|
|
// Disable the border.
|
|
|
|
nsCSSValue styleVal(NS_STYLE_BORDER_STYLE_NONE, eCSSUnit_Enumerated);
|
|
|
|
if (aData->mMarginData->mBorderStyle->mLeft.GetUnit() == eCSSUnit_Null)
|
|
|
|
aData->mMarginData->mBorderStyle->mLeft = styleVal;
|
|
|
|
if (aData->mMarginData->mBorderStyle->mRight.GetUnit() == eCSSUnit_Null)
|
|
|
|
aData->mMarginData->mBorderStyle->mRight = styleVal;
|
|
|
|
if (aData->mMarginData->mBorderStyle->mTop.GetUnit() == eCSSUnit_Null)
|
|
|
|
aData->mMarginData->mBorderStyle->mTop = styleVal;
|
|
|
|
if (aData->mMarginData->mBorderStyle->mBottom.GetUnit() == eCSSUnit_Null)
|
|
|
|
aData->mMarginData->mBorderStyle->mBottom = styleVal;
|
1999-04-20 04:28:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
1999-04-20 04:28:40 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSFirstLineRule::List(FILE* out, PRInt32 aIndent) const
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2000-03-31 11:08:36 +04:00
|
|
|
|
1999-04-20 04:28:40 +04:00
|
|
|
// -----------------------------------------------------------
|
|
|
|
|
|
|
|
class CSSFirstLetterRule : public CSSFirstLineRule {
|
|
|
|
public:
|
|
|
|
CSSFirstLetterRule(nsIHTMLCSSStyleSheet* aSheet);
|
|
|
|
};
|
|
|
|
|
|
|
|
CSSFirstLetterRule::CSSFirstLetterRule(nsIHTMLCSSStyleSheet* aSheet)
|
|
|
|
: CSSFirstLineRule(aSheet)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------
|
1998-05-14 03:42:18 +04:00
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
class HTMLCSSStyleSheetImpl : public nsIHTMLCSSStyleSheet,
|
|
|
|
public nsIStyleRuleProcessor {
|
1998-05-14 03:42:18 +04:00
|
|
|
public:
|
1998-12-03 23:20:35 +03:00
|
|
|
HTMLCSSStyleSheetImpl();
|
1998-05-14 03:42:18 +04:00
|
|
|
|
2002-10-15 03:57:17 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
1998-05-14 03:42:18 +04:00
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
// basic style sheet data
|
1999-06-23 07:29:44 +04:00
|
|
|
NS_IMETHOD Init(nsIURI* aURL, nsIDocument* aDocument);
|
|
|
|
NS_IMETHOD Reset(nsIURI* aURL);
|
|
|
|
NS_IMETHOD GetURL(nsIURI*& aURL) const;
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHOD GetTitle(nsString& aTitle) const;
|
|
|
|
NS_IMETHOD GetType(nsString& aType) const;
|
|
|
|
NS_IMETHOD GetMediumCount(PRInt32& aCount) const;
|
1998-12-02 03:38:33 +03:00
|
|
|
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const;
|
2001-09-05 04:00:18 +04:00
|
|
|
NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const;
|
1998-11-26 04:34:53 +03:00
|
|
|
|
2002-12-03 08:48:14 +03:00
|
|
|
NS_IMETHOD GetApplicable(PRBool& aApplicable) const;
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHOD SetEnabled(PRBool aEnabled);
|
|
|
|
|
2002-12-03 08:48:14 +03:00
|
|
|
NS_IMETHOD GetComplete(PRBool& aComplete) const;
|
|
|
|
NS_IMETHOD SetComplete();
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
// style sheet owner info
|
|
|
|
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // will be null
|
|
|
|
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const;
|
|
|
|
NS_IMETHOD SetOwningDocument(nsIDocument* aDocument);
|
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
NS_IMETHOD GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor,
|
|
|
|
nsIStyleRuleProcessor* aPrevProcessor);
|
1998-05-14 03:42:18 +04:00
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
// nsIStyleRuleProcessor api
|
2001-11-11 02:51:45 +03:00
|
|
|
NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData,
|
|
|
|
nsIAtom* aMedium);
|
|
|
|
|
|
|
|
NS_IMETHOD RulesMatching(PseudoRuleProcessorData* aData,
|
|
|
|
nsIAtom* aMedium);
|
|
|
|
|
|
|
|
NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
|
2002-04-11 07:49:30 +04:00
|
|
|
nsIAtom* aMedium,
|
|
|
|
PRBool* aResult);
|
1999-04-20 04:05:54 +04:00
|
|
|
|
1998-05-14 03:42:18 +04:00
|
|
|
// XXX style rule enumerations
|
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
1998-05-14 03:42:18 +04:00
|
|
|
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2000-03-31 11:08:36 +04:00
|
|
|
|
2000-05-16 06:43:33 +04:00
|
|
|
// If changing the given attribute cannot affect style context, aAffects
|
|
|
|
// will be PR_FALSE on return.
|
|
|
|
NS_IMETHOD AttributeAffectsStyle(nsIAtom *aAttribute, nsIContent *aContent,
|
|
|
|
PRBool &aAffects);
|
1998-05-14 03:42:18 +04:00
|
|
|
private:
|
|
|
|
// These are not supported and are not implemented!
|
|
|
|
HTMLCSSStyleSheetImpl(const HTMLCSSStyleSheetImpl& aCopy);
|
|
|
|
HTMLCSSStyleSheetImpl& operator=(const HTMLCSSStyleSheetImpl& aCopy);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~HTMLCSSStyleSheetImpl();
|
|
|
|
|
|
|
|
protected:
|
1999-06-23 07:29:44 +04:00
|
|
|
nsIURI* mURL;
|
1998-11-26 04:34:53 +03:00
|
|
|
nsIDocument* mDocument;
|
1999-04-20 04:28:40 +04:00
|
|
|
|
|
|
|
CSSFirstLineRule* mFirstLineRule;
|
1999-04-28 05:16:45 +04:00
|
|
|
CSSFirstLetterRule* mFirstLetterRule;
|
1998-05-14 03:42:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-12-03 23:20:35 +03:00
|
|
|
HTMLCSSStyleSheetImpl::HTMLCSSStyleSheetImpl()
|
1998-05-14 03:42:18 +04:00
|
|
|
: nsIHTMLCSSStyleSheet(),
|
2002-09-17 08:49:28 +04:00
|
|
|
mRefCnt(0),
|
1998-12-03 23:20:35 +03:00
|
|
|
mURL(nsnull),
|
1999-04-20 04:28:40 +04:00
|
|
|
mDocument(nsnull),
|
1999-04-28 05:16:45 +04:00
|
|
|
mFirstLineRule(nsnull),
|
|
|
|
mFirstLetterRule(nsnull)
|
1998-05-14 03:42:18 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
HTMLCSSStyleSheetImpl::~HTMLCSSStyleSheetImpl()
|
|
|
|
{
|
|
|
|
NS_RELEASE(mURL);
|
1999-04-20 04:28:40 +04:00
|
|
|
if (nsnull != mFirstLineRule) {
|
|
|
|
mFirstLineRule->mSheet = nsnull;
|
|
|
|
NS_RELEASE(mFirstLineRule);
|
|
|
|
}
|
1999-04-28 05:16:45 +04:00
|
|
|
if (nsnull != mFirstLetterRule) {
|
|
|
|
mFirstLetterRule->mSheet = nsnull;
|
|
|
|
NS_RELEASE(mFirstLetterRule);
|
|
|
|
}
|
1998-05-14 03:42:18 +04:00
|
|
|
}
|
|
|
|
|
2001-11-11 02:51:45 +03:00
|
|
|
NS_IMPL_ISUPPORTS3(HTMLCSSStyleSheetImpl,
|
|
|
|
nsIHTMLCSSStyleSheet,
|
|
|
|
nsIStyleSheet,
|
|
|
|
nsIStyleRuleProcessor)
|
1998-05-14 03:42:18 +04:00
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLCSSStyleSheetImpl::GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor,
|
|
|
|
nsIStyleRuleProcessor* /*aPrevProcessor*/)
|
|
|
|
{
|
|
|
|
aProcessor = this;
|
|
|
|
NS_ADDREF(aProcessor);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-11-11 02:51:45 +03:00
|
|
|
HTMLCSSStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData,
|
|
|
|
nsIAtom* aMedium)
|
1998-05-14 03:42:18 +04:00
|
|
|
{
|
2001-11-11 02:51:45 +03:00
|
|
|
nsIStyledContent *styledContent = aData->mStyledContent;
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2002-08-16 15:29:20 +04:00
|
|
|
if (styledContent) {
|
2001-06-01 02:19:43 +04:00
|
|
|
// just get the one and only style rule from the content's STYLE attribute
|
2002-08-16 15:29:20 +04:00
|
|
|
nsCOMPtr<nsIStyleRule> rule;
|
|
|
|
styledContent->GetInlineStyleRule(getter_AddRefs(rule));
|
|
|
|
if (rule)
|
|
|
|
aData->mRuleWalker->Forward(rule, PR_TRUE);
|
|
|
|
}
|
1998-05-14 03:42:18 +04:00
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
return NS_OK;
|
1998-05-14 03:42:18 +04:00
|
|
|
}
|
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
NS_IMETHODIMP
|
2001-11-11 02:51:45 +03:00
|
|
|
HTMLCSSStyleSheetImpl::RulesMatching(PseudoRuleProcessorData* aData,
|
|
|
|
nsIAtom* aMedium)
|
1998-05-19 01:11:08 +04:00
|
|
|
{
|
2001-11-11 02:51:45 +03:00
|
|
|
// We only want to add these rules if there are real :first-letter or
|
|
|
|
// :first-line rules that cause a pseudo-element frame to be created.
|
|
|
|
// Otherwise the use of ProbePseudoStyleContextFor will prevent frame
|
|
|
|
// creation, and adding rules here would cause it.
|
|
|
|
if (aData->mRuleWalker->AtRoot())
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsIAtom* pseudoTag = aData->mPseudoTag;
|
2002-11-17 18:37:56 +03:00
|
|
|
if (pseudoTag == nsCSSPseudoElements::firstLine) {
|
2001-11-11 02:51:45 +03:00
|
|
|
if (!mFirstLineRule) {
|
|
|
|
mFirstLineRule = new CSSFirstLineRule(this);
|
|
|
|
if (!mFirstLineRule)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
NS_ADDREF(mFirstLineRule);
|
|
|
|
}
|
|
|
|
aData->mRuleWalker->Forward(mFirstLineRule);
|
1999-04-28 05:16:45 +04:00
|
|
|
}
|
2002-11-17 18:37:56 +03:00
|
|
|
else if (pseudoTag == nsCSSPseudoElements::firstLetter) {
|
2001-11-11 02:51:45 +03:00
|
|
|
if (!mFirstLetterRule) {
|
|
|
|
mFirstLetterRule = new CSSFirstLetterRule(this);
|
|
|
|
if (!mFirstLetterRule)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
NS_ADDREF(mFirstLetterRule);
|
|
|
|
}
|
|
|
|
aData->mRuleWalker->Forward(mFirstLetterRule);
|
|
|
|
}
|
1999-10-08 07:09:31 +04:00
|
|
|
return NS_OK;
|
1998-05-19 01:11:08 +04:00
|
|
|
}
|
|
|
|
|
1998-12-03 23:20:35 +03:00
|
|
|
NS_IMETHODIMP
|
1999-06-23 07:29:44 +04:00
|
|
|
HTMLCSSStyleSheetImpl::Init(nsIURI* aURL, nsIDocument* aDocument)
|
1998-12-03 23:20:35 +03:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aURL && aDocument, "null ptr");
|
|
|
|
if (! aURL || ! aDocument)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
if (mURL || mDocument)
|
|
|
|
return NS_ERROR_ALREADY_INITIALIZED;
|
|
|
|
|
|
|
|
mDocument = aDocument; // not refcounted!
|
|
|
|
mURL = aURL;
|
|
|
|
NS_ADDREF(mURL);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-20 04:05:54 +04:00
|
|
|
// Test if style is dependent on content state
|
|
|
|
NS_IMETHODIMP
|
2001-11-11 02:51:45 +03:00
|
|
|
HTMLCSSStyleSheetImpl::HasStateDependentStyle(StateRuleProcessorData* aData,
|
2002-04-11 07:49:30 +04:00
|
|
|
nsIAtom* aMedium,
|
|
|
|
PRBool* aResult)
|
1999-04-20 04:05:54 +04:00
|
|
|
{
|
2002-04-11 07:49:30 +04:00
|
|
|
*aResult = PR_FALSE;
|
|
|
|
return NS_OK;
|
1999-04-20 04:05:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-02-03 22:38:16 +03:00
|
|
|
NS_IMETHODIMP
|
1999-06-23 07:29:44 +04:00
|
|
|
HTMLCSSStyleSheetImpl::Reset(nsIURI* aURL)
|
1999-02-03 22:38:16 +03:00
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mURL);
|
|
|
|
mURL = aURL;
|
|
|
|
NS_ADDREF(mURL);
|
1999-04-20 04:28:40 +04:00
|
|
|
if (nsnull != mFirstLineRule) {
|
|
|
|
mFirstLineRule->mSheet = nsnull;
|
|
|
|
NS_RELEASE(mFirstLineRule);
|
|
|
|
}
|
1999-04-28 05:16:45 +04:00
|
|
|
if (nsnull != mFirstLetterRule) {
|
|
|
|
mFirstLetterRule->mSheet = nsnull;
|
|
|
|
NS_RELEASE(mFirstLetterRule);
|
|
|
|
}
|
1999-02-03 22:38:16 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHODIMP
|
1999-06-23 07:29:44 +04:00
|
|
|
HTMLCSSStyleSheetImpl::GetURL(nsIURI*& aURL) const
|
1998-05-14 03:42:18 +04:00
|
|
|
{
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IF_ADDREF(mURL);
|
|
|
|
aURL = mURL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLCSSStyleSheetImpl::GetTitle(nsString& aTitle) const
|
|
|
|
{
|
2001-12-16 14:58:03 +03:00
|
|
|
aTitle.Assign(NS_LITERAL_STRING("Internal HTML/CSS Style Sheet"));
|
1998-11-26 04:34:53 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLCSSStyleSheetImpl::GetType(nsString& aType) const
|
|
|
|
{
|
2001-12-16 14:58:03 +03:00
|
|
|
aType.Assign(NS_LITERAL_STRING("text/html"));
|
1998-11-26 04:34:53 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLCSSStyleSheetImpl::GetMediumCount(PRInt32& aCount) const
|
|
|
|
{
|
|
|
|
aCount = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-12-02 03:38:33 +03:00
|
|
|
HTMLCSSStyleSheetImpl::GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const
|
1998-11-26 04:34:53 +03:00
|
|
|
{
|
1998-12-02 03:38:33 +03:00
|
|
|
aMedium = nsnull;
|
1998-11-26 04:34:53 +03:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2001-09-05 04:00:18 +04:00
|
|
|
NS_IMETHODIMP_(PRBool)
|
1999-06-15 10:21:47 +04:00
|
|
|
HTMLCSSStyleSheetImpl::UseForMedium(nsIAtom* aMedium) const
|
|
|
|
{
|
2001-09-05 04:00:18 +04:00
|
|
|
return PR_TRUE; // works for all media
|
1999-06-15 10:21:47 +04:00
|
|
|
}
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHODIMP
|
2002-12-03 08:48:14 +03:00
|
|
|
HTMLCSSStyleSheetImpl::GetApplicable(PRBool& aApplicable) const
|
1998-11-26 04:34:53 +03:00
|
|
|
{
|
2002-12-03 08:48:14 +03:00
|
|
|
aApplicable = PR_TRUE;
|
1998-11-26 04:34:53 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLCSSStyleSheetImpl::SetEnabled(PRBool aEnabled)
|
|
|
|
{ // these can't be disabled
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-12-03 08:48:14 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLCSSStyleSheetImpl::GetComplete(PRBool& aComplete) const
|
|
|
|
{
|
|
|
|
aComplete = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLCSSStyleSheetImpl::SetComplete()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
// style sheet owner info
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLCSSStyleSheetImpl::GetParentSheet(nsIStyleSheet*& aParent) const
|
|
|
|
{
|
|
|
|
aParent = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLCSSStyleSheetImpl::GetOwningDocument(nsIDocument*& aDocument) const
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(mDocument);
|
|
|
|
aDocument = mDocument;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLCSSStyleSheetImpl::SetOwningDocument(nsIDocument* aDocument)
|
|
|
|
{
|
|
|
|
mDocument = aDocument;
|
|
|
|
return NS_OK;
|
1998-05-14 03:42:18 +04:00
|
|
|
}
|
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
1998-05-14 03:42:18 +04:00
|
|
|
void HTMLCSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const
|
|
|
|
{
|
|
|
|
// Indent
|
|
|
|
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
|
|
|
|
|
|
|
|
fputs("HTML CSS Style Sheet: ", out);
|
2002-03-06 10:48:55 +03:00
|
|
|
nsCAutoString urlSpec;
|
|
|
|
mURL->GetSpec(urlSpec);
|
|
|
|
if (!urlSpec.IsEmpty()) {
|
|
|
|
fputs(urlSpec.get(), out);
|
1999-06-28 01:17:39 +04:00
|
|
|
}
|
1998-05-14 03:42:18 +04:00
|
|
|
fputs("\n", out);
|
|
|
|
}
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
1998-12-03 23:20:35 +03:00
|
|
|
|
2000-05-16 06:43:33 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLCSSStyleSheetImpl::AttributeAffectsStyle(nsIAtom *aAttribute,
|
|
|
|
nsIContent *aContent,
|
|
|
|
PRBool &aAffects)
|
|
|
|
{
|
|
|
|
// XXX can attributes affect rules in these?
|
|
|
|
aAffects = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-03 23:20:35 +03:00
|
|
|
// XXX For backwards compatibility and convenience
|
2001-10-20 00:59:33 +04:00
|
|
|
NS_EXPORT nsresult
|
1999-06-23 07:29:44 +04:00
|
|
|
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult, nsIURI* aURL,
|
1998-11-26 04:34:53 +03:00
|
|
|
nsIDocument* aDocument)
|
1998-12-03 23:20:35 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsIHTMLCSSStyleSheet* sheet;
|
|
|
|
if (NS_FAILED(rv = NS_NewHTMLCSSStyleSheet(&sheet)))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
if (NS_FAILED(rv = sheet->Init(aURL, aDocument))) {
|
|
|
|
NS_RELEASE(sheet);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aInstancePtrResult = sheet;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-10-20 00:59:33 +04:00
|
|
|
NS_EXPORT nsresult
|
1998-12-03 23:20:35 +03:00
|
|
|
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult)
|
1998-05-14 03:42:18 +04:00
|
|
|
{
|
|
|
|
if (aInstancePtrResult == nsnull) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
1998-12-03 23:20:35 +03:00
|
|
|
HTMLCSSStyleSheetImpl* it = new HTMLCSSStyleSheetImpl();
|
1998-05-14 03:42:18 +04:00
|
|
|
|
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
1998-12-03 23:20:35 +03:00
|
|
|
NS_ADDREF(it);
|
|
|
|
*aInstancePtrResult = it;
|
|
|
|
return NS_OK;
|
1998-05-14 03:42:18 +04:00
|
|
|
}
|