From 2fb9924e9919f3ac51ad49fa1dcb33c57ebcc5f0 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Thu, 23 May 2013 03:59:00 -0700 Subject: [PATCH] Bug 869002 - DocumentFragment should be constructable, r=Ms2ger --- content/base/src/DocumentFragment.cpp | 12 ++++++++++ content/base/src/DocumentFragment.h | 3 +++ content/base/test/Makefile.in | 1 + content/base/test/test_bug869002.html | 32 +++++++++++++++++++++++++++ dom/webidl/DocumentFragment.webidl | 1 + 5 files changed, 49 insertions(+) create mode 100644 content/base/test/test_bug869002.html diff --git a/content/base/src/DocumentFragment.cpp b/content/base/src/DocumentFragment.cpp index 24ec3feec720..86859b44d2bc 100644 --- a/content/base/src/DocumentFragment.cpp +++ b/content/base/src/DocumentFragment.cpp @@ -107,6 +107,18 @@ DocumentFragment::DumpContent(FILE* out, int32_t aIndent, } #endif +/* static */ already_AddRefed +DocumentFragment::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) +{ + nsCOMPtr window = do_QueryInterface(aGlobal.Get()); + if (!window || !window->GetDoc()) { + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; + } + + return window->GetDoc()->CreateDocumentFragment(); +} + // QueryInterface implementation for DocumentFragment NS_INTERFACE_MAP_BEGIN(DocumentFragment) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY diff --git a/content/base/src/DocumentFragment.h b/content/base/src/DocumentFragment.h index c64e3fe29fb5..2efb3fed986e 100644 --- a/content/base/src/DocumentFragment.h +++ b/content/base/src/DocumentFragment.h @@ -141,6 +141,9 @@ public: mHost = aHost; } + static already_AddRefed + Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); + #ifdef DEBUG virtual void List(FILE* out, int32_t aIndent) const; virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const; diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index 75449f97c54d..8bb5f9baecef 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -628,6 +628,7 @@ MOCHITEST_FILES_C= \ test_bug869006.html \ test_bug868999.html \ test_bug869000.html \ + test_bug869002.html \ $(NULL) # OOP tests don't work on Windows (bug 763081) or native-fennec diff --git a/content/base/test/test_bug869002.html b/content/base/test/test_bug869002.html new file mode 100644 index 000000000000..a93200a1bf47 --- /dev/null +++ b/content/base/test/test_bug869002.html @@ -0,0 +1,32 @@ + + + + + + Test for Bug 868999 + + + + +Mozilla Bug 869002 +

+ +
+
+
+ + diff --git a/dom/webidl/DocumentFragment.webidl b/dom/webidl/DocumentFragment.webidl index b33a2749bc72..8034ea468d50 100644 --- a/dom/webidl/DocumentFragment.webidl +++ b/dom/webidl/DocumentFragment.webidl @@ -11,6 +11,7 @@ * liability, trademark and document use rules apply. */ +[Constructor] interface DocumentFragment : Node { // NEW /*