/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent: */ /* 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/. */
// Return true if the given character is a numeric character staticbool IsDigit(nsDependentSubstring::char_type aChar) { return (aChar >= '0' && aChar <= '9');
}
// Return the index of the first character in the string that is not // a numerical digit, starting from 'aStart'. static uint32_t FirstNonDigit(nsDependentSubstring& aString, uint32_t aStart) { while (aStart < aString.Length() && IsDigit(aString[aStart])) {
++aStart;
} return aStart;
}
// Read and validate coordinates. if (ParseInteger(aString, x) && x >= 0 && ParseCommaSeparator(aString) &&
ParseInteger(aString, y) && y >= 0 && ParseCommaSeparator(aString) &&
ParseInteger(aString, w) && w > 0 && ParseCommaSeparator(aString) &&
ParseInteger(aString, h) && h > 0 && aString.Length() == 0) { // Reject invalid percentage coordinates. if (clipUnit == eClipUnit_Percent && (x + w > 100 || y + h > 100)) { returnfalse;
}
mClip.emplace(x, y, w, h);
mClipUnit = clipUnit; returntrue;
}
returnfalse;
}
void nsMediaFragmentURIParser::Parse(nsACString& aRef) { // Create an array of possibly-invalid media fragments.
nsTArray<std::pair<nsCString, nsCString> > fragments;
for (const nsACString& nv : nsCCharSeparatedTokenizer(aRef, '&').ToRange()) {
int32_t index = nv.FindChar('='); if (index >= 0) {
nsAutoCString name;
nsAutoCString value;
NS_UnescapeURL(StringHead(nv, index), esc_Ref | esc_AlwaysCopy, name);
NS_UnescapeURL(Substring(nv, index + 1, nv.Length()),
esc_Ref | esc_AlwaysCopy, value);
fragments.AppendElement(make_pair(name, value));
}
}
// Parse the media fragment values. bool gotTemporal = false, gotSpatial = false; for (int i = fragments.Length() - 1; i >= 0; --i) { if (gotTemporal && gotSpatial) { // We've got one of each possible type. No need to look at the rest. break;
} if (!gotTemporal && fragments[i].first.EqualsLiteral("t")) {
nsAutoString value = NS_ConvertUTF8toUTF16(fragments[i].second);
gotTemporal = ParseNPT(nsDependentSubstring(value, 0));
} elseif (!gotSpatial && fragments[i].first.EqualsLiteral("xywh")) {
nsAutoString value = NS_ConvertUTF8toUTF16(fragments[i].second);
gotSpatial = ParseXYWH(nsDependentSubstring(value, 0));
}
}
}
} // namespace net
} // namespace mozilla
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.