Ejemplo n.º 1
0
MutableStylePropertySet* CanvasFontCache::parseFont(const String& fontString)
{
    MutableStylePropertySet* parsedStyle;
    MutableStylePropertyMap::iterator i = m_fetchedFonts.find(fontString);
    if (i != m_fetchedFonts.end()) {
        ASSERT(m_fontLRUList.contains(fontString));
        parsedStyle = i->value;
        m_fontLRUList.remove(fontString);
        m_fontLRUList.add(fontString);
    } else {
        parsedStyle = MutableStylePropertySet::create(HTMLStandardMode);
        CSSParser::parseValue(parsedStyle, CSSPropertyFont, fontString, true, 0);
        if (parsedStyle->isEmpty())
            return nullptr;
        // According to http://lists.w3.org/Archives/Public/public-html/2009Jul/0947.html,
        // the "inherit" and "initial" values must be ignored.
        CSSValue* fontValue = parsedStyle->getPropertyCSSValue(CSSPropertyFontSize);
        if (fontValue && (fontValue->isInitialValue() || fontValue->isInheritedValue()))
            return nullptr;
        m_fetchedFonts.add(fontString, parsedStyle);
        m_fontLRUList.add(fontString);
        // Hard limit is applied here, on the fly, while the soft limit is
        // applied at the end of the task.
        if (m_fetchedFonts.size() > hardMaxFonts()) {
            ASSERT(m_fetchedFonts.size() == hardMaxFonts() + 1);
            ASSERT(m_fontLRUList.size() == hardMaxFonts() + 1);
            m_fetchedFonts.remove(m_fontLRUList.first());
            m_fontsResolvedUsingDefaultStyle.remove(m_fontLRUList.first());
            m_fontLRUList.removeFirst();
        }
    }
    schedulePruningIfNeeded();

    return parsedStyle;
}
Ejemplo n.º 2
0
static StylePropertySet* createBorderStyle(CSSValueID value) {
  MutableStylePropertySet* style =
      MutableStylePropertySet::create(HTMLQuirksMode);
  style->setProperty(CSSPropertyBorderTopStyle, value);
  style->setProperty(CSSPropertyBorderBottomStyle, value);
  style->setProperty(CSSPropertyBorderLeftStyle, value);
  style->setProperty(CSSPropertyBorderRightStyle, value);
  return style;
}
Ejemplo n.º 3
0
static inline void applyCSSPropertyToTarget(SVGElement* targetElement, CSSPropertyID id, const String& value)
{
    ASSERT_WITH_SECURITY_IMPLICATION(!targetElement->m_deletionHasBegun);

    MutableStylePropertySet* propertySet = targetElement->ensureAnimatedSMILStyleProperties();
    if (!propertySet->setProperty(id, value, false, 0))
        return;

    targetElement->setNeedsStyleRecalc(LocalStyleChange);
}
Ejemplo n.º 4
0
static inline void applyCSSPropertyToTarget(SVGElement* targetElement, CSSPropertyID id, const String& value)
{
#if !ENABLE(OILPAN)
    ASSERT_WITH_SECURITY_IMPLICATION(!targetElement->m_deletionHasBegun);
#endif

    MutableStylePropertySet* propertySet = targetElement->ensureAnimatedSMILStyleProperties();
    if (!propertySet->setProperty(id, value, false, 0))
        return;

    targetElement->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::Animation));
}
Ejemplo n.º 5
0
void HTMLFontElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet& style)
{
    if (name == sizeAttr) {
        CSSValueID size = CSSValueInvalid;
        if (cssValueFromFontSizeNumber(value, size))
            addPropertyToPresentationAttributeStyle(style, CSSPropertyFontSize, size);
    } else if (name == colorAttr)
        addHTMLColorToStyle(style, CSSPropertyColor, value);
    else if (name == faceAttr) {
        if (RefPtr<CSSValueList> fontFaceValue = cssValuePool().createFontFaceValue(value))
            style.setProperty(CSSProperty(CSSPropertyFontFamily, fontFaceValue.release()));
    } else
        HTMLElement::collectStyleForPresentationAttribute(name, value, style);
}
Ejemplo n.º 6
0
static StylePropertySet* createGroupBorderStyle(int rows) {
  MutableStylePropertySet* style =
      MutableStylePropertySet::create(HTMLQuirksMode);
  if (rows) {
    style->setProperty(CSSPropertyBorderTopWidth, CSSValueThin);
    style->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin);
    style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
    style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
  } else {
    style->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin);
    style->setProperty(CSSPropertyBorderRightWidth, CSSValueThin);
    style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
    style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
  }
  return style;
}
Ejemplo n.º 7
0
bool FontFaceSet::resolveFontStyle(const String& fontString, Font& font) {
  if (fontString.isEmpty())
    return false;

  // Interpret fontString in the same way as the 'font' attribute of
  // CanvasRenderingContext2D.
  MutableStylePropertySet* parsedStyle =
      MutableStylePropertySet::create(HTMLStandardMode);
  CSSParser::parseValue(parsedStyle, CSSPropertyFont, fontString, true, 0);
  if (parsedStyle->isEmpty())
    return false;

  String fontValue = parsedStyle->getPropertyValue(CSSPropertyFont);
  if (fontValue == "inherit" || fontValue == "initial")
    return false;

  RefPtr<ComputedStyle> style = ComputedStyle::create();

  FontFamily fontFamily;
  fontFamily.setFamily(defaultFontFamily);

  FontDescription defaultFontDescription;
  defaultFontDescription.setFamily(fontFamily);
  defaultFontDescription.setSpecifiedSize(defaultFontSize);
  defaultFontDescription.setComputedSize(defaultFontSize);

  style->setFontDescription(defaultFontDescription);

  style->font().update(style->font().getFontSelector());

  document()->ensureStyleResolver().computeFont(style.get(), *parsedStyle);

  font = style->font();
  font.update(document()->styleEngine().fontSelector());
  return true;
}
Ejemplo n.º 8
0
StylePropertySet* HTMLTableElement::createSharedCellStyle() {
  MutableStylePropertySet* style =
      MutableStylePropertySet::create(HTMLQuirksMode);

  switch (getCellBorders()) {
    case SolidBordersColsOnly:
      style->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin);
      style->setProperty(CSSPropertyBorderRightWidth, CSSValueThin);
      style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid);
      style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid);
      style->setProperty(CSSPropertyBorderColor, *CSSInheritedValue::create());
      break;
    case SolidBordersRowsOnly:
      style->setProperty(CSSPropertyBorderTopWidth, CSSValueThin);
      style->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin);
      style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid);
      style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid);
      style->setProperty(CSSPropertyBorderColor, *CSSInheritedValue::create());
      break;
    case SolidBorders:
      style->setProperty(
          CSSPropertyBorderWidth,
          *CSSPrimitiveValue::create(1, CSSPrimitiveValue::UnitType::Pixels));
      style->setProperty(CSSPropertyBorderStyle,
                         *CSSIdentifierValue::create(CSSValueSolid));
      style->setProperty(CSSPropertyBorderColor, *CSSInheritedValue::create());
      break;
    case InsetBorders:
      style->setProperty(
          CSSPropertyBorderWidth,
          *CSSPrimitiveValue::create(1, CSSPrimitiveValue::UnitType::Pixels));
      style->setProperty(CSSPropertyBorderStyle,
                         *CSSIdentifierValue::create(CSSValueInset));
      style->setProperty(CSSPropertyBorderColor, *CSSInheritedValue::create());
      break;
    case NoBorders:
      // If 'rules=none' then allow any borders set at cell level to take
      // effect.
      break;
  }

  if (m_padding)
    style->setProperty(CSSPropertyPadding,
                       *CSSPrimitiveValue::create(
                           m_padding, CSSPrimitiveValue::UnitType::Pixels));

  return style;
}