예제 #1
0
void TextFieldInputType::createShadowSubtree()
{
    ASSERT(element()->hasShadowRoot());

    ASSERT(!m_innerText);
    ASSERT(!m_innerBlock);
    ASSERT(!m_innerSpinButton);

    Document* document = element()->document();
    ChromeClient* chromeClient = document->page() ? document->page()->chrome()->client() : 0;
    bool shouldAddDecorations = chromeClient && chromeClient->willAddTextFieldDecorationsTo(element());
    bool shouldHaveSpinButton = this->shouldHaveSpinButton();
    bool createsContainer = shouldHaveSpinButton || needsContainer() || shouldAddDecorations;

    ExceptionCode ec = 0;
    m_innerText = TextControlInnerTextElement::create(document);
    if (!createsContainer) {
        element()->shadowTree()->oldestShadowRoot()->appendChild(m_innerText, ec);
        return;
    }

    ShadowRoot* shadowRoot = element()->shadowTree()->oldestShadowRoot();
    m_container = HTMLDivElement::create(document);
    m_container->setShadowPseudoId("-webkit-textfield-decoration-container");
    shadowRoot->appendChild(m_container, ec);

    m_innerBlock = TextControlInnerElement::create(document);
    m_innerBlock->appendChild(m_innerText, ec);
    m_container->appendChild(m_innerBlock, ec);

#if ENABLE(INPUT_SPEECH)
    ASSERT(!m_speechButton);
    if (element()->isSpeechEnabled()) {
        m_speechButton = InputFieldSpeechButtonElement::create(document);
        m_container->appendChild(m_speechButton, ec);
    }
#endif

    if (shouldHaveSpinButton) {
        m_innerSpinButton = SpinButtonElement::create(document);
        m_container->appendChild(m_innerSpinButton, ec);
    }

    if (shouldAddDecorations)
        chromeClient->addTextFieldDecorationsTo(element());
}
예제 #2
0
void TextFieldInputType::createShadowSubtree()
{
    ASSERT(element()->shadow());

    ASSERT(!m_innerText);
    ASSERT(!m_innerBlock);
    ASSERT(!m_innerSpinButton);

    Document* document = element()->document();
    ChromeClient* chromeClient = document->page() ? document->page()->chrome()->client() : 0;
    bool shouldAddDecorations = chromeClient && chromeClient->willAddTextFieldDecorationsTo(element());
    bool shouldHaveSpinButton = this->shouldHaveSpinButton();
    bool createsContainer = shouldHaveSpinButton || needsContainer() || shouldAddDecorations;

    m_innerText = TextControlInnerTextElement::create(document);
    if (!createsContainer) {
        element()->userAgentShadowRoot()->appendChild(m_innerText, IGNORE_EXCEPTION);
        return;
    }

    ShadowRoot* shadowRoot = element()->userAgentShadowRoot();
    m_container = TextControlInnerContainer::create(document);
    m_container->setPseudo(AtomicString("-webkit-textfield-decoration-container", AtomicString::ConstructFromLiteral));
    shadowRoot->appendChild(m_container, IGNORE_EXCEPTION);

    m_innerBlock = TextControlInnerElement::create(document);
    m_innerBlock->appendChild(m_innerText, IGNORE_EXCEPTION);
    m_container->appendChild(m_innerBlock, IGNORE_EXCEPTION);

#if ENABLE(INPUT_SPEECH)
    ASSERT(!m_speechButton);
    if (element()->isSpeechEnabled()) {
        m_speechButton = InputFieldSpeechButtonElement::create(document);
        m_container->appendChild(m_speechButton, IGNORE_EXCEPTION);
    }
#endif

    if (shouldHaveSpinButton) {
        m_innerSpinButton = SpinButtonElement::create(document, *this);
        m_container->appendChild(m_innerSpinButton, IGNORE_EXCEPTION);
    }

    if (shouldAddDecorations)
        chromeClient->addTextFieldDecorationsTo(element());
}