diff options
author | Steve Block <steveblock@google.com> | 2009-10-08 17:19:54 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2009-10-20 00:41:58 +0100 |
commit | 231d4e3152a9c27a73b6ac7badbe6be673aa3ddf (patch) | |
tree | a6c7e2d6cd7bfa7011cc39abbb436142d7a4a7c8 /WebCore/rendering/RenderTextControlSingleLine.cpp | |
parent | e196732677050bd463301566a68a643b6d14b907 (diff) | |
download | external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.zip external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.gz external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.bz2 |
Merge webkit.org at R49305 : Automatic merge by git.
Change-Id: I8968561bc1bfd72b8923b7118d3728579c6dbcc7
Diffstat (limited to 'WebCore/rendering/RenderTextControlSingleLine.cpp')
-rw-r--r-- | WebCore/rendering/RenderTextControlSingleLine.cpp | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/WebCore/rendering/RenderTextControlSingleLine.cpp b/WebCore/rendering/RenderTextControlSingleLine.cpp index b448eb7..dd1c24c 100644 --- a/WebCore/rendering/RenderTextControlSingleLine.cpp +++ b/WebCore/rendering/RenderTextControlSingleLine.cpp @@ -48,9 +48,8 @@ namespace WebCore { using namespace HTMLNames; -RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node) - : RenderTextControl(node) - , m_placeholderVisible(false) +RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node, bool placeholderVisible) + : RenderTextControl(node, placeholderVisible) , m_searchPopupIsVisible(false) , m_shouldDrawCapsLockIndicator(false) , m_searchEventTimer(this, &RenderTextControlSingleLine::searchEventTimerFired) @@ -69,25 +68,9 @@ RenderTextControlSingleLine::~RenderTextControlSingleLine() m_innerBlock->detach(); } -bool RenderTextControlSingleLine::placeholderShouldBeVisible() const +RenderStyle* RenderTextControlSingleLine::textBaseStyle() const { - return inputElement()->placeholderShouldBeVisible(); -} - -void RenderTextControlSingleLine::updatePlaceholderVisibility() -{ - RenderStyle* parentStyle = m_innerBlock ? m_innerBlock->renderer()->style() : style(); - - RefPtr<RenderStyle> textBlockStyle = createInnerTextStyle(parentStyle); - HTMLElement* innerText = innerTextElement(); - innerText->renderer()->setStyle(textBlockStyle); - - for (Node* n = innerText->firstChild(); n; n = n->traverseNextNode(innerText)) { - if (RenderObject* renderer = n->renderer()) - renderer->setStyle(textBlockStyle); - } - - updateFromElement(); + return m_innerBlock ? m_innerBlock->renderer()->style() : style(); } void RenderTextControlSingleLine::addSearchResult() @@ -163,8 +146,6 @@ void RenderTextControlSingleLine::hidePopup() ASSERT(node()->isHTMLElement()); if (m_searchPopup) m_searchPopup->hide(); - - m_searchPopupIsVisible = false; } void RenderTextControlSingleLine::subtreeHasChanged() @@ -173,7 +154,11 @@ void RenderTextControlSingleLine::subtreeHasChanged() RenderTextControl::subtreeHasChanged(); InputElement* input = inputElement(); - input->setValueFromRenderer(input->constrainValue(text())); + // We don't need to call sanitizeUserInputValue() function here because + // InputElement::handleBeforeTextInsertedEvent() has already called + // sanitizeUserInputValue(). + // sanitizeValue() is needed because IME input doesn't dispatch BeforeTextInsertedEvent. + input->setValueFromRenderer(input->sanitizeValue(text())); if (m_cancelButton) updateCancelButtonVisibility(); @@ -480,17 +465,14 @@ void RenderTextControlSingleLine::updateFromElement() createSubtreeIfNeeded(); RenderTextControl::updateFromElement(); - bool placeholderVisibilityShouldChange = m_placeholderVisible != placeholderShouldBeVisible(); - m_placeholderVisible = placeholderShouldBeVisible(); - if (m_cancelButton) updateCancelButtonVisibility(); if (m_placeholderVisible) { ExceptionCode ec = 0; - innerTextElement()->setInnerText(inputElement()->placeholder(), ec); + innerTextElement()->setInnerText(static_cast<Element*>(node())->getAttribute(placeholderAttr), ec); ASSERT(!ec); - } else if (!static_cast<Element*>(node())->formControlValueMatchesRenderer() || placeholderVisibilityShouldChange) + } else setInnerTextValue(inputElement()->value()); if (m_searchPopupIsVisible) @@ -505,7 +487,7 @@ void RenderTextControlSingleLine::cacheSelection(int start, int end) PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerTextStyle(const RenderStyle* startStyle) const { RefPtr<RenderStyle> textBlockStyle; - if (placeholderShouldBeVisible()) { + if (m_placeholderVisible) { if (RenderStyle* pseudoStyle = getCachedPseudoStyle(INPUT_PLACEHOLDER)) textBlockStyle = RenderStyle::clone(pseudoStyle); } @@ -535,7 +517,7 @@ PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerTextStyle(const // After this, updateFromElement will immediately update the text displayed. // When the placeholder is no longer visible, updatePlaceholderVisiblity will reset the style, // and the text security mode will be set back to the computed value correctly. - if (placeholderShouldBeVisible()) + if (m_placeholderVisible) textBlockStyle->setTextSecurity(TSNONE); return textBlockStyle.release(); @@ -753,6 +735,11 @@ int RenderTextControlSingleLine::selectedIndex() const return -1; } +void RenderTextControlSingleLine::popupDidHide() +{ + m_searchPopupIsVisible = false; +} + bool RenderTextControlSingleLine::itemIsSeparator(unsigned listIndex) const { // The separator will be the second to last item in our list. @@ -832,12 +819,12 @@ void RenderTextControlSingleLine::setScrollTop(int newTop) innerTextElement()->setScrollTop(newTop); } -bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier) +bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode) { RenderLayer* layer = innerTextElement()->renderBox()->layer(); if (layer && layer->scroll(direction, granularity, multiplier)) return true; - return RenderBlock::scroll(direction, granularity, multiplier); + return RenderBlock::scroll(direction, granularity, multiplier, stopNode); } PassRefPtr<Scrollbar> RenderTextControlSingleLine::createScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) |