From e80ccff07dc8446ca65435e83bb335ae445d8654 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Fri, 10 Apr 2009 13:14:34 +1200 Subject: [PATCH] Bug 486673. elements containing video document should scale the video to fill the document. r+sr=bzbarsky --HG-- extra : rebase_source : c56e1a7c507f5532dacf2c1589428b5b10f0611d --- content/html/document/src/nsVideoDocument.cpp | 16 ++++++++++++++++ .../ogg-video/object-aspect-ratio-1a.xhtml | 14 ++++++++++++++ .../ogg-video/object-aspect-ratio-1b.xhtml | 14 ++++++++++++++ .../ogg-video/object-aspect-ratio-2a.xhtml | 14 ++++++++++++++ .../ogg-video/object-aspect-ratio-2b.xhtml | 14 ++++++++++++++ layout/reftests/ogg-video/reftest.list | 4 ++++ 6 files changed, 76 insertions(+) create mode 100644 layout/reftests/ogg-video/object-aspect-ratio-1a.xhtml create mode 100644 layout/reftests/ogg-video/object-aspect-ratio-1b.xhtml create mode 100644 layout/reftests/ogg-video/object-aspect-ratio-2a.xhtml create mode 100644 layout/reftests/ogg-video/object-aspect-ratio-2b.xhtml diff --git a/content/html/document/src/nsVideoDocument.cpp b/content/html/document/src/nsVideoDocument.cpp index 7ba47c8e8fe1..60506a56dcc9 100644 --- a/content/html/document/src/nsVideoDocument.cpp +++ b/content/html/document/src/nsVideoDocument.cpp @@ -40,6 +40,7 @@ #include "nsNodeInfoManager.h" #include "nsContentCreatorFunctions.h" #include "nsHTMLMediaElement.h" +#include "nsIDocShellTreeItem.h" class nsVideoDocument : public nsMediaDocument { @@ -119,6 +120,21 @@ nsVideoDocument::CreateSyntheticVideoDocument(nsIChannel* aChannel, element->SetControls(PR_TRUE); element->LoadWithChannel(aChannel, aListener); UpdateTitle(aChannel); + + nsCOMPtr container = GetContainer(); + nsCOMPtr docShellAsItem(do_QueryInterface(container)); + nsCOMPtr sameTypeParent; + if (docShellAsItem) { + docShellAsItem->GetSameTypeParent(getter_AddRefs(sameTypeParent)); + } + if (sameTypeParent) { + // Video documents that aren't toplevel should fill their frames and + // not have margins + element->SetAttr(kNameSpaceID_None, nsGkAtoms::style, + NS_LITERAL_STRING("position:absolute; top:0; left:0; width:100%; height:100%"), + PR_TRUE); + } + return body->AppendChildTo(element, PR_FALSE); } diff --git a/layout/reftests/ogg-video/object-aspect-ratio-1a.xhtml b/layout/reftests/ogg-video/object-aspect-ratio-1a.xhtml new file mode 100644 index 000000000000..29fd619fd720 --- /dev/null +++ b/layout/reftests/ogg-video/object-aspect-ratio-1a.xhtml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/layout/reftests/ogg-video/object-aspect-ratio-1b.xhtml b/layout/reftests/ogg-video/object-aspect-ratio-1b.xhtml new file mode 100644 index 000000000000..ea1f02ff7401 --- /dev/null +++ b/layout/reftests/ogg-video/object-aspect-ratio-1b.xhtml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/layout/reftests/ogg-video/object-aspect-ratio-2a.xhtml b/layout/reftests/ogg-video/object-aspect-ratio-2a.xhtml new file mode 100644 index 000000000000..36b4cc0c1e98 --- /dev/null +++ b/layout/reftests/ogg-video/object-aspect-ratio-2a.xhtml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/layout/reftests/ogg-video/object-aspect-ratio-2b.xhtml b/layout/reftests/ogg-video/object-aspect-ratio-2b.xhtml new file mode 100644 index 000000000000..d557921d2fba --- /dev/null +++ b/layout/reftests/ogg-video/object-aspect-ratio-2b.xhtml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/layout/reftests/ogg-video/reftest.list b/layout/reftests/ogg-video/reftest.list index faaef0b8514c..3454e2eca3a1 100644 --- a/layout/reftests/ogg-video/reftest.list +++ b/layout/reftests/ogg-video/reftest.list @@ -9,4 +9,8 @@ random HTTP(..) == canvas-1a.xhtml basic-1-ref.html random HTTP(..) == canvas-1b.xhtml basic-1-ref.html == empty-1a.html empty-1-ref.html == empty-1b.html empty-1-ref.html +HTTP(..) == object-aspect-ratio-1a.xhtml aspect-ratio-1-ref.html +HTTP(..) == object-aspect-ratio-1b.xhtml aspect-ratio-1-ref.html +skip-if(MOZ_WIDGET_TOOLKIT=="gtk2") HTTP(..) == object-aspect-ratio-2a.xhtml aspect-ratio-2-ref.html +skip-if(MOZ_WIDGET_TOOLKIT=="gtk2") HTTP(..) == object-aspect-ratio-2b.xhtml aspect-ratio-2-ref.html skip-if(MOZ_WIDGET_TOOLKIT=="gtk2") HTTP(..) == zoomed-1.xhtml zoomed-1-ref.html