Bug 1704628 Part 4: Avoid use of ESC to close context menu in browser_toolbox_content...
[gecko.git] / parser / html / nsHtml5DependentUTF16Buffer.cpp
blob6372b6923b30b03a5d8e6b33bf29f1443067e563
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsHtml5DependentUTF16Buffer.h"
7 nsHtml5DependentUTF16Buffer::nsHtml5DependentUTF16Buffer(
8 const nsAString& aToWrap)
9 : nsHtml5UTF16Buffer(const_cast<char16_t*>(aToWrap.BeginReading()),
10 aToWrap.Length()) {
11 MOZ_COUNT_CTOR(nsHtml5DependentUTF16Buffer);
14 nsHtml5DependentUTF16Buffer::~nsHtml5DependentUTF16Buffer() {
15 MOZ_COUNT_DTOR(nsHtml5DependentUTF16Buffer);
18 already_AddRefed<nsHtml5OwningUTF16Buffer>
19 nsHtml5DependentUTF16Buffer::FalliblyCopyAsOwningBuffer() {
20 int32_t newLength = getEnd() - getStart();
21 RefPtr<nsHtml5OwningUTF16Buffer> newObj =
22 nsHtml5OwningUTF16Buffer::FalliblyCreate(newLength);
23 if (!newObj) {
24 return nullptr;
26 newObj->setEnd(newLength);
27 memcpy(newObj->getBuffer(), getBuffer() + getStart(),
28 newLength * sizeof(char16_t));
29 return newObj.forget();