Color StyleColor::colorFromKeyword(CSSValueID keyword) { if (const char* valueName = getValueName(keyword)) { if (const NamedColor* namedColor = findColor(valueName, strlen(valueName))) return Color(namedColor->ARGBValue); } return RenderTheme::defaultTheme()->systemColor(keyword); }
String CSSGridAutoRepeatValue::customCSSText() const { StringBuilder result; result.append("repeat("); result.append(getValueName(autoRepeatID())); result.append(", "); result.append(CSSValueList::customCSSText()); result.append(")"); return result.toString(); }
/** * Load the given value. * * @param v the value to load */ void JVMWriter::printValueLoad(const Value *v) { if(const Function *f = dyn_cast<Function>(v)) { std::string sig = getValueName(f) + getCallSignature(f->getFunctionType()); if(externRefs.count(v)) printSimpleInstruction("CLASSFORMETHOD", sig); else printSimpleInstruction("ldc", '"' + classname + '"'); printSimpleInstruction("ldc", '"' + sig + '"'); printSimpleInstruction("invokestatic", "lljvm/runtime/Function/getFunctionPointer" "(Ljava/lang/String;Ljava/lang/String;)I"); } else if(isa<GlobalVariable>(v)) { const Type *ty = cast<PointerType>(v->getType())->getElementType(); if(externRefs.count(v)) printSimpleInstruction("getstatic", getValueName(v) + " I"); else printSimpleInstruction("getstatic", classname + "/" + getValueName(v) + " I"); } else if(isa<ConstantPointerNull>(v)) { printPtrLoad(0); } else if(const ConstantExpr *ce = dyn_cast<ConstantExpr>(v)) { printConstantExpr(ce); } else if(const Constant *c = dyn_cast<Constant>(v)) { printConstLoad(c); } else { if(getLocalVarNumber(v) <= 3) printSimpleInstruction( getTypePrefix(v->getType(), true) + "load_" + utostr(getLocalVarNumber(v)) + " ; " + getValueName(v)); else printSimpleInstruction( getTypePrefix(v->getType(), true) + "load", utostr(getLocalVarNumber(v)) + " ; " + getValueName(v)); } }
static const AtomicString& valueName(CSSValueID valueID) { ASSERT_ARG(valueID, valueID >= 0); ASSERT_ARG(valueID, valueID < numCSSValueKeywords); if (valueID < 0) return nullAtom; static AtomicString* keywordStrings = new AtomicString[numCSSValueKeywords]; // Leaked intentionally. AtomicString& keywordString = keywordStrings[valueID]; if (keywordString.isNull()) keywordString = getValueName(valueID); return keywordString; }
static const AtomicString& valueName(CSSValueID valueID) { DCHECK_GE(valueID, 0); DCHECK_LT(valueID, numCSSValueKeywords); if (valueID < 0) return nullAtom; static AtomicString* keywordStrings = new AtomicString[numCSSValueKeywords]; // Leaked intentionally. AtomicString& keywordString = keywordStrings[valueID]; if (keywordString.isNull()) keywordString = getValueName(valueID); return keywordString; }
/** * Print the static class initialization method. */ void JVMWriter::printClInit() { out << ".method public <clinit>()V\n"; printSimpleInstruction(".limit stack 4"); out << "\n\t; allocate global variables\n"; for(Module::global_iterator i = module->global_begin(), e = module->global_end(); i != e; i++) { if(!i->isDeclaration()) { const GlobalVariable *g = i; const Constant *c = g->getInitializer(); printConstLoad( APInt(32, targetData->getTypeAllocSize(c->getType()), false)); printSimpleInstruction("invokestatic", "lljvm/runtime/Memory/allocateData(I)I"); printSimpleInstruction("putstatic", classname + "/" + getValueName(g) + " I"); } } out << "\n\t; initialise global variables\n"; for(Module::global_iterator i = module->global_begin(), e = module->global_end(); i != e; i++) { if(!i->isDeclaration()) { const GlobalVariable *g = i; const Constant *c = g->getInitializer(); printSimpleInstruction("getstatic", classname + "/" + getValueName(g) + " I"); printStaticConstant(c); printSimpleInstruction("pop"); out << '\n'; } } printSimpleInstruction("return"); out << ".end method\n\n"; }
String CSSPrimitiveValue::getStringValue() const { switch (m_type) { case CSS_STRING: case CSS_ATTR: case CSS_URI: return m_value.string; case CSS_IDENT: return getValueName(m_value.ident); default: // FIXME: The CSS 2.1 spec says you should throw an exception here. break; } return String(); }
/** * Print the list of external methods. */ void JVMWriter::printExternalMethods() { out << "; External methods\n"; for(Module::const_iterator i = module->begin(), e = module->end(); i != e; i++) { if(i->isDeclaration() && !i->isIntrinsic()) { const Function *f = i; const FunctionType *ty = f->getFunctionType(); out << ".extern method " << getValueName(f) << getCallSignature(ty); if(debug >= 3) out << " ; " << *ty; out << '\n'; externRefs.insert(f); } } out << '\n'; }
/** * Print the field declarations. */ void JVMWriter::printFields() { out << "; Fields\n"; for(Module::global_iterator i = module->global_begin(), e = module->global_end(); i != e; i++) { if(i->isDeclaration()) { out << ".extern field "; externRefs.insert(i); } else out << ".field " << (i->hasLocalLinkage() ? "private " : "public ") << "static final "; out << getValueName(i) << ' ' << getTypeDescriptor(i->getType()); if(debug >= 3) out << " ; " << *i; else out << '\n'; } out << '\n'; }
String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShorthand& shorthand) const { StringBuilder result; const unsigned size = shorthand.length(); // Begin by collecting the properties into an array. WillBeHeapVector<RefPtrWillBeMember<CSSValue> > values(size); size_t numLayers = 0; for (unsigned i = 0; i < size; ++i) { values[i] = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]); if (values[i]) { if (values[i]->isBaseValueList()) { CSSValueList* valueList = toCSSValueList(values[i].get()); numLayers = max(valueList->length(), numLayers); } else numLayers = max<size_t>(1U, numLayers); } } String commonValue; bool commonValueInitialized = false; // Now stitch the properties together. Implicit initial values are flagged as such and // can safely be omitted. for (size_t i = 0; i < numLayers; i++) { StringBuilder layerResult; bool useRepeatXShorthand = false; bool useRepeatYShorthand = false; bool useSingleWordShorthand = false; bool foundPositionYCSSProperty = false; for (unsigned j = 0; j < size; j++) { RefPtrWillBeRawPtr<CSSValue> value = nullptr; if (values[j]) { if (values[j]->isBaseValueList()) value = toCSSValueList(values[j].get())->item(i); else { value = values[j]; // Color only belongs in the last layer. if (shorthand.properties()[j] == CSSPropertyBackgroundColor) { if (i != numLayers - 1) value = nullptr; } else if (i) { // Other singletons only belong in the first layer. value = nullptr; } } } // We need to report background-repeat as it was written in the CSS. If the property is implicit, // then it was written with only one value. Here we figure out which value that was so we can // report back correctly. if ((shorthand.properties()[j] == CSSPropertyBackgroundRepeatX && m_propertySet.isPropertyImplicit(shorthand.properties()[j])) || (shorthand.properties()[j] == CSSPropertyWebkitMaskRepeatX && m_propertySet.isPropertyImplicit(shorthand.properties()[j]))) { // BUG 49055: make sure the value was not reset in the layer check just above. if ((j < size - 1 && shorthand.properties()[j + 1] == CSSPropertyBackgroundRepeatY && value) || (j < size - 1 && shorthand.properties()[j + 1] == CSSPropertyWebkitMaskRepeatY && value)) { RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; RefPtrWillBeRawPtr<CSSValue> nextValue = values[j + 1]; if (nextValue->isValueList()) yValue = toCSSValueList(nextValue.get())->itemWithoutBoundsCheck(i); else yValue = nextValue; // background-repeat-x(y) or mask-repeat-x(y) may be like this : "initial, repeat". We can omit the implicit initial values // before starting to compare their values. if (value->isImplicitInitialValue() || yValue->isImplicitInitialValue()) continue; // FIXME: At some point we need to fix this code to avoid returning an invalid shorthand, // since some longhand combinations are not serializable into a single shorthand. if (!value->isPrimitiveValue() || !yValue->isPrimitiveValue()) continue; CSSValueID xId = toCSSPrimitiveValue(value.get())->getValueID(); CSSValueID yId = toCSSPrimitiveValue(yValue.get())->getValueID(); if (xId != yId) { if (xId == CSSValueRepeat && yId == CSSValueNoRepeat) { useRepeatXShorthand = true; ++j; } else if (xId == CSSValueNoRepeat && yId == CSSValueRepeat) { useRepeatYShorthand = true; continue; } } else { useSingleWordShorthand = true; ++j; } } } String valueText; if (value && !value->isImplicitInitialValue()) { if (!layerResult.isEmpty()) layerResult.append(' '); if (foundPositionYCSSProperty && (shorthand.properties()[j] == CSSPropertyBackgroundSize || shorthand.properties()[j] == CSSPropertyWebkitMaskSize)) layerResult.appendLiteral("/ "); if (!foundPositionYCSSProperty && (shorthand.properties()[j] == CSSPropertyBackgroundSize || shorthand.properties()[j] == CSSPropertyWebkitMaskSize)) continue; if (useRepeatXShorthand) { useRepeatXShorthand = false; layerResult.append(getValueName(CSSValueRepeatX)); } else if (useRepeatYShorthand) { useRepeatYShorthand = false; layerResult.append(getValueName(CSSValueRepeatY)); } else { if (useSingleWordShorthand) useSingleWordShorthand = false; valueText = value->cssText(); layerResult.append(valueText); } if (shorthand.properties()[j] == CSSPropertyBackgroundPositionY || shorthand.properties()[j] == CSSPropertyWebkitMaskPositionY) { foundPositionYCSSProperty = true; // background-position is a special case: if only the first offset is specified, // the second one defaults to "center", not the same value. if (commonValueInitialized && commonValue != "initial" && commonValue != "inherit") commonValue = String(); } } if (!commonValueInitialized) { commonValue = valueText; commonValueInitialized = true; } else if (!commonValue.isNull() && commonValue != valueText) commonValue = String(); } if (!layerResult.isEmpty()) { if (!result.isEmpty()) result.appendLiteral(", "); result.append(layerResult); } } if (isInitialOrInherit(commonValue)) return commonValue; if (result.isEmpty()) return String(); return result.toString(); }
static const char* valueOrPropertyName(int valueOrPropertyID) { if (const char* valueName = getValueName(valueOrPropertyID)) return valueName; return getPropertyName(static_cast<CSSPropertyID>(valueOrPropertyID)); }
String CSSMutableStyleDeclaration::getLayeredShorthandValue(const int* properties, size_t size) const { String res; // Begin by collecting the properties into an array. Vector< RefPtr<CSSValue> > values(size); size_t numLayers = 0; for (size_t i = 0; i < size; ++i) { values[i] = getPropertyCSSValue(properties[i]); if (values[i]) { if (values[i]->isValueList()) { CSSValueList* valueList = static_cast<CSSValueList*>(values[i].get()); numLayers = max(valueList->length(), numLayers); } else numLayers = max<size_t>(1U, numLayers); } } // Now stitch the properties together. Implicit initial values are flagged as such and // can safely be omitted. for (size_t i = 0; i < numLayers; i++) { String layerRes; bool useRepeatXShorthand = false; bool useRepeatYShorthand = false; bool useSingleWordShorthand = false; for (size_t j = 0; j < size; j++) { RefPtr<CSSValue> value; if (values[j]) { if (values[j]->isValueList()) value = static_cast<CSSValueList*>(values[j].get())->item(i); else { value = values[j]; // Color only belongs in the last layer. if (properties[j] == CSSPropertyBackgroundColor) { if (i != numLayers - 1) value = 0; } else if (i != 0) // Other singletons only belong in the first layer. value = 0; } } // We need to report background-repeat as it was written in the CSS. If the property is implicit, // then it was written with only one value. Here we figure out which value that was so we can // report back correctly. if (properties[j] == CSSPropertyBackgroundRepeatX && isPropertyImplicit(properties[j])) { // BUG 49055: make sure the value was not reset in the layer check just above. if (j < size - 1 && properties[j + 1] == CSSPropertyBackgroundRepeatY && value) { RefPtr<CSSValue> yValue; RefPtr<CSSValue> nextValue = values[j + 1]; if (nextValue->isValueList()) yValue = static_cast<CSSValueList*>(nextValue.get())->itemWithoutBoundsCheck(i); else yValue = nextValue; int xId = static_cast<CSSPrimitiveValue*>(value.get())->getIdent(); int yId = static_cast<CSSPrimitiveValue*>(yValue.get())->getIdent(); if (xId != yId) { if (xId == CSSValueRepeat && yId == CSSValueNoRepeat) { useRepeatXShorthand = true; ++j; } else if (xId == CSSValueNoRepeat && yId == CSSValueRepeat) { useRepeatYShorthand = true; continue; } } else { useSingleWordShorthand = true; ++j; } } } if (value && !value->isImplicitInitialValue()) { if (!layerRes.isNull()) layerRes += " "; if (useRepeatXShorthand) { useRepeatXShorthand = false; layerRes += getValueName(CSSValueRepeatX); } else if (useRepeatYShorthand) { useRepeatYShorthand = false; layerRes += getValueName(CSSValueRepeatY); } else if (useSingleWordShorthand) { useSingleWordShorthand = false; layerRes += value->cssText(); } else layerRes += value->cssText(); } } if (!layerRes.isNull()) { if (!res.isNull()) res += ", "; res += layerRes; } } return res; }
String CSSPrimitiveValue::cssText() const { // ### return the original value instead of a generated one (e.g. color // name if it was specified) - check what spec says about this String text; switch ( m_type ) { case CSS_UNKNOWN: // ### break; case CSS_NUMBER: text = String::number(m_value.num); break; case CSS_PERCENTAGE: text = String::number(m_value.num) + "%"; break; case CSS_EMS: text = String::number(m_value.num) + "em"; break; case CSS_EXS: text = String::number(m_value.num) + "ex"; break; case CSS_PX: text = String::number(m_value.num) + "px"; break; case CSS_CM: text = String::number(m_value.num) + "cm"; break; case CSS_MM: text = String::number(m_value.num) + "mm"; break; case CSS_IN: text = String::number(m_value.num) + "in"; break; case CSS_PT: text = String::number(m_value.num) + "pt"; break; case CSS_PC: text = String::number(m_value.num) + "pc"; break; case CSS_DEG: text = String::number(m_value.num) + "deg"; break; case CSS_RAD: text = String::number(m_value.num) + "rad"; break; case CSS_GRAD: text = String::number(m_value.num) + "grad"; break; case CSS_MS: text = String::number(m_value.num) + "ms"; break; case CSS_S: text = String::number(m_value.num) + "s"; break; case CSS_HZ: text = String::number(m_value.num) + "hz"; break; case CSS_KHZ: text = String::number(m_value.num) + "khz"; break; case CSS_DIMENSION: // ### break; case CSS_STRING: text = quoteStringIfNeeded(m_value.string); break; case CSS_URI: text = "url(" + String(m_value.string) + ")"; break; case CSS_IDENT: text = getValueName(m_value.ident); break; case CSS_ATTR: // ### break; case CSS_COUNTER: // ### break; case CSS_RECT: { RectImpl* rectVal = getRectValue(); text = "rect("; text += rectVal->top()->cssText() + " "; text += rectVal->right()->cssText() + " "; text += rectVal->bottom()->cssText() + " "; text += rectVal->left()->cssText() + ")"; break; } case CSS_RGBCOLOR: { Color color(m_value.rgbcolor); if (color.alpha() < 0xFF) text = "rgba("; else text = "rgb("; text += String::number(color.red()) + ", "; text += String::number(color.green()) + ", "; text += String::number(color.blue()); if (color.alpha() < 0xFF) text += ", " + String::number((float)color.alpha() / 0xFF); text += ")"; break; } case CSS_PAIR: text = m_value.pair->first()->cssText(); text += " "; text += m_value.pair->second()->cssText(); break; #if __APPLE__ case CSS_DASHBOARD_REGION: for (DashboardRegion* region = getDashboardRegionValue(); region; region = region->m_next.get()) { text = "dashboard-region("; text += region->m_label; if (region->m_isCircle) text += " circle "; else if (region->m_isRectangle) text += " rectangle "; else break; text += region->top()->cssText() + " "; text += region->right()->cssText() + " "; text += region->bottom()->cssText() + " "; text += region->left()->cssText(); text += ")"; } break; #endif } return text; }
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineValueName( JNIEnv * env, jobject obj, jstring subkey, jint index) { return getValueName(env, HKEY_LOCAL_MACHINE, subkey, index); }
/*! * \brief Get a string for displaying the card's identity * \return QString */ QString Card::getLabel() { return getValueName() + " of " + getColorName(); }
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getCurrentUserValueName( JNIEnv * env, jobject obj, jstring subkey, jint index) { return getValueName(env, HKEY_CURRENT_USER, subkey, index); }
/** * Print the class constructor. */ void JVMWriter::printConstructor() { out << "; Constructor\n" ".method public <init>()V\n"; printSimpleInstruction("aload_0"); printSimpleInstruction("invokespecial","java/lang/Object/<init>()V"); printSimpleInstruction("return"); printSimpleInstruction(".limit stack 1"); printSimpleInstruction(".limit locals 1"); out << ".end method\n\n"; out << ".method public initialize(Llljvm/runtime/Context;)V\n"; printSimpleInstruction(".limit stack 12"); printSimpleInstruction(".limit locals 2"); out << "\n;;;START LINKER INITIALIZATIONS;;;\n"; printInitLinkerFields(); out << ";;;END LINKER INITIALIZATIONS;;;\n\n"; out << "\n\t; allocate global variables\n"; for(Module::global_iterator i = module->global_begin(), e = module->global_end(); i != e; i++) { if(!i->isDeclaration()) { const GlobalVariable *g = i; const Constant *c = g->getInitializer(); printSimpleInstruction("aload_0"); printStartInvocationTag(); printConstLoad( APInt(32, targetData->getTypeAllocSize(c->getType()), false)); printEndInvocationTag("lljvm/runtime/Memory/allocateData(I)I"); printSimpleInstruction("putfield", classname + "/" + getValueName(g) + " I"); } } out << "\n\t; initialize global variables\n"; for(Module::global_iterator i = module->global_begin(), e = module->global_end(); i != e; i++) { if(!i->isDeclaration()) { const GlobalVariable *g = i; const Constant *c = g->getInitializer(); printSimpleInstruction("aload_0"); printSimpleInstruction("getfield", classname + "/" + getValueName(g) + " I"); printStaticConstant(c); printSimpleInstruction("pop"); out << '\n'; } } out << "\n" "\treturn\n" ".end method\n\n"; out << ".method public destroy(Llljvm/runtime/Context;)V\n"; printSimpleInstruction("return"); printSimpleInstruction(".limit stack 0"); printSimpleInstruction(".limit locals 2"); out << ".end method\n\n"; }