Ejemplo n.º 1
0
 static void alignAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
   INC_STATS("DOM.HTMLDivElement.align._set");
   HTMLDivElement* imp = V8HTMLDivElement::toNative(info.Holder());
   V8Parameter<WithNullCheck> v = value;
   imp->setAlign(v);
   return;
 }
Ejemplo n.º 2
0
void VTTCue::updateDisplay(const IntSize& videoSize, HTMLDivElement& container)
{
    RefPtr<VTTCueBox> displayBox = getDisplayTree(videoSize);
    VTTRegion* region = 0;
    if (track()->regions())
        region = track()->regions()->getRegionById(regionId());

    if (!region) {
        // If cue has an empty text track cue region identifier or there is no
        // WebVTT region whose region identifier is identical to cue's text
        // track cue region identifier, run the following substeps:
        if (displayBox->hasChildNodes() && !container.contains(displayBox.get())) {
            // Note: the display tree of a cue is removed when the active flag of the cue is unset.
            container.appendChild(displayBox);
        }
    } else {
        // Let region be the WebVTT region whose region identifier
        // matches the text track cue region identifier of cue.
        RefPtr<HTMLDivElement> regionNode = region->getDisplayTree(document());

        // Append the region to the viewport, if it was not already.
        if (!container.contains(regionNode.get()))
            container.appendChild(regionNode);

        region->appendVTTCueBox(displayBox);
    }
}
Ejemplo n.º 3
0
JSValue jsHTMLDivElementAlign(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSHTMLDivElement* castedThis = static_cast<JSHTMLDivElement*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    HTMLDivElement* imp = static_cast<HTMLDivElement*>(castedThis->impl());
    JSValue result = jsString(exec, imp->getAttribute(WebCore::HTMLNames::alignAttr));
    return result;
}
Ejemplo n.º 4
0
void JSHTMLDivElement::putValueProperty(ExecState* exec, int token, JSValue* value)
{
    switch (token) {
    case AlignAttrNum: {
        HTMLDivElement* imp = static_cast<HTMLDivElement*>(impl());
        imp->setAlign(valueToStringWithNullCheck(exec, value));
        break;
    }
    }
}
Ejemplo n.º 5
0
JSValue* JSHTMLDivElement::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case AlignAttrNum: {
        HTMLDivElement* imp = static_cast<HTMLDivElement*>(impl());
        return jsString(exec, imp->align());
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
Ejemplo n.º 6
0
void RangeInputType::createShadowSubtree() {
  DCHECK(element().shadow());

  Document& document = element().document();
  HTMLDivElement* track = HTMLDivElement::create(document);
  track->setShadowPseudoId(AtomicString("-webkit-slider-runnable-track"));
  track->setAttribute(idAttr, ShadowElementNames::sliderTrack());
  track->appendChild(SliderThumbElement::create(document));
  HTMLElement* container = SliderContainerElement::create(document);
  container->appendChild(track);
  element().userAgentShadowRoot()->appendChild(container);
  container->setAttribute(styleAttr, "-webkit-appearance:inherit");
}
Ejemplo n.º 7
0
void VTTCue::updateDisplay(HTMLDivElement& container)
{
    ASSERT(track() && track()->isRendered() && isActive());

    UseCounter::count(document(), UseCounter::VTTCueRender);

    if (m_writingDirection != Horizontal)
        UseCounter::count(document(), UseCounter::VTTCueRenderVertical);

    if (!m_snapToLines)
        UseCounter::count(document(), UseCounter::VTTCueRenderSnapToLinesFalse);

    if (!lineIsAuto())
        UseCounter::count(document(), UseCounter::VTTCueRenderLineNotAuto);

    if (textPositionIsAuto())
        UseCounter::count(document(), UseCounter::VTTCueRenderPositionNot50);

    if (m_cueSize != 100)
        UseCounter::count(document(), UseCounter::VTTCueRenderSizeNot100);

    if (m_cueAlignment != Middle)
        UseCounter::count(document(), UseCounter::VTTCueRenderAlignNotMiddle);

    VTTCueBox* displayBox = getDisplayTree();
    VTTRegion* region = 0;
    if (track()->regions())
        region = track()->regions()->getRegionById(regionId());

    if (!region) {
        // If cue has an empty region identifier or there is no WebVTT region
        // whose region identifier is identical to cue's region identifier, run
        // the following substeps:
        if (displayBox->hasChildren() && !container.contains(displayBox)) {
            // Note: the display tree of a cue is removed when the active flag of the cue is unset.
            container.appendChild(displayBox);
        }
    } else {
        // Let region be the WebVTT region whose region identifier matches the
        // region identifier of cue.
        HTMLDivElement* regionNode = region->getDisplayTree(document());

        // Append the region to the viewport, if it was not already.
        if (!container.contains(regionNode))
            container.appendChild(regionNode);

        region->appendVTTCueBox(displayBox);
    }
}
Ejemplo n.º 8
0
void VTTCue::updateDisplay(const IntSize& videoSize, HTMLDivElement& container)
{
    UseCounter::count(document(), UseCounter::VTTCueRender);

    if (m_writingDirection != Horizontal)
        UseCounter::count(document(), UseCounter::VTTCueRenderVertical);

    if (!m_snapToLines)
        UseCounter::count(document(), UseCounter::VTTCueRenderSnapToLinesFalse);

    if (m_linePosition != undefinedPosition)
        UseCounter::count(document(), UseCounter::VTTCueRenderLineNotAuto);

    if (m_textPosition != 50)
        UseCounter::count(document(), UseCounter::VTTCueRenderPositionNot50);

    if (m_cueSize != 100)
        UseCounter::count(document(), UseCounter::VTTCueRenderSizeNot100);

    if (m_cueAlignment != Middle)
        UseCounter::count(document(), UseCounter::VTTCueRenderAlignNotMiddle);

    RefPtrWillBeRawPtr<VTTCueBox> displayBox = getDisplayTree(videoSize);
    VTTRegion* region = 0;
    if (track()->regions())
        region = track()->regions()->getRegionById(regionId());

    if (!region) {
        // If cue has an empty text track cue region identifier or there is no
        // WebVTT region whose region identifier is identical to cue's text
        // track cue region identifier, run the following substeps:
        if (displayBox->hasChildren() && !container.contains(displayBox.get())) {
            // Note: the display tree of a cue is removed when the active flag of the cue is unset.
            container.appendChild(displayBox);
        }
    } else {
        // Let region be the WebVTT region whose region identifier
        // matches the text track cue region identifier of cue.
        RefPtrWillBeRawPtr<HTMLDivElement> regionNode = region->getDisplayTree(document());

        // Append the region to the viewport, if it was not already.
        if (!container.contains(regionNode.get()))
            container.appendChild(regionNode);

        region->appendVTTCueBox(displayBox);
    }
}
Ejemplo n.º 9
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.º 10
0
void MediaDocumentParser::createDocumentStructure() {
  DCHECK(document());
  HTMLHtmlElement* rootElement = HTMLHtmlElement::create(*document());
  document()->appendChild(rootElement);
  rootElement->insertedByParser();

  if (isDetached())
    return;  // runScriptsAtDocumentElementAvailable can detach the frame.

  HTMLHeadElement* head = HTMLHeadElement::create(*document());
  HTMLMetaElement* meta = HTMLMetaElement::create(*document());
  meta->setAttribute(nameAttr, "viewport");
  meta->setAttribute(contentAttr, "width=device-width");
  head->appendChild(meta);

  HTMLVideoElement* media = HTMLVideoElement::create(*document());
  media->setAttribute(controlsAttr, "");
  media->setAttribute(autoplayAttr, "");
  media->setAttribute(nameAttr, "media");

  HTMLSourceElement* source = HTMLSourceElement::create(*document());
  source->setSrc(document()->url());

  if (DocumentLoader* loader = document()->loader())
    source->setType(loader->responseMIMEType());

  media->appendChild(source);

  HTMLBodyElement* body = HTMLBodyElement::create(*document());
  body->setAttribute(styleAttr, "margin: 0px;");

  document()->willInsertBody();

  HTMLDivElement* div = HTMLDivElement::create(*document());
  // Style sheets for media controls are lazily loaded until a media element is
  // encountered.  As a result, elements encountered before the media element
  // will not get the right style at first if we put the styles in
  // mediacontrols.css. To solve this issue, set the styles inline so that they
  // will be applied when the page loads.  See w3c example on how to centering
  // an element: https://www.w3.org/Style/Examples/007/center.en.html
  div->setAttribute(styleAttr,
                    "display: flex;"
                    "flex-direction: column;"
                    "justify-content: center;"
                    "align-items: center;"
                    "min-height: min-content;"
                    "height: 100%;");
  HTMLContentElement* content = HTMLContentElement::create(*document());
  div->appendChild(content);

  if (RuntimeEnabledFeatures::mediaDocumentDownloadButtonEnabled()) {
    HTMLAnchorElement* anchor = HTMLAnchorElement::create(*document());
    anchor->setAttribute(downloadAttr, "");
    anchor->setURL(document()->url());
    anchor->setTextContent(
        document()
            ->getCachedLocale(document()->contentLanguage())
            .queryString(WebLocalizedString::DownloadButtonLabel)
            .upper());
    // Using CSS style according to Android material design.
    anchor->setAttribute(
        styleAttr,
        "display: inline-block;"
        "margin-top: 32px;"
        "padding: 0 16px 0 16px;"
        "height: 36px;"
        "background: #000000;"
        "-webkit-tap-highlight-color: rgba(255, 255, 255, 0.12);"
        "font-family: Roboto;"
        "font-size: 14px;"
        "border-radius: 5px;"
        "color: white;"
        "font-weight: 500;"
        "text-decoration: none;"
        "line-height: 36px;");
    EventListener* listener = MediaDownloadEventListener::create();
    anchor->addEventListener(EventTypeNames::click, listener, false);
    HTMLDivElement* buttonContainer = HTMLDivElement::create(*document());
    buttonContainer->setAttribute(styleAttr,
                                  "text-align: center;"
                                  "height: 0;"
                                  "flex: none");
    buttonContainer->appendChild(anchor);
    div->appendChild(buttonContainer);
    recordDownloadMetric(MediaDocumentDownloadButtonShown);
  }

  // According to
  // https://html.spec.whatwg.org/multipage/browsers.html#read-media,
  // MediaDocument should have a single child which is the video element. Use
  // shadow root to hide all the elements we added here.
  ShadowRoot& shadowRoot = body->ensureUserAgentShadowRoot();
  shadowRoot.appendChild(div);
  body->appendChild(media);
  rootElement->appendChild(head);
  rootElement->appendChild(body);

  m_didBuildDocumentStructure = true;
}
Ejemplo n.º 11
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);
}
Ejemplo n.º 12
0
 static v8::Handle<v8::Value> alignAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) {
   INC_STATS("DOM.HTMLDivElement.align._get");
   HTMLDivElement* imp = V8HTMLDivElement::toNative(info.Holder());
   return v8String(imp->align());
 }
Ejemplo n.º 13
0
void setJSHTMLDivElementAlign(ExecState* exec, JSObject* thisObject, JSValue value)
{
    JSHTMLDivElement* castedThis = static_cast<JSHTMLDivElement*>(thisObject);
    HTMLDivElement* imp = static_cast<HTMLDivElement*>(castedThis->impl());
    imp->setAttribute(WebCore::HTMLNames::alignAttr, valueToStringWithNullCheck(exec, value));
}