Ejemplo n.º 1
0
void LayoutEditor::overlayStartedPropertyChange(const String& anchorName)
{
    m_changingProperty = cssPropertyID(anchorName);
    if (!m_changingProperty)
        return;

    RefPtrWillBeRawPtr<CSSPrimitiveValue> cssValue = getPropertyCSSValue(m_changingProperty);
    m_valueUnitType = cssValue ? cssValue->typeWithCalcResolved() : CSSPrimitiveValue::UnitType::Pixels;
    if (!isMutableUnitType(m_valueUnitType))
        return;

    switch (m_valueUnitType) {
    case CSSPrimitiveValue::UnitType::Pixels:
        m_factor = 1;
        break;
    case CSSPrimitiveValue::UnitType::Ems:
        m_factor = m_element->computedStyle()->computedFontSize();
        break;
    case CSSPrimitiveValue::UnitType::Percentage:
        // It is hard to correctly support percentages, so we decided hack it this way: 100% = 1000px
        m_factor = 10;
        break;
    case CSSPrimitiveValue::UnitType::Rems:
        m_factor = m_element->document().computedStyle()->computedFontSize();
        break;
    default:
        ASSERT_NOT_REACHED();
        break;
    }
    m_propertyInitialValue = cssValue ? cssValue->getFloatValue() : 0;
}
Ejemplo n.º 2
0
PassRefPtr<JSONObject> LayoutEditor::createValueDescription(const String& propertyName)
{
    RefPtrWillBeRawPtr<CSSPrimitiveValue> cssValue = getPropertyCSSValue(cssPropertyID(propertyName));
    if (cssValue && !(cssValue->isLength() || cssValue->isPercentage()))
        return nullptr;

    RefPtr<JSONObject> object = JSONObject::create();
    object->setNumber("value", cssValue ? cssValue->getFloatValue() : 0);
    CSSPrimitiveValue::UnitType unitType = cssValue ? cssValue->typeWithCalcResolved() : CSSPrimitiveValue::UnitType::Pixels;
    object->setString("unit", CSSPrimitiveValue::unitTypeToString(unitType));
    object->setBoolean("mutable", isMutableUnitType(unitType));

    if (!m_growsInside.contains(propertyName))
        m_growsInside.set(propertyName, growInside(propertyName, cssValue.get()));

    object->setBoolean("growInside", m_growsInside.get(propertyName));
    return object.release();
}
Ejemplo n.º 3
0
std::unique_ptr<protocol::DictionaryValue> LayoutEditor::createValueDescription(
    const String& propertyName) {
  const CSSPrimitiveValue* cssValue =
      getPropertyCSSValue(cssPropertyID(propertyName));
  if (cssValue && !(cssValue->isLength() || cssValue->isPercentage()))
    return nullptr;

  std::unique_ptr<protocol::DictionaryValue> object =
      protocol::DictionaryValue::create();
  object->setDouble("value", cssValue ? cssValue->getFloatValue() : 0);
  CSSPrimitiveValue::UnitType unitType =
      cssValue ? cssValue->typeWithCalcResolved()
               : CSSPrimitiveValue::UnitType::Pixels;
  object->setString("unit", CSSPrimitiveValue::unitTypeToString(unitType));
  object->setBoolean("mutable", isMutableUnitType(unitType));

  if (!m_growsInside.contains(propertyName))
    m_growsInside.set(propertyName, growInside(propertyName, cssValue));

  object->setBoolean("growInside", m_growsInside.get(propertyName));
  return object;
}