Commit 378d3ead authored by Boris Zbarsky's avatar Boris Zbarsky
Browse files

Bug 700981 part 1. Get rid of nsMappedAttributeElement::BindToTree and inline...

Bug 700981 part 1.  Get rid of nsMappedAttributeElement::BindToTree and inline some of the things it used to call so they're faster.  r=sicking
parent 85ec2311
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -649,7 +649,9 @@ public:
   * Get this document's attribute stylesheet.  May return null if
   * there isn't one.
   */
  virtual nsHTMLStyleSheet* GetAttributeStyleSheet() const = 0;
  nsHTMLStyleSheet* GetAttributeStyleSheet() const {
    return mAttrStyleSheet;
  }

  /**
   * Get this document's inline style sheet.  May return null if there
@@ -1700,6 +1702,7 @@ protected:
  // The cleanup is handled by the nsDocument destructor.
  nsNodeInfoManager* mNodeInfoManager; // [STRONG]
  mozilla::css::Loader* mCSSLoader; // [STRONG]
  nsHTMLStyleSheet* mAttrStyleSheet;

  // The set of all object, embed, applet, video and audio elements for
  // which this is the owner document. (They might not be in the document.)
+4 −3
Original line number Diff line number Diff line
@@ -576,10 +576,11 @@ nsAttrAndChildArray::SetAndTakeMappedAttr(nsIAtom* aLocalName,
}

nsresult
nsAttrAndChildArray::SetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet)
nsAttrAndChildArray::DoSetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet)
{
  if (!mImpl || !mImpl->mMappedAttrs ||
      aSheet == mImpl->mMappedAttrs->GetStyleSheet()) {
  NS_PRECONDITION(mImpl && mImpl->mMappedAttrs,
                  "Should have mapped attrs here!");
  if (aSheet == mImpl->mMappedAttrs->GetStyleSheet()) {
    return NS_OK;
  }

+11 −1
Original line number Diff line number Diff line
@@ -124,7 +124,12 @@ public:
  nsresult SetAndTakeMappedAttr(nsIAtom* aLocalName, nsAttrValue& aValue,
                                nsMappedAttributeElement* aContent,
                                nsHTMLStyleSheet* aSheet);
  nsresult SetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet);
  nsresult SetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet) {
    if (!mImpl || !mImpl->mMappedAttrs) {
      return NS_OK;
    }
    return DoSetMappedAttrStyleSheet(aSheet);
  }
  void WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker);

  void Compact();
@@ -203,6 +208,11 @@ private:
  inline void SetChildAtPos(void** aPos, nsIContent* aChild, PRUint32 aIndex,
                            PRUint32 aChildCount);

  /**
   * Guts of SetMappedAttrStyleSheet for the rare case when we have mapped attrs
   */
  nsresult DoSetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet);

  struct InternalAttr
  {
    nsAttrName mName;
+8 −11
Original line number Diff line number Diff line
@@ -1628,8 +1628,10 @@ nsDocument::~nsDocument()
  while (--indx >= 0) {
    mCatalogSheets[indx]->SetOwningDocument(nsnull);
  }
  if (mAttrStyleSheet)
  if (mAttrStyleSheet) {
    mAttrStyleSheet->SetOwningDocument(nsnull);
    NS_RELEASE(mAttrStyleSheet);
  }
  if (mStyleAttrStyleSheet)
    mStyleAttrStyleSheet->SetOwningDocument(nsnull);

@@ -1653,14 +1655,6 @@ nsDocument::~nsDocument()
    mNodeInfoManager->DropDocumentReference();
  }

  if (mAttrStyleSheet) {
    mAttrStyleSheet->SetOwningDocument(nsnull);
  }
  
  if (mStyleAttrStyleSheet) {
    mStyleAttrStyleSheet->SetOwningDocument(nsnull);
  }

  delete mHeaderData;

  if (mBoxObjectTable) {
@@ -2273,9 +2267,12 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI)
    }
    mAttrStyleSheet->Reset(aURI);
  } else {
    rv = NS_NewHTMLStyleSheet(getter_AddRefs(mAttrStyleSheet), aURI, this);
    rv = NS_NewHTMLStyleSheet(&mAttrStyleSheet, aURI, this);
    if (NS_FAILED(rv)) {
      NS_IF_RELEASE(mAttrStyleSheet);
      NS_ENSURE_SUCCESS(rv, rv);
    }
  }

  // Don't use AddStyleSheet, since it'll put the sheet into style
  // sets in the document level, which is not desirable here.
+0 −9
Original line number Diff line number Diff line
@@ -628,14 +628,6 @@ public:
    return mChannel;
  }

  /**
   * Get this document's attribute stylesheet.  May return null if
   * there isn't one.
   */
  virtual nsHTMLStyleSheet* GetAttributeStyleSheet() const {
    return mAttrStyleSheet;
  }

  /**
   * Get this document's inline style sheet.  May return null if there
   * isn't one
@@ -1200,7 +1192,6 @@ protected:

  // The channel that got passed to StartDocumentLoad(), if any
  nsCOMPtr<nsIChannel> mChannel;
  nsRefPtr<nsHTMLStyleSheet> mAttrStyleSheet;
  nsRefPtr<nsHTMLCSSStyleSheet> mStyleAttrStyleSheet;
  nsRefPtr<nsXMLEventsManager> mXMLEventsManager;

Loading