зеркало из https://github.com/mozilla/gecko-dev.git
Bug 700981 part 2. Get rid of nsStyledElement::BindToTree/UnbindFromTree. r=smaug
This commit is contained in:
Родитель
378d3ead3e
Коммит
922ddb8a25
|
@ -159,6 +159,8 @@
|
||||||
|
|
||||||
#include "mozilla/CORSMode.h"
|
#include "mozilla/CORSMode.h"
|
||||||
|
|
||||||
|
#include "nsStyledElement.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
|
@ -3214,6 +3216,28 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||||
|
|
||||||
nsNodeUtils::ParentChainChanged(this);
|
nsNodeUtils::ParentChainChanged(this);
|
||||||
|
|
||||||
|
if (aDocument && HasID() && !aBindingParent) {
|
||||||
|
aDocument->AddToIdTable(this, DoGetID());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MayHaveStyle() && !IsXUL()) {
|
||||||
|
// XXXbz if we already have a style attr parsed, this won't do
|
||||||
|
// anything... need to fix that.
|
||||||
|
// If MayHaveStyle() is true, we must be an nsStyledElement
|
||||||
|
static_cast<nsStyledElement*>(this)->ReparseStyleAttribute(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aDocument) {
|
||||||
|
// If we're in a document now, let our mapped attrs know what their new
|
||||||
|
// sheet is. This is safe to run for non-mapped-attribute elements too;
|
||||||
|
// it'll just do a small bit of unnecessary work. But most elements in
|
||||||
|
// practice are mapped-attribute elements.
|
||||||
|
nsHTMLStyleSheet* sheet = aDocument->GetAttributeStyleSheet();
|
||||||
|
if (sheet) {
|
||||||
|
mAttrsAndChildren.SetMappedAttrStyleSheet(sheet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// XXXbz script execution during binding can trigger some of these
|
// XXXbz script execution during binding can trigger some of these
|
||||||
// postcondition asserts.... But we do want that, since things will
|
// postcondition asserts.... But we do want that, since things will
|
||||||
// generally be quite broken when that happens.
|
// generally be quite broken when that happens.
|
||||||
|
@ -3231,6 +3255,9 @@ nsGenericElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||||
NS_PRECONDITION(aDeep || (!GetCurrentDoc() && !GetBindingParent()),
|
NS_PRECONDITION(aDeep || (!GetCurrentDoc() && !GetBindingParent()),
|
||||||
"Shallow unbind won't clear document and binding parent on "
|
"Shallow unbind won't clear document and binding parent on "
|
||||||
"kids!");
|
"kids!");
|
||||||
|
|
||||||
|
RemoveFromIdTable();
|
||||||
|
|
||||||
// Make sure to unbind this node before doing the kids
|
// Make sure to unbind this node before doing the kids
|
||||||
nsIDocument *document =
|
nsIDocument *document =
|
||||||
HasFlag(NODE_FORCE_XBL_BINDINGS) ? OwnerDoc() : GetCurrentDoc();
|
HasFlag(NODE_FORCE_XBL_BINDINGS) ? OwnerDoc() : GetCurrentDoc();
|
||||||
|
|
|
@ -220,51 +220,6 @@ nsStyledElementNotElementCSSInlineStyle::GetInlineStyleRule()
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsStyledElementNotElementCSSInlineStyle::BindToTree(nsIDocument* aDocument,
|
|
||||||
nsIContent* aParent,
|
|
||||||
nsIContent* aBindingParent,
|
|
||||||
bool aCompileEventHandlers)
|
|
||||||
{
|
|
||||||
nsresult rv = nsStyledElementBase::BindToTree(aDocument, aParent,
|
|
||||||
aBindingParent,
|
|
||||||
aCompileEventHandlers);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
if (aDocument && HasID() && !GetBindingParent()) {
|
|
||||||
aDocument->AddToIdTable(this, DoGetID());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsXUL()) {
|
|
||||||
// XXXbz if we already have a style attr parsed, this won't do
|
|
||||||
// anything... need to fix that.
|
|
||||||
ReparseStyleAttribute(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aDocument) {
|
|
||||||
// If we're in a document now, let our mapped attrs know what their new
|
|
||||||
// sheet is. This is safe to run for non-mapped-attribute elements too;
|
|
||||||
// it'll just do a small bit of unnecessary work. But most elements in
|
|
||||||
// practice are mapped-attribute elements.
|
|
||||||
nsHTMLStyleSheet* sheet = aDocument->GetAttributeStyleSheet();
|
|
||||||
if (sheet) {
|
|
||||||
mAttrsAndChildren.SetMappedAttrStyleSheet(sheet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsStyledElementNotElementCSSInlineStyle::UnbindFromTree(bool aDeep,
|
|
||||||
bool aNullParent)
|
|
||||||
{
|
|
||||||
RemoveFromIdTable();
|
|
||||||
|
|
||||||
nsStyledElementBase::UnbindFromTree(aDeep, aNullParent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// Others and helpers
|
// Others and helpers
|
||||||
|
|
||||||
|
|
|
@ -76,11 +76,6 @@ public:
|
||||||
virtual mozilla::css::StyleRule* GetInlineStyleRule();
|
virtual mozilla::css::StyleRule* GetInlineStyleRule();
|
||||||
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, bool aNotify);
|
NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, bool aNotify);
|
||||||
|
|
||||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
||||||
nsIContent* aBindingParent,
|
|
||||||
bool aCompileEventHandlers);
|
|
||||||
virtual void UnbindFromTree(bool aDeep, bool aNullParent);
|
|
||||||
|
|
||||||
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||||
bool aNotify);
|
bool aNotify);
|
||||||
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||||
|
@ -104,6 +99,8 @@ protected:
|
||||||
virtual bool ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute,
|
virtual bool ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute,
|
||||||
const nsAString& aValue, nsAttrValue& aResult);
|
const nsAString& aValue, nsAttrValue& aResult);
|
||||||
|
|
||||||
|
friend class nsGenericElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the style struct from the style attr. Used when an element is
|
* Create the style struct from the style attr. Used when an element is
|
||||||
* first put into a document. Only has an effect if the old value is a
|
* first put into a document. Only has an effect if the old value is a
|
||||||
|
|
Загрузка…
Ссылка в новой задаче