/src/mozilla-central/parser/html/nsHtml5DependentUTF16Buffer.cpp
Line | Count | Source (jump to first uncovered line) |
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/. */ |
4 | | |
5 | | #include "nsHtml5DependentUTF16Buffer.h" |
6 | | |
7 | | nsHtml5DependentUTF16Buffer::nsHtml5DependentUTF16Buffer( |
8 | | const nsAString& aToWrap) |
9 | | : nsHtml5UTF16Buffer(const_cast<char16_t*>(aToWrap.BeginReading()), |
10 | | aToWrap.Length()) |
11 | 0 | { |
12 | 0 | MOZ_COUNT_CTOR(nsHtml5DependentUTF16Buffer); |
13 | 0 | } |
14 | | |
15 | | nsHtml5DependentUTF16Buffer::~nsHtml5DependentUTF16Buffer() |
16 | 0 | { |
17 | 0 | MOZ_COUNT_DTOR(nsHtml5DependentUTF16Buffer); |
18 | 0 | } |
19 | | |
20 | | already_AddRefed<nsHtml5OwningUTF16Buffer> |
21 | | nsHtml5DependentUTF16Buffer::FalliblyCopyAsOwningBuffer() |
22 | 0 | { |
23 | 0 | int32_t newLength = getEnd() - getStart(); |
24 | 0 | RefPtr<nsHtml5OwningUTF16Buffer> newObj = |
25 | 0 | nsHtml5OwningUTF16Buffer::FalliblyCreate(newLength); |
26 | 0 | if (!newObj) { |
27 | 0 | return nullptr; |
28 | 0 | } |
29 | 0 | newObj->setEnd(newLength); |
30 | 0 | memcpy(newObj->getBuffer(), |
31 | 0 | getBuffer() + getStart(), |
32 | 0 | newLength * sizeof(char16_t)); |
33 | 0 | return newObj.forget(); |
34 | 0 | } |