Beispiel #1
0
void BaseMultipleFieldsDateAndTimeInputType::createShadowSubtree()
{
    ASSERT(element()->shadow());

    Document* document = element()->document();
    ContainerNode* container = element()->userAgentShadowRoot();

    RefPtr<DateTimeEditElement> dateTimeEditElement(DateTimeEditElement::create(document, *this));
    m_dateTimeEditElement = dateTimeEditElement.get();
    container->appendChild(m_dateTimeEditElement);
    updateInnerTextValue();

    RefPtr<SpinButtonElement> spinButton = SpinButtonElement::create(document, *this);
    m_spinButtonElement = spinButton.get();
    container->appendChild(spinButton);

    bool shouldAddPickerIndicator = false;
#if ENABLE(DATALIST_ELEMENT)
    if (InputType::themeSupportsDataListUI(this))
        shouldAddPickerIndicator = true;
#endif
    RefPtr<RenderTheme> theme = document->page() ? document->page()->theme() : RenderTheme::defaultTheme();
    if (theme->supportsCalendarPicker(formControlType())) {
        shouldAddPickerIndicator = true;
        m_pickerIndicatorIsAlwaysVisible = true;
    }
    if (shouldAddPickerIndicator) {
        RefPtr<PickerIndicatorElement> pickerElement = PickerIndicatorElement::create(document, *this);
        m_pickerIndicatorElement = pickerElement.get();
        container->appendChild(m_pickerIndicatorElement);
        m_pickerIndicatorIsVisible = true;
        updatePickerIndicatorVisibility();
    }
}
void PluginPlaceholderImpl::loadIntoContainer(ContainerNode& container)
{
    m_placeholderElement->remove(ASSERT_NO_EXCEPTION);
    update();
    container.removeChildren();
    container.appendChild(m_placeholderElement);
}
Beispiel #3
0
void SVGUseElement::cloneTarget(ContainerNode& container, SVGElement& target) const
{
    Ref<SVGElement> targetClone = static_pointer_cast<SVGElement>(target.cloneElementWithChildren(document())).releaseNonNull();
    associateClonesWithOriginals(targetClone.get(), target);
    removeDisallowedElementsFromSubtree(targetClone.get());
    transferSizeAttributesToTargetClone(targetClone.get());
    container.appendChild(WTF::move(targetClone));
}
Beispiel #4
0
static void fillContainerFromString(ContainerNode& paragraph, const String& string)
{
    Document& document = paragraph.document();

    if (string.isEmpty()) {
        paragraph.appendChild(createBlockPlaceholderElement(document), ASSERT_NO_EXCEPTION);
        return;
    }

    ASSERT(string.find('\n') == notFound);

    Vector<String> tabList;
    string.split('\t', true, tabList);
    String tabText = emptyString();
    bool first = true;
    size_t numEntries = tabList.size();
    for (size_t i = 0; i < numEntries; ++i) {
        const String& s = tabList[i];

        // append the non-tab textual part
        if (!s.isEmpty()) {
            if (!tabText.isEmpty()) {
                paragraph.appendChild(createTabSpanElement(document, tabText), ASSERT_NO_EXCEPTION);
                tabText = emptyString();
            }
            Ref<Node> textNode = document.createTextNode(stringWithRebalancedWhitespace(s, first, i + 1 == numEntries));
            paragraph.appendChild(WTF::move(textNode), ASSERT_NO_EXCEPTION);
        }

        // there is a tab after every entry, except the last entry
        // (if the last character is a tab, the list gets an extra empty entry)
        if (i + 1 != numEntries)
            tabText.append('\t');
        else if (!tabText.isEmpty())
            paragraph.appendChild(createTabSpanElement(document, tabText), ASSERT_NO_EXCEPTION);

        first = false;
    }
}
void MultipleFieldsTemporalInputTypeView::createShadowSubtree() {
  DCHECK(element().shadow());

  // Element must not have a layoutObject here, because if it did
  // DateTimeEditElement::customStyleForLayoutObject() is called in
  // appendChild() before the field wrapper element is created.
  // FIXME: This code should not depend on such craziness.
  DCHECK(!element().layoutObject());

  Document& document = element().document();
  ContainerNode* container = element().userAgentShadowRoot();

  container->appendChild(DateTimeEditElement::create(document, *this));
  element().updateView();
  container->appendChild(ClearButtonElement::create(document, *this));
  container->appendChild(SpinButtonElement::create(document, *this));

  if (LayoutTheme::theme().supportsCalendarPicker(
          m_inputType->formControlType()))
    m_pickerIndicatorIsAlwaysVisible = true;
  container->appendChild(PickerIndicatorElement::create(document, *this));
  m_pickerIndicatorIsVisible = true;
  updatePickerIndicatorVisibility();
}
void BaseMultipleFieldsDateAndTimeInputType::createShadowSubtree()
{
    ASSERT(element().shadow());

    // Element must not have a renderer here, because if it did
    // DateTimeEditElement::customStyleForRenderer() is called in appendChild()
    // before the field wrapper element is created.
    // FIXME: This code should not depend on such craziness.
    ASSERT(!element().renderer());

    Document& document = element().document();
    ContainerNode* container = element().userAgentShadowRoot();

    container->appendChild(DateTimeEditElement::create(document, *this));
    element().updateView();
    container->appendChild(ClearButtonElement::create(document, *this));
    container->appendChild(SpinButtonElement::create(document, *this));

    if (RenderTheme::theme().supportsCalendarPicker(formControlType()))
        m_pickerIndicatorIsAlwaysVisible = true;
    container->appendChild(PickerIndicatorElement::create(document, *this));
    m_pickerIndicatorIsVisible = true;
    updatePickerIndicatorVisibility();
}
InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* document, bool createIfAbsent)
{
    if (!document) {
        ASSERT(!createIfAbsent);
        return 0;
    }

    RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToInspectorStyleSheet.get(document);
    if (inspectorStyleSheet || !createIfAbsent)
        return inspectorStyleSheet.get();

    ExceptionCode ec = 0;
    RefPtr<Element> styleElement = document->createElement("style", ec);
    if (!ec)
        styleElement->setAttribute("type", "text/css", ec);
    if (!ec) {
        ContainerNode* targetNode;
        // HEAD is absent in ImageDocuments, for example.
        if (document->head())
            targetNode = document->head();
        else if (document->body())
            targetNode = document->body();
        else
            return 0;
        targetNode->appendChild(styleElement, ec);
    }
    if (ec)
        return 0;
    StyleSheetList* styleSheets = document->styleSheets();
    StyleSheet* styleSheet = styleSheets->item(styleSheets->length() - 1);
    if (!styleSheet->isCSSStyleSheet())
        return 0;
    CSSStyleSheet* cssStyleSheet = static_cast<CSSStyleSheet*>(styleSheet);
    String id = String::number(m_lastStyleSheetId++);
    inspectorStyleSheet = InspectorStyleSheet::create(id, cssStyleSheet, "inspector", m_domAgent->documentURLString(document));
    m_idToInspectorStyleSheet.set(id, inspectorStyleSheet);
    m_cssStyleSheetToInspectorStyleSheet.set(cssStyleSheet, inspectorStyleSheet);
    m_documentToInspectorStyleSheet.set(document, inspectorStyleSheet);
    return inspectorStyleSheet.get();
}