From: tkent@chromium.org Date: Tue, 17 Apr 2012 08:36:38 +0000 (+0000) Subject: Introduce an internal feature for a fixed placeholder X-Git-Tag: 070512121124~6826 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f547be300c67b5ec5ffc277d2cf06cca6d88b96;p=profile%2Fivi%2Fwebkit-efl.git Introduce an internal feature for a fixed placeholder https://bugs.webkit.org/show_bug.cgi?id=84009 Reviewed by Hajime Morita. This change adds a framework to support fixed placeholder string for textfield-like without the palceholder attribute support. This doesn't change any behavior of input types which support the 'placeholder' attribute. According to the standard, doesn't support the 'placeholder' attribute. However it is a kind of text field in WebKit platforms with ENABLE_CALENDAR_PICKER, and we may show something useful information as the default placeholder. No new tests because of no behavior changes. * html/HTMLTextFormControlElement.h: (HTMLTextFormControlElement): Make isPlaceholderEmpty() virtual. * html/HTMLInputElement.h: (HTMLInputElement): Overrides isPlaceholderEmpty(). * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::isPlaceholderEmpty): Check InputType::defaultPlaceholder() if InputType::usesFixedPlaceholder(). * html/InputType.cpp: (WebCore::InputType::usesFixedPlaceholder): Added. Returns false. (WebCore::InputType::fixedPlaceholder): Added. Returns a null string. * html/InputType.h: (InputType): Add usesFixedPlaceholder() and fixedPlaceholder(). * html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::updatePlaceholderText): Uses fixedPlaceholder() instead of strippedPlaceholder() if usesFixedPlaceholder(). git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114360 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 49c7181..c6e396f 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,5 +1,40 @@ 2012-04-17 Kent Tamura + Introduce an internal feature for a fixed placeholder + https://bugs.webkit.org/show_bug.cgi?id=84009 + + Reviewed by Hajime Morita. + + This change adds a framework to support fixed placeholder string for + textfield-like without the palceholder attribute support. This + doesn't change any behavior of input types which support the + 'placeholder' attribute. + + According to the standard, doesn't support the + 'placeholder' attribute. However it is a kind of text field in WebKit + platforms with ENABLE_CALENDAR_PICKER, and we may show something useful + information as the default placeholder. + + No new tests because of no behavior changes. + + * html/HTMLTextFormControlElement.h: + (HTMLTextFormControlElement): Make isPlaceholderEmpty() virtual. + * html/HTMLInputElement.h: + (HTMLInputElement): Overrides isPlaceholderEmpty(). + * html/HTMLInputElement.cpp: + (WebCore::HTMLInputElement::isPlaceholderEmpty): + Check InputType::defaultPlaceholder() if InputType::usesFixedPlaceholder(). + * html/InputType.cpp: + (WebCore::InputType::usesFixedPlaceholder): Added. Returns false. + (WebCore::InputType::fixedPlaceholder): Added. Returns a null string. + * html/InputType.h: + (InputType): Add usesFixedPlaceholder() and fixedPlaceholder(). + * html/TextFieldInputType.cpp: + (WebCore::TextFieldInputType::updatePlaceholderText): + Uses fixedPlaceholder() instead of strippedPlaceholder() if usesFixedPlaceholder(). + +2012-04-17 Kent Tamura + Move some code of LocalizedNumberICU.cpp to ICULocale.cpp https://bugs.webkit.org/show_bug.cgi?id=84128 diff --git a/Source/WebCore/html/HTMLInputElement.cpp b/Source/WebCore/html/HTMLInputElement.cpp index 09c52ad..05198d1 100644 --- a/Source/WebCore/html/HTMLInputElement.cpp +++ b/Source/WebCore/html/HTMLInputElement.cpp @@ -1759,6 +1759,13 @@ bool HTMLInputElement::supportsPlaceholder() const return m_inputType->supportsPlaceholder(); } +bool HTMLInputElement::isPlaceholderEmpty() const +{ + if (m_inputType->usesFixedPlaceholder()) + return m_inputType->fixedPlaceholder().isEmpty(); + return HTMLTextFormControlElement::isPlaceholderEmpty(); +} + void HTMLInputElement::updatePlaceholderText() { return m_inputType->updatePlaceholderText(); diff --git a/Source/WebCore/html/HTMLInputElement.h b/Source/WebCore/html/HTMLInputElement.h index 170f973..991a380 100644 --- a/Source/WebCore/html/HTMLInputElement.h +++ b/Source/WebCore/html/HTMLInputElement.h @@ -311,6 +311,7 @@ private: bool isTextType() const; virtual bool supportsPlaceholder() const; + virtual bool isPlaceholderEmpty() const OVERRIDE; virtual void updatePlaceholderText(); virtual bool isEmptyValue() const OVERRIDE { return innerTextValue().isEmpty(); } virtual bool isEmptySuggestedValue() const { return suggestedValue().isEmpty(); } diff --git a/Source/WebCore/html/HTMLTextFormControlElement.h b/Source/WebCore/html/HTMLTextFormControlElement.h index c283055..bad807f 100644 --- a/Source/WebCore/html/HTMLTextFormControlElement.h +++ b/Source/WebCore/html/HTMLTextFormControlElement.h @@ -87,6 +87,7 @@ public: protected: HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*); + virtual bool isPlaceholderEmpty() const; virtual void updatePlaceholderText() = 0; virtual void parseAttribute(Attribute*) OVERRIDE; @@ -117,8 +118,6 @@ private: virtual void dispatchBlurEvent(PassRefPtr newFocusedNode); virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE; - bool isPlaceholderEmpty() const; - // Returns true if user-editable value is empty. Used to check placeholder visibility. virtual bool isEmptyValue() const = 0; // Returns true if suggested value is empty. Used to check placeholder visibility. diff --git a/Source/WebCore/html/InputType.cpp b/Source/WebCore/html/InputType.cpp index 7a9f1b1..9a3da4d 100644 --- a/Source/WebCore/html/InputType.cpp +++ b/Source/WebCore/html/InputType.cpp @@ -728,6 +728,16 @@ bool InputType::supportsPlaceholder() const return false; } +bool InputType::usesFixedPlaceholder() const +{ + return false; +} + +String InputType::fixedPlaceholder() +{ + return String(); +} + void InputType::updatePlaceholderText() { } diff --git a/Source/WebCore/html/InputType.h b/Source/WebCore/html/InputType.h index d79db6f..7316ffd 100644 --- a/Source/WebCore/html/InputType.h +++ b/Source/WebCore/html/InputType.h @@ -235,7 +235,14 @@ public: virtual bool isCheckable(); virtual bool isSteppable() const; virtual bool shouldRespectHeightAndWidthAttributes(); + // If supportsPlaceholder() && !usesFixedPlaceholder(), it means a type + // supports the 'placeholder' attribute. + // If supportsPlaceholder() && usesFixedPlaceholder(), it means a type + // doesn't support the 'placeholder' attribute, but shows + // fixedPlaceholder() string as a placeholder. virtual bool supportsPlaceholder() const; + virtual bool usesFixedPlaceholder() const; + virtual String fixedPlaceholder(); virtual void updatePlaceholderText(); virtual void multipleAttributeChanged(); virtual void disabledAttributeChanged(); diff --git a/Source/WebCore/html/TextFieldInputType.cpp b/Source/WebCore/html/TextFieldInputType.cpp index 5e4962b..f4fc14e 100644 --- a/Source/WebCore/html/TextFieldInputType.cpp +++ b/Source/WebCore/html/TextFieldInputType.cpp @@ -393,7 +393,7 @@ void TextFieldInputType::updatePlaceholderText() if (!supportsPlaceholder()) return; ExceptionCode ec = 0; - String placeholderText = element()->strippedPlaceholder(); + String placeholderText = usesFixedPlaceholder() ? fixedPlaceholder() : element()->strippedPlaceholder(); if (placeholderText.isEmpty()) { if (m_placeholder) { m_placeholder->parentNode()->removeChild(m_placeholder.get(), ec);