Bug 1365092 - Move side effects of SetAttr, UnsetAttr, and ParseAttribute functions to BeforeSetAttr and AfterSetAttr r=bz
This is necessary to facilitate the transition to cloning attributes instead of reparsing them. MozReview-Commit-ID: Gyd1tD6ldly
This commit is contained in:
@@ -304,55 +304,6 @@ nsGenericHTMLFrameElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLFrameElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom* aPrefix, const nsAString& aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
|
||||
aValue, aNotify);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::src &&
|
||||
(!IsHTMLElement(nsGkAtoms::iframe) ||
|
||||
!HasAttr(kNameSpaceID_None,nsGkAtoms::srcdoc))) {
|
||||
// Don't propagate error here. The attribute was successfully set, that's
|
||||
// what we should reflect.
|
||||
LoadSrc();
|
||||
} else if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::name) {
|
||||
// Propagate "name" to the docshell to make browsing context names live,
|
||||
// per HTML5.
|
||||
nsIDocShell *docShell = mFrameLoader ? mFrameLoader->GetExistingDocShell()
|
||||
: nullptr;
|
||||
if (docShell) {
|
||||
docShell->SetName(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLFrameElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
||||
bool aNotify)
|
||||
{
|
||||
// Invoke on the superclass.
|
||||
nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::name) {
|
||||
// Propagate "name" to the docshell to make browsing context names live,
|
||||
// per HTML5.
|
||||
nsIDocShell *docShell = mFrameLoader ? mFrameLoader->GetExistingDocShell()
|
||||
: nullptr;
|
||||
if (docShell) {
|
||||
docShell->SetName(EmptyString());
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ int32_t
|
||||
nsGenericHTMLFrameElement::MapScrollingAttribute(const nsAttrValue* aValue)
|
||||
{
|
||||
@@ -385,39 +336,88 @@ nsGenericHTMLFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValue* aValue,
|
||||
const nsAttrValue* aOldValue, bool aNotify)
|
||||
{
|
||||
if (aName == nsGkAtoms::scrolling && aNameSpaceID == kNameSpaceID_None) {
|
||||
if (mFrameLoader) {
|
||||
nsIDocShell* docshell = mFrameLoader->GetExistingDocShell();
|
||||
nsCOMPtr<nsIScrollable> scrollable = do_QueryInterface(docshell);
|
||||
if (scrollable) {
|
||||
int32_t cur;
|
||||
scrollable->GetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X, &cur);
|
||||
int32_t val = MapScrollingAttribute(aValue);
|
||||
if (cur != val) {
|
||||
scrollable->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X, val);
|
||||
scrollable->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, val);
|
||||
RefPtr<nsPresContext> presContext;
|
||||
docshell->GetPresContext(getter_AddRefs(presContext));
|
||||
nsIPresShell* shell = presContext ? presContext->GetPresShell() : nullptr;
|
||||
nsIFrame* rootScroll = shell ? shell->GetRootScrollFrame() : nullptr;
|
||||
if (rootScroll) {
|
||||
shell->FrameNeedsReflow(rootScroll, nsIPresShell::eStyleChange,
|
||||
NS_FRAME_IS_DIRTY);
|
||||
if (aValue) {
|
||||
nsAttrValueOrString value(aValue);
|
||||
AfterMaybeChangeAttr(aNameSpaceID, aName, &value, aNotify);
|
||||
} else {
|
||||
AfterMaybeChangeAttr(aNameSpaceID, aName, nullptr, aNotify);
|
||||
}
|
||||
|
||||
if (aNameSpaceID == kNameSpaceID_None) {
|
||||
if (aName == nsGkAtoms::scrolling) {
|
||||
if (mFrameLoader) {
|
||||
nsIDocShell* docshell = mFrameLoader->GetExistingDocShell();
|
||||
nsCOMPtr<nsIScrollable> scrollable = do_QueryInterface(docshell);
|
||||
if (scrollable) {
|
||||
int32_t cur;
|
||||
scrollable->GetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X, &cur);
|
||||
int32_t val = MapScrollingAttribute(aValue);
|
||||
if (cur != val) {
|
||||
scrollable->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X, val);
|
||||
scrollable->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, val);
|
||||
RefPtr<nsPresContext> presContext;
|
||||
docshell->GetPresContext(getter_AddRefs(presContext));
|
||||
nsIPresShell* shell = presContext ? presContext->GetPresShell() : nullptr;
|
||||
nsIFrame* rootScroll = shell ? shell->GetRootScrollFrame() : nullptr;
|
||||
if (rootScroll) {
|
||||
shell->FrameNeedsReflow(rootScroll, nsIPresShell::eStyleChange,
|
||||
NS_FRAME_IS_DIRTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (aName == nsGkAtoms::mozbrowser) {
|
||||
mReallyIsBrowser = !!aValue && BrowserFramesEnabled() &&
|
||||
PrincipalAllowsBrowserFrame(NodePrincipal());
|
||||
}
|
||||
}
|
||||
|
||||
if (aName == nsGkAtoms::mozbrowser && aNameSpaceID == kNameSpaceID_None) {
|
||||
mReallyIsBrowser = !!aValue && BrowserFramesEnabled() &&
|
||||
PrincipalAllowsBrowserFrame(NodePrincipal());
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue,
|
||||
aOldValue, aNotify);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLFrameElement::OnAttrSetButNotChanged(int32_t aNamespaceID,
|
||||
nsIAtom* aName,
|
||||
const nsAttrValueOrString& aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
AfterMaybeChangeAttr(aNamespaceID, aName, &aValue, aNotify);
|
||||
|
||||
return nsGenericHTMLElement::OnAttrSetButNotChanged(aNamespaceID, aName,
|
||||
aValue, aNotify);
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericHTMLFrameElement::AfterMaybeChangeAttr(int32_t aNamespaceID,
|
||||
nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (aName == nsGkAtoms::src) {
|
||||
if (aValue && (!IsHTMLElement(nsGkAtoms::iframe) ||
|
||||
!HasAttr(kNameSpaceID_None, nsGkAtoms::srcdoc))) {
|
||||
// Don't propagate error here. The attribute was successfully set,
|
||||
// that's what we should reflect.
|
||||
LoadSrc();
|
||||
}
|
||||
} else if (aName == nsGkAtoms::name) {
|
||||
// Propagate "name" to the docshell to make browsing context names live,
|
||||
// per HTML5.
|
||||
nsIDocShell* docShell = mFrameLoader ? mFrameLoader->GetExistingDocShell()
|
||||
: nullptr;
|
||||
if (docShell) {
|
||||
if (aValue) {
|
||||
docShell->SetName(aValue->String());
|
||||
} else {
|
||||
docShell->SetName(EmptyString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericHTMLFrameElement::DestroyContent()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user