void HTMLTablePartElement::collectStyleForPresentationAttribute( const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style) { if (name == bgcolorAttr) { addHTMLColorToStyle(style, CSSPropertyBackgroundColor, value); } else if (name == backgroundAttr) { String url = stripLeadingAndTrailingHTMLSpaces(value); if (!url.isEmpty()) { CSSImageValue* imageValue = CSSImageValue::create(url, document().completeURL(url)); imageValue->setReferrer(Referrer(document().outgoingReferrer(), document().getReferrerPolicy())); style->setProperty(CSSProperty(CSSPropertyBackgroundImage, *imageValue)); } } else if (name == valignAttr) { if (equalIgnoringCase(value, "top")) addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueTop); else if (equalIgnoringCase(value, "middle")) addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueMiddle); else if (equalIgnoringCase(value, "bottom")) addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueBottom); else if (equalIgnoringCase(value, "baseline")) addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueBaseline); else addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, value); } else if (name == alignAttr) { if (equalIgnoringCase(value, "middle") || equalIgnoringCase(value, "center")) addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitCenter); else if (equalIgnoringCase(value, "absmiddle")) addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, CSSValueCenter); else if (equalIgnoringCase(value, "left")) addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitLeft); else if (equalIgnoringCase(value, "right")) addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitRight); else addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, value); } else if (name == heightAttr) { if (!value.isEmpty()) addHTMLLengthToStyle(style, CSSPropertyHeight, value); } else { HTMLElement::collectStyleForPresentationAttribute(name, value, style); } }
StyleImage* CSSCursorImageValue::cacheImage(const Document& document, float deviceScaleFactor) { if (m_imageValue->isImageSetValue()) return toCSSImageSetValue(*m_imageValue) .cacheImage(document, deviceScaleFactor); if (m_isCachePending) { m_isCachePending = false; // For SVG images we need to lazily substitute in the correct URL. Rather // than attempt to change the URL of the CSSImageValue (which would then // change behavior like cssText), we create an alternate CSSImageValue to // use. if (hasFragmentInURL()) { CSSImageValue* imageValue = toCSSImageValue(m_imageValue.get()); // FIXME: This will fail if the <cursor> element is in a shadow DOM // (http://crbug/59827) if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(imageValue->url(), document)) { CSSImageValue* svgImageValue = CSSImageValue::create(document.completeURL( cursorElement->href()->currentValue()->value())); svgImageValue->setReferrer(imageValue->referrer()); m_cachedImage = svgImageValue->cacheImage(document); return m_cachedImage.get(); } } if (m_imageValue->isImageValue()) m_cachedImage = toCSSImageValue(*m_imageValue).cacheImage(document); } if (m_cachedImage && m_cachedImage->isImageResource()) return toStyleFetchedImage(m_cachedImage); return nullptr; }
void HTMLTableElement::collectStyleForPresentationAttribute( const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style) { if (name == widthAttr) { addHTMLLengthToStyle(style, CSSPropertyWidth, value); } else if (name == heightAttr) { addHTMLLengthToStyle(style, CSSPropertyHeight, value); } else if (name == borderAttr) { addPropertyToPresentationAttributeStyle( style, CSSPropertyBorderWidth, parseBorderWidthAttribute(value), CSSPrimitiveValue::UnitType::Pixels); } else if (name == bordercolorAttr) { if (!value.isEmpty()) addHTMLColorToStyle(style, CSSPropertyBorderColor, value); } else if (name == bgcolorAttr) { addHTMLColorToStyle(style, CSSPropertyBackgroundColor, value); } else if (name == backgroundAttr) { String url = stripLeadingAndTrailingHTMLSpaces(value); if (!url.isEmpty()) { CSSImageValue* imageValue = CSSImageValue::create(url, document().completeURL(url)); imageValue->setReferrer(Referrer(document().outgoingReferrer(), document().getReferrerPolicy())); style->setProperty(CSSProperty(CSSPropertyBackgroundImage, *imageValue)); } } else if (name == valignAttr) { if (!value.isEmpty()) addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, value); } else if (name == cellspacingAttr) { if (!value.isEmpty()) addHTMLLengthToStyle(style, CSSPropertyBorderSpacing, value); } else if (name == alignAttr) { if (!value.isEmpty()) { if (equalIgnoringCase(value, "center")) { addPropertyToPresentationAttributeStyle( style, CSSPropertyWebkitMarginStart, CSSValueAuto); addPropertyToPresentationAttributeStyle( style, CSSPropertyWebkitMarginEnd, CSSValueAuto); } else { addPropertyToPresentationAttributeStyle(style, CSSPropertyFloat, value); } } } else if (name == rulesAttr) { // The presence of a valid rules attribute causes border collapsing to be // enabled. if (m_rulesAttr != UnsetRules) addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderCollapse, CSSValueCollapse); } else if (name == frameAttr) { bool borderTop; bool borderRight; bool borderBottom; bool borderLeft; if (getBordersFromFrameAttributeValue(value, borderTop, borderRight, borderBottom, borderLeft)) { addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, CSSValueThin); addPropertyToPresentationAttributeStyle( style, CSSPropertyBorderTopStyle, borderTop ? CSSValueSolid : CSSValueHidden); addPropertyToPresentationAttributeStyle( style, CSSPropertyBorderBottomStyle, borderBottom ? CSSValueSolid : CSSValueHidden); addPropertyToPresentationAttributeStyle( style, CSSPropertyBorderLeftStyle, borderLeft ? CSSValueSolid : CSSValueHidden); addPropertyToPresentationAttributeStyle( style, CSSPropertyBorderRightStyle, borderRight ? CSSValueSolid : CSSValueHidden); } } else { HTMLElement::collectStyleForPresentationAttribute(name, value, style); } }