Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/xslt/base/txExpandedName.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "txExpandedName.h"
7
#include "nsString.h"
8
#include "nsReadableUtils.h"
9
#include "txStringUtils.h"
10
#include "txNamespaceMap.h"
11
#include "txXMLUtils.h"
12
13
nsresult
14
txExpandedName::init(const nsAString& aQName, txNamespaceMap* aResolver,
15
                     bool aUseDefault)
16
0
{
17
0
    const nsString& qName = PromiseFlatString(aQName);
18
0
    const char16_t* colon;
19
0
    bool valid = XMLUtils::isValidQName(qName, &colon);
20
0
    if (!valid) {
21
0
        return NS_ERROR_FAILURE;
22
0
    }
23
0
24
0
    if (colon) {
25
0
        RefPtr<nsAtom> prefix = NS_Atomize(Substring(qName.get(), colon));
26
0
        int32_t namespaceID = aResolver->lookupNamespace(prefix);
27
0
        if (namespaceID == kNameSpaceID_Unknown)
28
0
            return NS_ERROR_FAILURE;
29
0
        mNamespaceID = namespaceID;
30
0
31
0
        const char16_t *end;
32
0
        qName.EndReading(end);
33
0
        mLocalName = NS_Atomize(Substring(colon + 1, end));
34
0
    }
35
0
    else {
36
0
        mNamespaceID = aUseDefault ? aResolver->lookupNamespace(nullptr) :
37
0
                                     kNameSpaceID_None;
38
0
        mLocalName = NS_Atomize(aQName);
39
0
    }
40
0
    return NS_OK;
41
0
}