bool elementPatternIndicatesHexadecimal(const HTMLInputElement* inputElement) { if (!inputElement) return false; if (inputElement->fastHasAttribute(HTMLNames::patternAttr)) { AtomicString patternAttribute = inputElement->fastGetAttribute(HTMLNames::patternAttr); if (patternAttribute.startsWith("[0-9a-fA-F]")) { // The pattern is for hexadecimal, make sure nothing else is permitted. // Check if it was an exact match. if (patternAttribute.length() == 11) return true; // Is the regex specifying a character count? if (patternAttribute[11] != '{' || !patternAttribute.endsWith("}")) return false; int count = 0; // Make sure the number in the regex is actually a number. if ((sscanf(patternAttribute.string().latin1().data(), "[0-9a-fA-F]{%d}\0", &count) == 1) && count > 0) return true; } } return false; }
static bool typefacesHasWeightSuffix(const AtomicString& family, AtomicString& adjustedName, FontWeight& variantWeight) { struct FamilyWeightSuffix { const wchar_t* suffix; size_t length; FontWeight weight; }; // Mapping from suffix to weight from the DirectWrite documentation. // http://msdn.microsoft.com/en-us/library/windows/desktop/dd368082.aspx const static FamilyWeightSuffix variantForSuffix[] = { {L" thin", 5, FontWeight100}, {L" extralight", 11, FontWeight200}, {L" ultralight", 11, FontWeight200}, {L" light", 6, FontWeight300}, {L" regular", 8, FontWeight400}, {L" medium", 7, FontWeight500}, {L" demibold", 9, FontWeight600}, {L" semibold", 9, FontWeight600}, {L" extrabold", 10, FontWeight800}, {L" ultrabold", 10, FontWeight800}, {L" black", 6, FontWeight900}, {L" heavy", 6, FontWeight900}}; size_t numVariants = WTF_ARRAY_LENGTH(variantForSuffix); for (size_t i = 0; i < numVariants; i++) { const FamilyWeightSuffix& entry = variantForSuffix[i]; if (family.endsWith(entry.suffix, TextCaseUnicodeInsensitive)) { String familyName = family.getString(); familyName.truncate(family.length() - entry.length); adjustedName = AtomicString(familyName); variantWeight = entry.weight; return true; } } return false; }
void SVGStopElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (!isSupportedAttribute(name)) { SVGElement::parseAttribute(name, value); return; } if (name == SVGNames::offsetAttr) { if (value.endsWith('%')) setOffsetBaseValue(value.string().left(value.length() - 1).toFloat() / 100.0f); else setOffsetBaseValue(value.toFloat()); return; } ASSERT_NOT_REACHED(); }
static bool typefacesHasStretchSuffix(const AtomicString& family, AtomicString& adjustedName, FontStretch& variantStretch) { struct FamilyStretchSuffix { const wchar_t* suffix; size_t length; FontStretch stretch; }; // Mapping from suffix to stretch value from the DirectWrite documentation. // http://msdn.microsoft.com/en-us/library/windows/desktop/dd368078.aspx // Also includes Narrow as a synonym for Condensed to to support Arial // Narrow and other fonts following the same naming scheme. const static FamilyStretchSuffix variantForSuffix[] = { { L" ultracondensed", 15, FontStretchUltraCondensed }, { L" extracondensed", 15, FontStretchExtraCondensed }, { L" condensed", 10, FontStretchCondensed }, { L" narrow", 7, FontStretchCondensed }, { L" semicondensed", 14, FontStretchSemiCondensed }, { L" semiexpanded", 13, FontStretchSemiExpanded }, { L" expanded", 9, FontStretchExpanded }, { L" extraexpanded", 14, FontStretchExtraExpanded }, { L" ultraexpanded", 14, FontStretchUltraExpanded } }; size_t numVariants = WTF_ARRAY_LENGTH(variantForSuffix); bool caseSensitive = false; for (size_t i = 0; i < numVariants; i++) { const FamilyStretchSuffix& entry = variantForSuffix[i]; if (family.endsWith(entry.suffix, caseSensitive)) { String familyName = family.string(); familyName.truncate(family.length() - entry.length); adjustedName = AtomicString(familyName); variantStretch = entry.stretch; return true; } } return false; }
String HTMLImageLoader::sourceURI(const AtomicString& attr) const { #if ENABLE(DASHBOARD_SUPPORT) Settings* settings = client()->sourceElement()->document()->settings(); if (settings && settings->usesDashboardBackwardCompatibilityMode() && attr.length() > 7 && attr.startsWith("url(\"") && attr.endsWith("\")")) return attr.string().substring(5, attr.length() - 7); #endif return stripLeadingAndTrailingHTMLSpaces(attr); }