summaryrefslogtreecommitdiff
path: root/dom/html/nsGenericHTMLFrameElement.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 05:33:06 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 05:33:06 -0400
commit17f7e1c8c6fca351174bdbd73981aa8e44d0f9da (patch)
treee8ea42c3121ecd79638172d226a94ad241a21ea9 /dom/html/nsGenericHTMLFrameElement.cpp
parent940d191ef8b61309f4ea83d0fea77828f361251b (diff)
downloaduxp-17f7e1c8c6fca351174bdbd73981aa8e44d0f9da.tar.gz
Bug 1365092 - Move side effects of SetAttr and ParseAttribute to BeforeSetAttr and AfterSetAttr
* Moves side effects of nsGenericHTMLElement and Element's SetAttr, UnsetAttr, and ParseAttribute functions to the corresponding BeforeSetAttr and AfterSetAttr functions * Moves side effects of HTMLAnchorElement's SetAttr, UnsetAttr, and ParseAttribute functions to the corresponding BeforeSetAttr and AfterSetAttr functions * Moves side effects of HTMLImageElement's SetAttr function to the corresponding BeforeSetAttr and AfterSetAttr functions * Moves side effects of SetAttr, UnsetAttr, and ParseAttribute functions to BeforeSetAttr and AfterSetAttr Tag #1375
Diffstat (limited to 'dom/html/nsGenericHTMLFrameElement.cpp')
-rw-r--r--dom/html/nsGenericHTMLFrameElement.cpp144
1 files changed, 72 insertions, 72 deletions
diff --git a/dom/html/nsGenericHTMLFrameElement.cpp b/dom/html/nsGenericHTMLFrameElement.cpp
index 1aeb0a7d2e..03e6ffb421 100644
--- a/dom/html/nsGenericHTMLFrameElement.cpp
+++ b/dom/html/nsGenericHTMLFrameElement.cpp
@@ -334,55 +334,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)
{
@@ -415,39 +366,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()
{