Ejemplo n.º 1
0
void HTMLOptGroupElement::didAddUserAgentShadowRoot(ShadowRoot& root) {
  DEFINE_STATIC_LOCAL(AtomicString, labelPadding, ("0 2px 1px 2px"));
  DEFINE_STATIC_LOCAL(AtomicString, labelMinHeight, ("1.2em"));
  HTMLDivElement* label = HTMLDivElement::create(document());
  label->setAttribute(roleAttr, AtomicString("group"));
  label->setAttribute(aria_labelAttr, AtomicString());
  label->setInlineStyleProperty(CSSPropertyPadding, labelPadding);
  label->setInlineStyleProperty(CSSPropertyMinHeight, labelMinHeight);
  label->setIdAttribute(ShadowElementNames::optGroupLabel());
  root.appendChild(label);

  HTMLContentElement* content = HTMLContentElement::create(document());
  content->setAttribute(selectAttr, "option,hr");
  root.appendChild(content);
}
Ejemplo n.º 2
0
void HTMLImageFallbackHelper::createAltTextShadowTree(Element& element) {
  ShadowRoot& root = element.ensureUserAgentShadowRoot();

  HTMLDivElement* container = HTMLDivElement::create(element.document());
  root.appendChild(container);
  container->setAttribute(idAttr, AtomicString("alttext-container"));
  container->setInlineStyleProperty(CSSPropertyOverflow, CSSValueHidden);
  container->setInlineStyleProperty(CSSPropertyBorderWidth, 1,
                                    CSSPrimitiveValue::UnitType::Pixels);
  container->setInlineStyleProperty(CSSPropertyBorderStyle, CSSValueSolid);
  container->setInlineStyleProperty(CSSPropertyBorderColor, CSSValueSilver);
  container->setInlineStyleProperty(CSSPropertyDisplay, CSSValueInlineBlock);
  container->setInlineStyleProperty(CSSPropertyBoxSizing, CSSValueBorderBox);
  container->setInlineStyleProperty(CSSPropertyPadding, 1,
                                    CSSPrimitiveValue::UnitType::Pixels);

  HTMLImageElement* brokenImage = HTMLImageElement::create(element.document());
  container->appendChild(brokenImage);
  brokenImage->setIsFallbackImage();
  brokenImage->setAttribute(idAttr, AtomicString("alttext-image"));
  brokenImage->setAttribute(widthAttr, AtomicString("16"));
  brokenImage->setAttribute(heightAttr, AtomicString("16"));
  brokenImage->setAttribute(alignAttr, AtomicString("left"));
  brokenImage->setInlineStyleProperty(CSSPropertyMargin, 0,
                                      CSSPrimitiveValue::UnitType::Pixels);

  HTMLDivElement* altText = HTMLDivElement::create(element.document());
  container->appendChild(altText);
  altText->setAttribute(idAttr, AtomicString("alttext"));
  altText->setInlineStyleProperty(CSSPropertyOverflow, CSSValueHidden);
  altText->setInlineStyleProperty(CSSPropertyDisplay, CSSValueBlock);

  Text* text =
      Text::create(element.document(), toHTMLElement(element).altText());
  altText->appendChild(text);
}