michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "mozilla/dom/Text.h" michael@0: #include "nsTextNode.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: already_AddRefed michael@0: Text::SplitText(uint32_t aOffset, ErrorResult& rv) michael@0: { michael@0: nsCOMPtr newChild; michael@0: rv = SplitData(aOffset, getter_AddRefs(newChild)); michael@0: if (rv.Failed()) { michael@0: return nullptr; michael@0: } michael@0: return newChild.forget().downcast(); michael@0: } michael@0: michael@0: /* static */ already_AddRefed michael@0: Text::Constructor(const GlobalObject& aGlobal, michael@0: const nsAString& aData, ErrorResult& aRv) michael@0: { michael@0: nsCOMPtr window = do_QueryInterface(aGlobal.GetAsSupports()); michael@0: if (!window || !window->GetDoc()) { michael@0: aRv.Throw(NS_ERROR_FAILURE); michael@0: return nullptr; michael@0: } michael@0: michael@0: return window->GetDoc()->CreateTextNode(aData); michael@0: } michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla