void PreviewContentWidget::renderNoPreview(QPainter &p) { const auto nothingToRender = (!isPlaceholderVisible() && !TextControl_); if (nothingToRender) { return; } if (!isPlaceholderVisible()) { prepareTextGeometry(); const QSize newSize( width(), getTextBubbleSize().height() ); if (newSize != LastSize_) { setFixedSize(newSize); LastSize_ = newSize; } return; } updateWidgetSize(); renderPreloader(p); }
void HTMLTextFormControlElement::updatePlaceholderVisibility() { HTMLElement* placeholder = placeholderElement(); if (!placeholder) { updatePlaceholderText(); return; } bool placeHolderWasVisible = isPlaceholderVisible(); setPlaceholderVisibility(placeholderShouldBeVisible()); if (placeHolderWasVisible == isPlaceholderVisible()) return; pseudoStateChanged(CSSSelector::PseudoPlaceholderShown); placeholder->setInlineStyleProperty(CSSPropertyDisplay, isPlaceholderVisible() ? CSSValueBlock : CSSValueNone, true); }
void HTMLTextAreaElement::updatePlaceholderText() { String placeholderText = strippedPlaceholder(); if (placeholderText.isEmpty()) { if (m_placeholder) { userAgentShadowRoot()->removeChild(*m_placeholder, ASSERT_NO_EXCEPTION); m_placeholder = nullptr; } return; } if (!m_placeholder) { RefPtr<HTMLDivElement> placeholder = HTMLDivElement::create(document()); m_placeholder = placeholder.get(); m_placeholder->setPseudo(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral)); m_placeholder->setInlineStyleProperty(CSSPropertyDisplay, isPlaceholderVisible() ? CSSValueBlock : CSSValueNone, true); userAgentShadowRoot()->insertBefore(*m_placeholder, innerTextElement()->nextSibling()); } m_placeholder->setInnerText(placeholderText, ASSERT_NO_EXCEPTION); }
void HTMLTextAreaElement::updatePlaceholderText() { HTMLElement* placeholder = placeholderElement(); const AtomicString& placeholderText = fastGetAttribute(placeholderAttr); if (placeholderText.isEmpty()) { if (placeholder) userAgentShadowRoot()->removeChild(placeholder); return; } if (!placeholder) { RefPtrWillBeRawPtr<HTMLDivElement> newElement = HTMLDivElement::create(document()); placeholder = newElement.get(); placeholder->setShadowPseudoId(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral)); placeholder->setAttribute(idAttr, ShadowElementNames::placeholder()); placeholder->setInlineStyleProperty(CSSPropertyDisplay, isPlaceholderVisible() ? CSSValueBlock : CSSValueNone, true); userAgentShadowRoot()->insertBefore(placeholder, innerEditorElement()->nextSibling()); } placeholder->setTextContent(placeholderText); }