author | Andrea Marchesini <amarchesini@mozilla.com> |
Tue, 21 May 2013 14:34:36 -0400 | |
changeset 144921 | 68891a4ffce3fe22662bd2de3ceca04f718560d4 |
parent 144920 | 068e9fa85875424ac9fb2eae37def06e77c63ad6 |
child 144922 | e6d64dcaf829e8a76eb4826b18f7422b2cf6bafc |
push id | 368 |
push user | bbajaj@mozilla.com |
push date | Mon, 09 Sep 2013 22:57:58 +0000 |
treeherder | mozilla-release@5a4f47ae1217 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | Ms2ger |
bugs | 869000 |
milestone | 24.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/content/base/src/Text.cpp +++ b/content/base/src/Text.cpp @@ -1,23 +1,37 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/Text.h" +#include "nsTextNode.h" namespace mozilla { namespace dom { already_AddRefed<Text> Text::SplitText(uint32_t aOffset, ErrorResult& rv) { nsCOMPtr<nsIContent> newChild; rv = SplitData(aOffset, getter_AddRefs(newChild)); if (rv.Failed()) { return nullptr; } return newChild.forget().downcast<Text>(); } +/* static */ already_AddRefed<Text> +Text::Constructor(const GlobalObject& aGlobal, const nsAString& aData, + ErrorResult& aRv) +{ + nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get()); + if (!window || !window->GetDoc()) { + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; + } + + return window->GetDoc()->CreateTextNode(aData); +} + } // namespace dom } // namespace mozilla
--- a/content/base/src/Text.h +++ b/content/base/src/Text.h @@ -22,14 +22,18 @@ public: using nsGenericDOMDataNode::GetWholeText; // WebIDL API already_AddRefed<Text> SplitText(uint32_t aOffset, ErrorResult& rv); void GetWholeText(nsAString& aWholeText, ErrorResult& rv) { rv = GetWholeText(aWholeText); } + + static already_AddRefed<Text> + Constructor(const GlobalObject& aGlobal, const nsAString& aData, + ErrorResult& aRv); }; } // namespace dom } // namespace mozilla #endif // mozilla_dom_Text_h
--- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -622,16 +622,17 @@ MOCHITEST_FILES_C= \ test_bothCSPheaders.html \ file_bothCSPheaders.html \ file_bothCSPheaders.html^headers^ \ badMessageEvent2.eventsource \ badMessageEvent2.eventsource^headers^ \ test_object.html \ test_bug869006.html \ test_bug868999.html \ + test_bug869000.html \ $(NULL) # OOP tests don't work on Windows (bug 763081) or native-fennec # (see Bug 774939) ifneq ($(OS_ARCH),WINNT) ifndef MOZ_ANDROID_OMTC MOCHITEST_FILES_B += \ test_messagemanager_assertpermission.html \
new file mode 100644 --- /dev/null +++ b/content/base/test/test_bug869000.html @@ -0,0 +1,37 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=869000 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 869000</title> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=869000">Mozilla Bug 869006</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script type="application/javascript"> + +/** Test for Bug 869000 **/ + +var c = new Text(); +ok(c, "Text has been created without content"); +is(c.data, "", "Text.data is ok"); + +c = new Text('foo'); +ok(c, "Text has been created"); +is(c.data, "foo", "Text.data is ok"); + +document.getElementById('display').appendChild(c); +ok(true, "Text has been added to the document"); + +</script> +</pre> +</body> +</html>
--- a/dom/webidl/Text.webidl +++ b/dom/webidl/Text.webidl @@ -5,14 +5,15 @@ * * The origin of this IDL file is * http://www.w3.org/TR/2012/WD-dom-20120105/ * * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C * liability, trademark and document use rules apply. */ +[Constructor(optional DOMString data = "")] interface Text : CharacterData { [Throws] Text splitText(unsigned long offset); [Throws] readonly attribute DOMString wholeText; };