Title: [114360] trunk/Source/WebCore
Revision
114360
Author
tk...@chromium.org
Date
2012-04-17 01:36:38 -0700 (Tue, 17 Apr 2012)

Log Message

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 <input> without the palceholder attribute support. This
doesn't change any behavior of input types which support the
'placeholder' attribute.

According to the standard, <input type=date> 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().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (114359 => 114360)


--- trunk/Source/WebCore/ChangeLog	2012-04-17 08:20:38 UTC (rev 114359)
+++ trunk/Source/WebCore/ChangeLog	2012-04-17 08:36:38 UTC (rev 114360)
@@ -1,5 +1,40 @@
 2012-04-17  Kent Tamura  <tk...@chromium.org>
 
+        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 <input> without the palceholder attribute support. This
+        doesn't change any behavior of input types which support the
+        'placeholder' attribute.
+
+        According to the standard, <input type=date> 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  <tk...@chromium.org>
+
         Move some code of LocalizedNumberICU.cpp to ICULocale.cpp
         https://bugs.webkit.org/show_bug.cgi?id=84128
 

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (114359 => 114360)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-04-17 08:20:38 UTC (rev 114359)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-04-17 08:36:38 UTC (rev 114360)
@@ -1759,6 +1759,13 @@
     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();

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (114359 => 114360)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2012-04-17 08:20:38 UTC (rev 114359)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2012-04-17 08:36:38 UTC (rev 114360)
@@ -311,6 +311,7 @@
     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(); }

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (114359 => 114360)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2012-04-17 08:20:38 UTC (rev 114359)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2012-04-17 08:36:38 UTC (rev 114360)
@@ -87,6 +87,7 @@
 
 protected:
     HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);
+    virtual bool isPlaceholderEmpty() const;
     virtual void updatePlaceholderText() = 0;
 
     virtual void parseAttribute(Attribute*) OVERRIDE;
@@ -117,8 +118,6 @@
     virtual void dispatchBlurEvent(PassRefPtr<Node> 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.

Modified: trunk/Source/WebCore/html/InputType.cpp (114359 => 114360)


--- trunk/Source/WebCore/html/InputType.cpp	2012-04-17 08:20:38 UTC (rev 114359)
+++ trunk/Source/WebCore/html/InputType.cpp	2012-04-17 08:36:38 UTC (rev 114360)
@@ -728,6 +728,16 @@
     return false;
 }
 
+bool InputType::usesFixedPlaceholder() const
+{
+    return false;
+}
+
+String InputType::fixedPlaceholder()
+{
+    return String();
+}
+
 void InputType::updatePlaceholderText()
 {
 }

Modified: trunk/Source/WebCore/html/InputType.h (114359 => 114360)


--- trunk/Source/WebCore/html/InputType.h	2012-04-17 08:20:38 UTC (rev 114359)
+++ trunk/Source/WebCore/html/InputType.h	2012-04-17 08:36:38 UTC (rev 114360)
@@ -235,7 +235,14 @@
     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();

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (114359 => 114360)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2012-04-17 08:20:38 UTC (rev 114359)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2012-04-17 08:36:38 UTC (rev 114360)
@@ -393,7 +393,7 @@
     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);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to