Changeset 90971 in webkit


Ignore:
Timestamp:
Jul 13, 2011 7:16:54 PM (13 years ago)
Author:
tkent@chromium.org
Message:

Implement text field placeholders using shadow DOM
https://bugs.webkit.org/show_bug.cgi?id=64253

Reviewed by Dimitri Glazkov.

Source/WebCore:

Represents a placeholder text as a shadow element, and its
visibility is controlled by 'visibility' CSS property.

This patch removes all of existing code about placeholder from
RenderTextControl*. RenderTextControl* have only small code about
placeholder layout.

Also, this patch removes INPUT_PLACEHOLDER legacy pseudo ID, and
the placeholder style uses Element::shadowPseudoId().

This fixes the following regressions:

Test: fast/forms/textarea-placeholder-wrapping.html

  • css/CSSSelector.cpp: Remove INPUT_PLACEHOLDER legacy pseudo ID.

(WebCore::CSSSelector::pseudoId):
(WebCore::nameToPseudoTypeMap):
(WebCore::CSSSelector::extractPseudoType):

  • css/CSSSelector.h: ditto.
  • css/html.css:

(::-webkit-input-placeholder): Added. This contains properties
common in <input> and <textarea>. Some properties have !important
so that a stylesheet specified by a page author won't break
WebKit's assumption.
(input::-webkit-input-placeholder, isindex::-webkit-input-placeholder):

Added the default style for <input> placeholders.

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::placeholderElement): Delegate to an InputType.
(WebCore::HTMLInputElement::updatePlaceholderText): ditto.

  • html/HTMLInputElement.h: Declare placeholderElement() and updatePlaceholderText().
  • html/HTMLTextAreaElement.cpp:

(WebCore::HTMLTextAreaElement::createRenderer):
Remove the 'placeholderVisible' argument.
(WebCore::HTMLTextAreaElement::placeholderElement): Added.
(WebCore::HTMLTextAreaElement::updatePlaceholderText):

Added. This creates, deletes, or updates the placeholder element.

  • html/HTMLTextAreaElement.h:
  • Declare placeholderElement() and updatePlaceholderText().
  • Add m_placeholder.
  • html/HTMLTextFormControlElement.cpp:

(WebCore::HTMLTextFormControlElement::updatePlaceholderVisibility):
Update the placeholder element and 'visibility' CSS property,
instead of delegating the job to a renderer.

  • html/HTMLTextFormControlElement.h:

Declare two pure virtual functions: placeholderElement() and updatePlaceholderText().

  • html/InputType.cpp:

(WebCore::InputType::placeholderElement): Add an empty implementation.
(WebCore::InputType::updatePlaceholderText): Add an empty implementation.

  • html/InputType.h: Declare placeholderElement() and updatePlaceholderText().
  • html/TextFieldInputType.cpp:

(WebCore::TextFieldInputType::createRenderer):
Remove the 'placeholderVisible' argument.
(WebCore::TextFieldInputType::placeholderElement): Added.
(WebCore::TextFieldInputType::destroyShadowSubtree): Deletes m_placeholder.
(WebCore::TextFieldInputType::updatePlaceholderText):

Added. This creates, deletes, or updates the placeholder element.

  • html/TextFieldInputType.h:
  • Declare placeholderElement() and updatePlaceholderText().
  • Add m_placeholder.
  • rendering/RenderTextControl.cpp:

(WebCore::RenderTextControl::RenderTextControl):
Remove the 'placeholderVisible' argument.
(WebCore::RenderTextControl::layoutSpecialExcludedChild):
Excludes the placeholder renderer in order to avoid to secure a box for
the placeholder.

  • rendering/RenderTextControl.h:
  • Remove declarations of removed functions.
  • Update the RenderTextControl signature.
  • Add layoutSpecialExcludedChild().
  • rendering/RenderTextControlMultiLine.cpp:

(WebCore::RenderTextControlMultiLine::RenderTextControlMultiLine):
Remove the 'placeholderVisible' argument.
(WebCore::RenderTextControlMultiLine::layoutSpecialExcludedChild):
Laying out the placeholder box so that it has correct width and location.

  • rendering/RenderTextControlMultiLine.h:
  • Remove declarations of removed functions.
  • Update the RenderTextControlMultiLine signature.
  • Add layoutSpecialExcludedChild().
  • rendering/RenderTextControlSingleLine.cpp:

(WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
Remove the 'placeholderVisible' argument.
(WebCore::RenderTextControlSingleLine::layout):
Laying out the placeholder box so that it has correct width and location.

  • rendering/RenderTextControlSingleLine.h:
  • Remove declarations of removed functions.
  • Update the RenderTextControlSingleLine signature.
  • rendering/style/RenderStyleConstants.h: Remove INPUT_PLACEHOLDER.

LayoutTests:

Add some test cases, and update expectations because placeholders
have their renderers.

  • fast/forms/input-placeholder-text-indent.html: Remove an obsolete comment. A placeholder respects a percentage indent.
  • fast/forms/placeholder-position.html: Add tests for line-height and text-align.
  • fast/forms/textarea-placeholder-wrapping.html: Added.
  • platform/chromium/test_expectations.txt:
  • platform/gtk/test_expectations.txt:
  • platform/mac/fast/css/pseudo-cache-stale-expected.txt:
  • platform/mac/fast/forms/input-placeholder-text-indent-expected.png:
  • platform/mac/fast/forms/input-placeholder-text-indent-expected.txt:
  • platform/mac/fast/forms/isindex-placeholder-expected.png:
  • platform/mac/fast/forms/isindex-placeholder-expected.txt:
  • platform/mac/fast/forms/password-placeholder-expected.txt:
  • platform/mac/fast/forms/password-placeholder-text-security-expected.png:
  • platform/mac/fast/forms/password-placeholder-text-security-expected.txt:
  • platform/mac/fast/forms/placeholder-position-expected.png:
  • platform/mac/fast/forms/placeholder-position-expected.txt:
  • platform/mac/fast/forms/placeholder-pseudo-style-expected.png:
  • platform/mac/fast/forms/placeholder-pseudo-style-expected.txt:
  • platform/mac/fast/forms/placeholder-set-attribute-expected.txt:
  • platform/mac/fast/forms/placeholder-stripped-expected.txt:
  • platform/mac/fast/forms/search-placeholder-value-changed-expected.txt:
  • platform/mac/fast/forms/search-styled-expected.png:
  • platform/mac/fast/forms/search-styled-expected.txt:
  • platform/mac/fast/forms/textarea-placeholder-pseudo-style-expected.txt:
  • platform/mac/fast/forms/textarea-placeholder-set-attribute-expected.txt:
  • platform/mac/fast/forms/textarea-placeholder-wrapping-expected.png: Added.
  • platform/mac/fast/forms/textarea-placeholder-wrapping-expected.txt: Added.
  • platform/qt/test_expectations.txt:
Location:
trunk
Files:
3 added
47 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r90966 r90971  
     12011-07-13  Kent Tamura  <tkent@chromium.org>
     2
     3        Implement text field placeholders using shadow DOM
     4        https://bugs.webkit.org/show_bug.cgi?id=64253
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Add some test cases, and update expectations because placeholders
     9        have their renderers.
     10
     11        * fast/forms/input-placeholder-text-indent.html:
     12          Remove an obsolete comment. A placeholder respects a percentage indent.
     13        * fast/forms/placeholder-position.html:
     14          Add tests for line-height and text-align.
     15        * fast/forms/textarea-placeholder-wrapping.html: Added.
     16        * platform/chromium/test_expectations.txt:
     17        * platform/gtk/test_expectations.txt:
     18        * platform/mac/fast/css/pseudo-cache-stale-expected.txt:
     19        * platform/mac/fast/forms/input-placeholder-text-indent-expected.png:
     20        * platform/mac/fast/forms/input-placeholder-text-indent-expected.txt:
     21        * platform/mac/fast/forms/isindex-placeholder-expected.png:
     22        * platform/mac/fast/forms/isindex-placeholder-expected.txt:
     23        * platform/mac/fast/forms/password-placeholder-expected.txt:
     24        * platform/mac/fast/forms/password-placeholder-text-security-expected.png:
     25        * platform/mac/fast/forms/password-placeholder-text-security-expected.txt:
     26        * platform/mac/fast/forms/placeholder-position-expected.png:
     27        * platform/mac/fast/forms/placeholder-position-expected.txt:
     28        * platform/mac/fast/forms/placeholder-pseudo-style-expected.png:
     29        * platform/mac/fast/forms/placeholder-pseudo-style-expected.txt:
     30        * platform/mac/fast/forms/placeholder-set-attribute-expected.txt:
     31        * platform/mac/fast/forms/placeholder-stripped-expected.txt:
     32        * platform/mac/fast/forms/search-placeholder-value-changed-expected.txt:
     33        * platform/mac/fast/forms/search-styled-expected.png:
     34        * platform/mac/fast/forms/search-styled-expected.txt:
     35        * platform/mac/fast/forms/textarea-placeholder-pseudo-style-expected.txt:
     36        * platform/mac/fast/forms/textarea-placeholder-set-attribute-expected.txt:
     37        * platform/mac/fast/forms/textarea-placeholder-wrapping-expected.png: Added.
     38        * platform/mac/fast/forms/textarea-placeholder-wrapping-expected.txt: Added.
     39        * platform/qt/test_expectations.txt:
     40
    1412011-07-13  Mihnea Ovidenie  <mihnea@adobe.com>
    242
  • trunk/LayoutTests/fast/forms/input-placeholder-text-indent.html

    r85560 r90971  
    55input.c::-webkit-input-placeholder { text-indent: 200px; }
    66input.d::-webkit-input-placeholder { text-indent: -10px; }
    7 input.e::-webkit-input-placeholder { text-indent: 50%; } /* Ignored. */
     7input.e::-webkit-input-placeholder { text-indent: 50%; }
    88</style>
    99
  • trunk/LayoutTests/fast/forms/placeholder-position.html

    r79284 r90971  
     1<style>
     2.center::-webkit-input-placeholder {
     3    text-align: center;
     4}
     5</style>
    16<!-- This tests that the placeholder is positioned correctly in different kinds of elements -->
    27<input type="search" placeholder="placeholder"><br>
     
    813<textarea placeholder="placeholder" style="padding-top: 15px;"></textarea><br>
    914<input type="text" placeholder="placeholder" style="font-size: 15px; border: solid 5px black; margin: 5px;"><br>
     15
     16<input value="Value" style="line-height: 25px;">
     17<input placeholder="placeholder" style="line-height: 25px;"> <br>
     18
     19<input value="Value" style="text-align: center;">
     20<input placeholder="placeholder" style="text-align: center;">
     21<input placeholder="placeholder" class="center"> <br>
     22
    1023<input type="text" placeholder="placeholder" style="padding-top: 15px; -webkit-transform: translateY(30px) rotateZ(30deg)"><br>
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r90960 r90971  
    37073707BUGWK59921 WIN LINUX : inspector/debugger/debugger-scripts.html = TEXT PASS
    37083708
     3709// Needs new baseline.
     3710BUGWK64253 : fast/css/pseudo-cache-stale.html = FAIL
     3711BUGWK64253 : fast/forms/input-placeholder-text-indent.html = FAIL
     3712BUGWK64253 : fast/forms/isindex-placeholder.html = FAIL
     3713BUGWK64253 : fast/forms/password-placeholder-text-security.html = FAIL
     3714BUGWK64253 : fast/forms/password-placeholder.html = FAIL
     3715BUGWK64253 : fast/forms/placeholder-position.html = FAIL
     3716BUGWK64253 : fast/forms/placeholder-pseudo-style.html = FAIL
     3717BUGWK64253 : fast/forms/placeholder-set-attribute.html = FAIL
     3718BUGWK64253 : fast/forms/placeholder-stripped.html = FAIL
     3719BUGWK64253 : fast/forms/search-placeholder-value-changed.html = FAIL
     3720BUGWK64253 : fast/forms/search-styled.html = FAIL
     3721BUGWK64253 : fast/forms/textarea-placeholder-pseudo-style.html = FAIL
     3722BUGWK64253 : fast/forms/textarea-placeholder-set-attribute.html = FAIL
     3723BUGWK64253 : fast/forms/textarea-placeholder-wrapping.html = FAIL
     3724
    37093725// Has been flaky/crashy for a while
    37103726BUGCR86359 WIN : fast/dom/DeviceOrientation/add-listener-from-callback.html = CRASH PASS
  • trunk/LayoutTests/platform/gtk/test_expectations.txt

    r90792 r90971  
    33// See http://trac.webkit.org/wiki/TestExpectations for more information on this file.
    44
     5// Needs new baseline.
     6BUGWK64253 : fast/css/pseudo-cache-stale.html = FAIL
     7BUGWK64253 : fast/forms/input-placeholder-text-indent.html = FAIL
     8BUGWK64253 : fast/forms/isindex-placeholder.html = FAIL
     9BUGWK64253 : fast/forms/password-placeholder-text-security.html = FAIL
     10BUGWK64253 : fast/forms/password-placeholder.html = FAIL
     11BUGWK64253 : fast/forms/placeholder-position.html = FAIL
     12BUGWK64253 : fast/forms/placeholder-pseudo-style.html = FAIL
     13BUGWK64253 : fast/forms/placeholder-set-attribute.html = FAIL
     14BUGWK64253 : fast/forms/placeholder-stripped.html = FAIL
     15BUGWK64253 : fast/forms/search-placeholder-value-changed.html = FAIL
     16BUGWK64253 : fast/forms/search-styled.html = FAIL
     17BUGWK64253 : fast/forms/textarea-placeholder-pseudo-style.html = FAIL
     18BUGWK64253 : fast/forms/textarea-placeholder-set-attribute.html = FAIL
     19BUGWK64253 : fast/forms/textarea-placeholder-wrapping.html = FAIL
  • trunk/LayoutTests/platform/mac/fast/css/pseudo-cache-stale-expected.txt

    r90089 r90971  
    2323layer at (21,87) size 98x13
    2424  RenderBlock {DIV} at (0,0) size 98x13
     25layer at (21,87) size 98x13 scrollWidth 115
     26  RenderBlock (relative positioned) {DIV} at (11,3) size 98x13 [color=#008000]
     27    RenderText {#text} at (1,0) size 113x13
     28      text run at (1,0) width 113: "This should be green"
  • trunk/LayoutTests/platform/mac/fast/forms/input-placeholder-text-indent-expected.txt

    r85560 r90971  
    5454layer at (295,508) size 494x35
    5555  RenderBlock {DIV} at (3,3) size 494x35
     56layer at (11,13) size 494x35
     57  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     58    RenderText {#text} at (1,0) size 170x35
     59      text run at (1,0) width 170: "placeholder"
     60layer at (11,58) size 494x35
     61  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     62    RenderText {#text} at (1,0) size 170x35
     63      text run at (1,0) width 170: "placeholder"
     64layer at (11,103) size 494x35
     65  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     66    RenderText {#text} at (11,0) size 170x35
     67      text run at (11,0) width 170: "placeholder"
     68layer at (11,148) size 494x35
     69  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     70    RenderText {#text} at (201,0) size 170x35
     71      text run at (201,0) width 170: "placeholder"
     72layer at (11,193) size 494x35
     73  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     74    RenderText {#text} at (-9,0) size 170x35
     75      text run at (-9,0) width 170: "placeholder"
     76layer at (11,238) size 494x35
     77  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     78    RenderText {#text} at (248,0) size 170x35
     79      text run at (248,0) width 170: "placeholder"
     80layer at (295,283) size 494x35
     81  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     82    RenderText {#text} at (323,0) size 170x35
     83      text run at (323,0) width 170: "placeholder"
     84layer at (295,328) size 494x35
     85  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     86    RenderText {#text} at (323,0) size 170x35
     87      text run at (323,0) width 170: "placeholder"
     88layer at (295,373) size 494x35
     89  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     90    RenderText {#text} at (313,0) size 170x35
     91      text run at (313,0) width 170: "placeholder"
     92layer at (295,418) size 494x35
     93  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     94    RenderText {#text} at (123,0) size 170x35
     95      text run at (123,0) width 170: "placeholder"
     96layer at (295,463) size 494x35
     97  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     98    RenderText {#text} at (333,0) size 170x35
     99      text run at (333,0) width 170: "placeholder"
     100layer at (295,508) size 494x35
     101  RenderBlock (relative positioned) {DIV} at (3,3) size 494x35 [color=#A9A9A9]
     102    RenderText {#text} at (76,0) size 170x35
     103      text run at (76,0) width 170: "placeholder"
  • trunk/LayoutTests/platform/mac/fast/forms/isindex-placeholder-expected.txt

    r72052 r90971  
    3838layer at (335,168) size 119x13
    3939  RenderBlock {DIV} at (3,3) size 119x13
     40layer at (335,83) size 119x13
     41  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     42    RenderText {#text} at (1,0) size 63x13
     43      text run at (1,0) width 63: "placeholder"
     44layer at (335,168) size 119x13
     45  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#008000]
     46    RenderText {#text} at (1,0) size 63x13
     47      text run at (1,0) width 63: "placeholder"
  • trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.txt

    r72052 r90971  
    88layer at (13,13) size 119x13
    99  RenderBlock {DIV} at (3,3) size 119x13
     10layer at (13,13) size 119x13
     11  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     12    RenderText {#text} at (1,0) size 36x13
     13      text run at (1,0) width 36: "foobar"
  • trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.txt

    r72052 r90971  
    3030layer at (603,77) size 119x13
    3131  RenderBlock {DIV} at (3,3) size 119x13
     32layer at (370,31) size 119x13
     33  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     34    RenderText {#text} at (1,0) size 63x13
     35      text run at (1,0) width 63: "placeholder"
     36layer at (603,77) size 119x13
     37  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     38    RenderText {#text} at (1,0) size 63x13
     39      text run at (1,0) width 63: "placeholder"
  • trunk/LayoutTests/platform/mac/fast/forms/placeholder-position-expected.txt

    r90089 r90971  
    3030      RenderTextControl {INPUT} at (5,219) size 176x30 [bgcolor=#FFFFFF] [border: (5px solid #000000)]
    3131      RenderBR {BR} at (186,240) size 0x0
    32       RenderBR {BR} at (129,284) size 0x0
     32      RenderTextControl {INPUT} at (2,256) size 125x31 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     33      RenderText {#text} at (129,262) size 4x18
     34        text run at (129,262) width 4: " "
     35      RenderTextControl {INPUT} at (135,256) size 125x31 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     36      RenderText {#text} at (262,262) size 4x18
     37        text run at (262,262) width 4: " "
     38      RenderBR {BR} at (266,276) size 0x0
     39      RenderTextControl {INPUT} at (2,291) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     40      RenderText {#text} at (129,291) size 4x18
     41        text run at (129,291) width 4: " "
     42      RenderTextControl {INPUT} at (135,291) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     43      RenderText {#text} at (262,291) size 4x18
     44        text run at (262,291) width 4: " "
     45      RenderTextControl {INPUT} at (268,291) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     46      RenderText {#text} at (395,291) size 4x18
     47        text run at (395,291) width 4: " "
     48      RenderBR {BR} at (399,305) size 0x0
     49      RenderBR {BR} at (129,342) size 0x0
    3350layer at (21,13) size 98x13
    3451  RenderBlock {DIV} at (0,0) size 98x13
     
    4966layer at (19,233) size 164x18
    5067  RenderBlock {DIV} at (6,6) size 164x18
    51 layer at (10,264) size 125x33
    52   RenderTextControl {INPUT} at (2,256) size 125x33 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
    53 layer at (13,281) size 119x13
     68layer at (13,267) size 119x25
     69  RenderBlock {DIV} at (3,3) size 119x25
     70    RenderText {#text} at (1,6) size 30x13
     71      text run at (1,6) width 30: "Value"
     72layer at (146,267) size 119x25
     73  RenderBlock {DIV} at (3,3) size 119x25
     74layer at (13,302) size 119x13
     75  RenderBlock {DIV} at (3,3) size 119x13
     76    RenderText {#text} at (44,0) size 31x13
     77      text run at (44,0) width 31: "Value"
     78layer at (146,302) size 119x13
     79  RenderBlock {DIV} at (3,3) size 119x13
     80layer at (279,302) size 119x13
     81  RenderBlock {DIV} at (3,3) size 119x13
     82layer at (21,13) size 98x13
     83  RenderBlock (relative positioned) {DIV} at (11,3) size 98x13 [color=#A9A9A9]
     84    RenderText {#text} at (1,0) size 63x13
     85      text run at (1,0) width 63: "placeholder"
     86layer at (13,36) size 119x13
     87  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     88    RenderText {#text} at (1,0) size 63x13
     89      text run at (1,0) width 63: "placeholder"
     90layer at (21,59) size 98x13
     91  RenderBlock (relative positioned) {DIV} at (11,3) size 98x13 [color=#A9A9A9]
     92    RenderText {#text} at (34,0) size 63x13
     93      text run at (34,0) width 63: "placeholder"
     94layer at (35,82) size 84x13
     95  RenderBlock (relative positioned) {DIV} at (25,3) size 84x13 [color=#A9A9A9]
     96    RenderText {#text} at (1,0) size 63x13
     97      text run at (1,0) width 63: "placeholder"
     98layer at (13,105) size 155x13
     99  RenderBlock (relative positioned) {DIV} at (3,3) size 155x13 [color=#A9A9A9]
     100    RenderText {#text} at (0,0) size 63x13
     101      text run at (0,0) width 63: "placeholder"
     102layer at (13,141) size 119x13
     103  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     104    RenderText {#text} at (1,0) size 63x13
     105      text run at (1,0) width 63: "placeholder"
     106layer at (13,191) size 155x13
     107  RenderBlock (relative positioned) {DIV} at (3,16) size 155x13 [color=#A9A9A9]
     108    RenderText {#text} at (0,0) size 63x13
     109      text run at (0,0) width 63: "placeholder"
     110layer at (19,233) size 164x18
     111  RenderBlock (relative positioned) {DIV} at (6,6) size 164x18 [color=#A9A9A9]
     112    RenderText {#text} at (1,0) size 85x18
     113      text run at (1,0) width 85: "placeholder"
     114layer at (146,267) size 119x25
     115  RenderBlock (relative positioned) {DIV} at (3,3) size 119x25 [color=#A9A9A9]
     116    RenderText {#text} at (1,6) size 63x13
     117      text run at (1,6) width 63: "placeholder"
     118layer at (146,302) size 119x13
     119  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     120    RenderText {#text} at (28,0) size 63x13
     121      text run at (28,0) width 63: "placeholder"
     122layer at (279,302) size 119x13
     123  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     124    RenderText {#text} at (28,0) size 63x13
     125      text run at (28,0) width 63: "placeholder"
     126layer at (10,322) size 125x33
     127  RenderTextControl {INPUT} at (2,314) size 125x33 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     128layer at (13,339) size 119x13
    54129  RenderBlock {DIV} at (3,17) size 119x13
     130layer at (13,339) size 119x13
     131  RenderBlock (relative positioned) {DIV} at (3,17) size 119x13 [color=#A9A9A9]
     132    RenderText {#text} at (1,0) size 63x13
     133      text run at (1,0) width 63: "placeholder"
  • trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.txt

    r90089 r90971  
    4040layer at (13,54) size 119x13
    4141  RenderBlock {DIV} at (3,3) size 119x13
     42layer at (13,31) size 119x13
     43  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#640000]
     44    RenderText {#text} at (1,0) size 22x13
     45      text run at (1,0) width 22: "text"
     46layer at (154,31) size 98x13
     47  RenderBlock (relative positioned) {DIV} at (11,3) size 98x13 [color=#640000]
     48    RenderText {#text} at (1,0) size 35x13
     49      text run at (1,0) width 35: "search"
     50layer at (279,31) size 119x13
     51  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#640000]
     52    RenderText {#text} at (1,0) size 51x13
     53      text run at (1,0) width 51: "password"
     54layer at (412,31) size 119x13
     55  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#640000]
     56    RenderText {#text} at (1,0) size 70x13
     57      text run at (1,0) width 70: "disabled text"
     58layer at (545,31) size 119x13
     59  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     60    RenderText {#text} at (1,0) size 38x13
     61      text run at (1,0) width 38: "default"
     62layer at (13,54) size 119x13
     63  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     64    RenderText {#text} at (1,0) size 86x13
     65      text run at (1,0) width 86: "default disabled"
  • trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.txt

    r72052 r90971  
    1111layer at (13,47) size 119x13
    1212  RenderBlock {DIV} at (3,3) size 119x13
     13layer at (13,47) size 119x13
     14  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     15    RenderText {#text} at (1,0) size 62x13
     16      text run at (1,0) width 62: "Placeholder"
  • trunk/LayoutTests/platform/mac/fast/forms/placeholder-stripped-expected.txt

    r72052 r90971  
    2525  RenderTextControl {TEXTAREA} at (2,88) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    2626    RenderBlock {DIV} at (3,3) size 155x13
     27layer at (13,73) size 119x13
     28  RenderBlock (relative positioned) {DIV} at (3,3) size 119x13 [color=#A9A9A9]
     29    RenderText {#text} at (1,0) size 109x13
     30      text run at (1,0) width 109: "first line second line"
     31layer at (13,119) size 155x13
     32  RenderBlock (relative positioned) {DIV} at (3,3) size 155x13 [color=#A9A9A9]
     33    RenderText {#text} at (0,0) size 109x13
     34      text run at (0,0) width 109: "first line second line"
  • trunk/LayoutTests/platform/mac/fast/forms/search-placeholder-value-changed-expected.txt

    r90089 r90971  
    1313layer at (21,13) size 98x13
    1414  RenderBlock {DIV} at (0,0) size 98x13
     15layer at (21,13) size 98x13
     16  RenderBlock (relative positioned) {DIV} at (11,3) size 98x13 [color=#A9A9A9]
     17    RenderText {#text} at (1,0) size 63x13
     18      text run at (1,0) width 63: "Test Passed"
  • trunk/LayoutTests/platform/mac/fast/forms/search-styled-expected.txt

    r90089 r90971  
    1212layer at (35,13) size 84x13
    1313  RenderBlock {DIV} at (0,0) size 84x13
     14layer at (35,13) size 84x13 scrollWidth 94
     15  RenderBlock (relative positioned) {DIV} at (25,3) size 84x13 [color=#A9A9A9]
     16    RenderText {#text} at (1,0) size 92x13
     17      text run at (1,0) width 92: "Search for Events"
  • trunk/LayoutTests/platform/mac/fast/forms/textarea-placeholder-pseudo-style-expected.txt

    r72052 r90971  
    2626  RenderTextControl {TEXTAREA} at (509,20) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    2727    RenderBlock {DIV} at (3,3) size 155x13 [color=#545454]
     28layer at (13,31) size 155x13
     29  RenderBlock (relative positioned) {DIV} at (3,3) size 155x13 [color=#640000]
     30    RenderText {#text} at (0,0) size 22x13
     31      text run at (0,0) width 22: "text"
     32layer at (182,31) size 155x13
     33  RenderBlock (relative positioned) {DIV} at (3,3) size 155x13 [color=#640000]
     34    RenderText {#text} at (0,0) size 70x13
     35      text run at (0,0) width 70: "disabled text"
     36layer at (351,31) size 155x13
     37  RenderBlock (relative positioned) {DIV} at (3,3) size 155x13 [color=#A9A9A9]
     38    RenderText {#text} at (0,0) size 38x13
     39      text run at (0,0) width 38: "default"
     40layer at (520,31) size 155x13
     41  RenderBlock (relative positioned) {DIV} at (3,3) size 155x13 [color=#A9A9A9]
     42    RenderText {#text} at (0,0) size 86x13
     43      text run at (0,0) width 86: "default disabled"
  • trunk/LayoutTests/platform/mac/fast/forms/textarea-placeholder-set-attribute-expected.txt

    r72052 r90971  
    1111  RenderTextControl {TEXTAREA} at (2,2) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    1212    RenderBlock {DIV} at (3,3) size 155x13
     13layer at (13,47) size 155x13
     14  RenderBlock (relative positioned) {DIV} at (3,3) size 155x13 [color=#A9A9A9]
     15    RenderText {#text} at (0,0) size 62x13
     16      text run at (0,0) width 62: "Placeholder"
  • trunk/LayoutTests/platform/qt/test_expectations.txt

    r90891 r90971  
    22//
    33// See http://trac.webkit.org/wiki/TestExpectations for more information on this file.
     4
     5// Needs new baseline.
     6BUGWK64253 : fast/css/pseudo-cache-stale.html = FAIL
     7BUGWK64253 : fast/forms/input-placeholder-text-indent.html = FAIL
     8BUGWK64253 : fast/forms/isindex-placeholder.html = FAIL
     9BUGWK64253 : fast/forms/password-placeholder-text-security.html = FAIL
     10BUGWK64253 : fast/forms/password-placeholder.html = FAIL
     11BUGWK64253 : fast/forms/placeholder-position.html = FAIL
     12BUGWK64253 : fast/forms/placeholder-pseudo-style.html = FAIL
     13BUGWK64253 : fast/forms/placeholder-set-attribute.html = FAIL
     14BUGWK64253 : fast/forms/placeholder-stripped.html = FAIL
     15BUGWK64253 : fast/forms/search-placeholder-value-changed.html = FAIL
     16BUGWK64253 : fast/forms/search-styled.html = FAIL
     17BUGWK64253 : fast/forms/textarea-placeholder-pseudo-style.html = FAIL
     18BUGWK64253 : fast/forms/textarea-placeholder-set-attribute.html = FAIL
     19BUGWK64253 : fast/forms/textarea-placeholder-wrapping.html = FAIL
    420
    521BUGWK64002 : http/tests/misc/object-embedding-svg-delayed-size-negotiation-2.htm = TEXT PASS
  • trunk/Source/WebCore/ChangeLog

    r90970 r90971  
     12011-07-13  Kent Tamura  <tkent@chromium.org>
     2
     3        Implement text field placeholders using shadow DOM
     4        https://bugs.webkit.org/show_bug.cgi?id=64253
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Represents a placeholder text as a shadow element, and its
     9        visibility is controlled by 'visibility' CSS property.
     10
     11        This patch removes all of existing code about placeholder from
     12        RenderTextControl*. RenderTextControl* have only small code about
     13        placeholder layout.
     14
     15        Also, this patch removes INPUT_PLACEHOLDER legacy pseudo ID, and
     16        the placeholder style uses Element::shadowPseudoId().
     17
     18        This fixes the following regressions:
     19        - https://bugs.webkit.org/show_bug.cgi?id=51290
     20        - https://bugs.webkit.org/show_bug.cgi?id=54797
     21        - https://bugs.webkit.org/show_bug.cgi?id=54814
     22        - https://bugs.webkit.org/show_bug.cgi?id=63367
     23
     24        Test: fast/forms/textarea-placeholder-wrapping.html
     25
     26        * css/CSSSelector.cpp: Remove INPUT_PLACEHOLDER legacy pseudo ID.
     27        (WebCore::CSSSelector::pseudoId):
     28        (WebCore::nameToPseudoTypeMap):
     29        (WebCore::CSSSelector::extractPseudoType):
     30        * css/CSSSelector.h: ditto.
     31        * css/html.css:
     32        (::-webkit-input-placeholder): Added. This contains properties
     33        common in <input> and <textarea>. Some properties have !important
     34        so that a stylesheet specified by a page author won't break
     35        WebKit's assumption.
     36        (input::-webkit-input-placeholder, isindex::-webkit-input-placeholder):
     37         Added the default style for <input> placeholders.
     38        * html/HTMLInputElement.cpp:
     39        (WebCore::HTMLInputElement::placeholderElement): Delegate to an InputType.
     40        (WebCore::HTMLInputElement::updatePlaceholderText): ditto.
     41        * html/HTMLInputElement.h: Declare placeholderElement() and updatePlaceholderText().
     42        * html/HTMLTextAreaElement.cpp:
     43        (WebCore::HTMLTextAreaElement::createRenderer):
     44        Remove the 'placeholderVisible' argument.
     45        (WebCore::HTMLTextAreaElement::placeholderElement): Added.
     46        (WebCore::HTMLTextAreaElement::updatePlaceholderText):
     47         Added. This creates, deletes, or updates the placeholder element.
     48        * html/HTMLTextAreaElement.h:
     49        - Declare placeholderElement() and updatePlaceholderText().
     50        - Add m_placeholder.
     51        * html/HTMLTextFormControlElement.cpp:
     52        (WebCore::HTMLTextFormControlElement::updatePlaceholderVisibility):
     53        Update the placeholder element and 'visibility' CSS property,
     54        instead of delegating the job to a renderer.
     55        * html/HTMLTextFormControlElement.h:
     56        Declare two pure virtual functions: placeholderElement() and updatePlaceholderText().
     57        * html/InputType.cpp:
     58        (WebCore::InputType::placeholderElement): Add an empty implementation.
     59        (WebCore::InputType::updatePlaceholderText): Add an empty implementation.
     60        * html/InputType.h: Declare placeholderElement() and updatePlaceholderText().
     61        * html/TextFieldInputType.cpp:
     62        (WebCore::TextFieldInputType::createRenderer):
     63        Remove the 'placeholderVisible' argument.
     64        (WebCore::TextFieldInputType::placeholderElement): Added.
     65        (WebCore::TextFieldInputType::destroyShadowSubtree): Deletes m_placeholder.
     66        (WebCore::TextFieldInputType::updatePlaceholderText):
     67         Added. This creates, deletes, or updates the placeholder element.
     68        * html/TextFieldInputType.h:
     69        - Declare placeholderElement() and updatePlaceholderText().
     70        - Add m_placeholder.
     71        * rendering/RenderTextControl.cpp:
     72        (WebCore::RenderTextControl::RenderTextControl):
     73        Remove the 'placeholderVisible' argument.
     74        (WebCore::RenderTextControl::layoutSpecialExcludedChild):
     75        Excludes the placeholder renderer in order to avoid to secure a box for
     76        the placeholder.
     77        * rendering/RenderTextControl.h:
     78        - Remove declarations of removed functions.
     79        - Update the RenderTextControl signature.
     80        - Add layoutSpecialExcludedChild().
     81        * rendering/RenderTextControlMultiLine.cpp:
     82        (WebCore::RenderTextControlMultiLine::RenderTextControlMultiLine):
     83        Remove the 'placeholderVisible' argument.
     84        (WebCore::RenderTextControlMultiLine::layoutSpecialExcludedChild):
     85        Laying out the placeholder box so that it has correct width and location.
     86        * rendering/RenderTextControlMultiLine.h:
     87        - Remove declarations of removed functions.
     88        - Update the RenderTextControlMultiLine signature.
     89        - Add layoutSpecialExcludedChild().
     90        * rendering/RenderTextControlSingleLine.cpp:
     91        (WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
     92        Remove the 'placeholderVisible' argument.
     93        (WebCore::RenderTextControlSingleLine::layout):
     94        Laying out the placeholder box so that it has correct width and location.
     95        * rendering/RenderTextControlSingleLine.h:
     96        - Remove declarations of removed functions.
     97        - Update the RenderTextControlSingleLine signature.
     98        * rendering/style/RenderStyleConstants.h: Remove INPUT_PLACEHOLDER.
     99
    11002011-07-13  James Simonsen  <simonjam@chromium.org>
    2101
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r89989 r90971  
    127127    case PseudoAfter:
    128128        return AFTER;
    129     case PseudoInputPlaceholder:
    130         return INPUT_PLACEHOLDER;
    131129    case PseudoScrollbar:
    132130        return SCROLLBAR;
     
    257255    DEFINE_STATIC_LOCAL(AtomicString, inputListButton, ("-webkit-input-list-button"));
    258256#endif
    259     DEFINE_STATIC_LOCAL(AtomicString, inputPlaceholder, ("-webkit-input-placeholder"));
    260257    DEFINE_STATIC_LOCAL(AtomicString, lastChild, ("last-child"));
    261258    DEFINE_STATIC_LOCAL(AtomicString, lastOfType, ("last-of-type"));
     
    327324        nameToPseudoType->set(inputListButton.impl(), CSSSelector::PseudoInputListButton);
    328325#endif
    329         nameToPseudoType->set(inputPlaceholder.impl(), CSSSelector::PseudoInputPlaceholder);
    330326        nameToPseudoType->set(lastChild.impl(), CSSSelector::PseudoLastChild);
    331327        nameToPseudoType->set(lastOfType.impl(), CSSSelector::PseudoLastOfType);
     
    416412        compat = true;
    417413    case PseudoInputListButton:
    418     case PseudoInputPlaceholder:
    419414    case PseudoResizer:
    420415    case PseudoScrollbar:
  • trunk/Source/WebCore/css/CSSSelector.h

    r89989 r90971  
    138138            PseudoDefault,
    139139            PseudoDisabled,
    140             PseudoInputPlaceholder,
    141140            PseudoOptional,
    142141            PseudoRequired,
  • trunk/Source/WebCore/css/html.css

    r90089 r90971  
    498498}
    499499
    500 input::-webkit-input-placeholder, isindex::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
     500::-webkit-input-placeholder {
     501    -webkit-text-security: none;
    501502    color: darkGray;
     503    display: block !important;
     504    pointer-events: none !important;
     505    position: relative !important;
     506}
     507
     508input::-webkit-input-placeholder, isindex::-webkit-input-placeholder {
     509    white-space: pre;
     510    word-wrap: normal;
     511    overflow: hidden;
     512    padding-left: 1px;
     513    padding-right: 1px;
    502514}
    503515
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r90849 r90971  
    164164}
    165165#endif
     166
     167HTMLElement* HTMLInputElement::placeholderElement() const
     168{
     169    return m_inputType->placeholderElement();
     170}
    166171
    167172bool HTMLInputElement::shouldAutocomplete() const
     
    18201825}
    18211826
     1827void HTMLInputElement::updatePlaceholderText()
     1828{
     1829    return m_inputType->updatePlaceholderText();
     1830}
     1831
    18221832CheckedRadioButtons& HTMLInputElement::checkedRadioButtons() const
    18231833{
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r90849 r90971  
    119119    HTMLElement* speechButtonElement() const;
    120120#endif
     121    virtual HTMLElement* placeholderElement() const;
    121122
    122123    bool checked() const { return m_isChecked; }
     
    303304
    304305    virtual bool supportsPlaceholder() const;
     306    virtual void updatePlaceholderText();
    305307    virtual bool isEmptyValue() const { return value().isEmpty(); }
    306308    virtual bool isEmptySuggestedValue() const { return suggestedValue().isEmpty(); }
  • trunk/Source/WebCore/html/HTMLTextAreaElement.cpp

    r90849 r90971  
    175175RenderObject* HTMLTextAreaElement::createRenderer(RenderArena* arena, RenderStyle*)
    176176{
    177     return new (arena) RenderTextControlMultiLine(this, placeholderShouldBeVisible());
     177    return new (arena) RenderTextControlMultiLine(this);
    178178}
    179179
     
    443443}
    444444
    445 }
     445HTMLElement* HTMLTextAreaElement::placeholderElement() const
     446{
     447    return m_placeholder.get();
     448}
     449
     450void HTMLTextAreaElement::updatePlaceholderText()
     451{
     452    ExceptionCode ec = 0;
     453    String placeholderText = strippedPlaceholder();
     454    if (placeholderText.isEmpty()) {
     455        if (m_placeholder) {
     456            shadowRoot()->removeChild(m_placeholder.get(), ec);
     457            ASSERT(!ec);
     458            m_placeholder.clear();
     459        }
     460        return;
     461    }
     462    if (!m_placeholder) {
     463        m_placeholder = HTMLDivElement::create(document());
     464        m_placeholder->setShadowPseudoId("-webkit-input-placeholder", ec);
     465        ASSERT(!ec);
     466        shadowRoot()->insertBefore(m_placeholder, shadowRoot()->firstChild()->nextSibling(), ec);
     467        ASSERT(!ec);
     468    }
     469    m_placeholder->setInnerText(placeholderText, ec);
     470    ASSERT(!ec);
     471}
     472
     473}
  • trunk/Source/WebCore/html/HTMLTextAreaElement.h

    r90849 r90971  
    7575
    7676    virtual bool supportsPlaceholder() const { return true; }
     77    virtual HTMLElement* placeholderElement() const;
     78    virtual void updatePlaceholderText();
    7779    virtual bool isEmptyValue() const { return value().isEmpty(); }
    7880
     
    107109    int m_cols;
    108110    WrapMethod m_wrap;
     111    RefPtr<HTMLElement> m_placeholder;
    109112    mutable String m_value;
    110113    mutable bool m_isDirty;
  • trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp

    r90885 r90971  
    129129void HTMLTextFormControlElement::updatePlaceholderVisibility(bool placeholderValueChanged)
    130130{
    131     if (supportsPlaceholder() && renderer())
    132         toRenderTextControl(renderer())->updatePlaceholderVisibility(placeholderShouldBeVisible(), placeholderValueChanged);
     131    if (!supportsPlaceholder())
     132        return;
     133    if (!placeholderElement() || placeholderValueChanged)
     134        updatePlaceholderText();
     135    HTMLElement* placeholder = placeholderElement();
     136    if (!placeholder)
     137        return;
     138    ExceptionCode ec = 0;
     139    placeholder->getInlineStyleDecl()->setProperty(CSSPropertyVisibility, placeholderShouldBeVisible() ? "visible" : "hidden", ec);
     140    ASSERT(!ec);
    133141}
    134142
  • trunk/Source/WebCore/html/HTMLTextFormControlElement.h

    r90885 r90971  
    4646    String strippedPlaceholder() const;
    4747    bool placeholderShouldBeVisible() const;
     48    virtual HTMLElement* placeholderElement() const = 0;
    4849
    4950    int indexForVisiblePosition(const VisiblePosition&) const;
     
    7677
    7778    void updatePlaceholderVisibility(bool);
     79    virtual void updatePlaceholderText() = 0;
    7880
    7981    virtual void parseMappedAttribute(Attribute*);
  • trunk/Source/WebCore/html/InputType.cpp

    r90101 r90971  
    459459}
    460460
     461HTMLElement* InputType::placeholderElement() const
     462{
     463    return 0;
     464}
     465
    461466bool InputType::rendererIsNeeded()
    462467{
     
    661666}
    662667
     668void InputType::updatePlaceholderText()
     669{
     670}
     671
    663672void InputType::multipleAttributeChanged()
    664673{
  • trunk/Source/WebCore/html/InputType.h

    r90101 r90971  
    199199    virtual HTMLElement* speechButtonElement() const { return 0; }
    200200#endif
     201    virtual HTMLElement* placeholderElement() const;
    201202
    202203    // Miscellaneous functions
     
    227228    virtual bool shouldRespectHeightAndWidthAttributes();
    228229    virtual bool supportsPlaceholder() const;
     230    virtual void updatePlaceholderText();
    229231    virtual void multipleAttributeChanged();
    230232
  • trunk/Source/WebCore/html/TextFieldInputType.cpp

    r90089 r90971  
    127127RenderObject* TextFieldInputType::createRenderer(RenderArena* arena, RenderStyle*) const
    128128{
    129     return new (arena) RenderTextControlSingleLine(element(), element()->placeholderShouldBeVisible());
     129    return new (arena) RenderTextControlSingleLine(element());
    130130}
    131131
     
    208208#endif
    209209
     210HTMLElement* TextFieldInputType::placeholderElement() const
     211{
     212    return m_placeholder.get();
     213}
     214
    210215void TextFieldInputType::destroyShadowSubtree()
    211216{
    212217    InputType::destroyShadowSubtree();
    213218    m_innerText.clear();
     219    m_placeholder.clear();
    214220    m_innerBlock.clear();
    215221#if ENABLE(INPUT_SPEECH)
     
    304310}
    305311
     312void TextFieldInputType::updatePlaceholderText()
     313{
     314    if (!supportsPlaceholder())
     315        return;
     316    ExceptionCode ec = 0;
     317    String placeholderText = element()->strippedPlaceholder();
     318    if (placeholderText.isEmpty()) {
     319        if (m_placeholder) {
     320            m_placeholder->parentNode()->removeChild(m_placeholder.get(), ec);
     321            ASSERT(!ec);
     322            m_placeholder.clear();
     323        }
     324        return;
     325    }
     326    if (!m_placeholder) {
     327        m_placeholder = HTMLDivElement::create(element()->document());
     328        m_placeholder->setShadowPseudoId("-webkit-input-placeholder", ec);
     329        ASSERT(!ec);
     330        element()->shadowRoot()->insertBefore(m_placeholder, m_container ? m_container->nextSibling() : innerTextElement()->nextSibling(), ec);
     331        ASSERT(!ec);
     332    }
     333    m_placeholder->setInnerText(placeholderText, ec);
     334    ASSERT(!ec);
     335}
     336
    306337} // namespace WebCore
  • trunk/Source/WebCore/html/TextFieldInputType.h

    r90089 r90971  
    7070    virtual String sanitizeValue(const String&);
    7171    virtual bool shouldRespectListAttribute();
     72    virtual HTMLElement* placeholderElement() const;
     73    virtual void updatePlaceholderText();
    7274
    7375    RefPtr<HTMLElement> m_container;
    7476    RefPtr<HTMLElement> m_innerBlock;
    7577    RefPtr<HTMLElement> m_innerText;
     78    RefPtr<HTMLElement> m_placeholder;
    7679    RefPtr<HTMLElement> m_innerSpinButton;
    7780#if ENABLE(INPUT_SPEECH)
  • trunk/Source/WebCore/rendering/RenderTextControl.cpp

    r90885 r90971  
    7070}
    7171
    72 RenderTextControl::RenderTextControl(Node* node, bool placeholderVisible)
     72RenderTextControl::RenderTextControl(Node* node)
    7373    : RenderBlock(node)
    74     , m_placeholderVisible(placeholderVisible)
    7574    , m_lastChangeWasUserEdit(false)
    7675{
     76    ASSERT(toTextFormControl(node));
    7777}
    7878
     
    445445}
    446446
    447 void RenderTextControl::updatePlaceholderVisibility(bool placeholderShouldBeVisible, bool placeholderValueChanged)
    448 {
    449     bool oldPlaceholderVisible = m_placeholderVisible;
    450     m_placeholderVisible = placeholderShouldBeVisible;
    451     if (oldPlaceholderVisible != m_placeholderVisible || placeholderValueChanged)
    452         repaint();
    453 }
    454 
    455 void RenderTextControl::paintPlaceholder(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    456 {
    457     if (style()->visibility() != VISIBLE)
    458         return;
    459    
    460     LayoutRect clipRect(paintOffset.x() + borderLeft(), paintOffset.y() + borderTop(), width() - borderLeft() - borderRight(), height() - borderBottom() - borderTop());
    461     if (clipRect.isEmpty())
    462         return;
    463    
    464     GraphicsContextStateSaver stateSaver(*paintInfo.context);
    465     paintInfo.context->clip(clipRect);
    466    
    467     RefPtr<RenderStyle> placeholderStyle = getCachedPseudoStyle(INPUT_PLACEHOLDER);
    468     if (!placeholderStyle)
    469         placeholderStyle = style();
    470    
    471     paintInfo.context->setFillColor(placeholderStyle->visitedDependentColor(CSSPropertyColor), placeholderStyle->colorSpace());
    472    
    473     String placeholderText = static_cast<HTMLTextFormControlElement*>(node())->strippedPlaceholder();
    474     TextRun textRun(placeholderText.characters(), placeholderText.length(), false, 0, 0, TextRun::AllowTrailingExpansion, placeholderStyle->direction(), placeholderStyle->unicodeBidi() == Override);
    475    
    476     RenderBox* textRenderer = innerTextElement() ? innerTextElement()->renderBox() : 0;
    477     if (textRenderer) {
    478         LayoutPoint textPoint;
    479         textPoint.setY(paintOffset.y() + textBlockInsetTop() + placeholderStyle->fontMetrics().ascent());
    480         LayoutUnit styleTextIndent = placeholderStyle->textIndent().isFixed() ? placeholderStyle->textIndent().calcMinValue(0) : 0;
    481         if (placeholderStyle->isLeftToRightDirection())
    482             textPoint.setX(paintOffset.x() + styleTextIndent + textBlockInsetLeft());
    483         else
    484             textPoint.setX(paintOffset.x() + width() - textBlockInsetRight() - styleTextIndent - style()->font().width(textRun));
    485        
    486         paintInfo.context->drawBidiText(placeholderStyle->font(), textRun, textPoint);
    487     }
    488 }
    489 
    490 void RenderTextControl::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    491 {   
    492     if (m_placeholderVisible && paintInfo.phase == PaintPhaseForeground)
    493         paintPlaceholder(paintInfo, paintOffset);
    494    
    495     RenderBlock::paintObject(paintInfo, paintOffset);
     447RenderObject* RenderTextControl::layoutSpecialExcludedChild(bool relayoutChildren)
     448{
     449    HTMLElement* placeholder = toTextFormControl(node())->placeholderElement();
     450    RenderObject* placeholderRenderer = placeholder ? placeholder->renderer() : 0;
     451    if (!placeholderRenderer)
     452        return 0;
     453    if (relayoutChildren)
     454        placeholderRenderer->setNeedsLayout(true);
     455    return placeholderRenderer;
    496456}
    497457
  • trunk/Source/WebCore/rendering/RenderTextControl.h

    r90885 r90971  
    4545    VisiblePosition visiblePositionForIndex(int index) const;
    4646
    47     void updatePlaceholderVisibility(bool, bool);
    48 
    4947protected:
    50     RenderTextControl(Node*, bool);
     48    RenderTextControl(Node*);
    5149
    5250    // This convenience function should not be made public because innerTextElement may outlive the render tree.
     
    7573    virtual void updateFromElement();
    7674    virtual void computeLogicalHeight();
     75    virtual RenderObject* layoutSpecialExcludedChild(bool relayoutChildren);
    7776
    7877    bool m_placeholderVisible;
     
    8584    virtual bool canHaveChildren() const { return false; }
    8685    virtual bool avoidsFloats() const { return true; }
    87     virtual void paintObject(PaintInfo&, const LayoutPoint&);
    8886   
    8987    virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint&);
     
    9593    static bool isSelectableElement(HTMLElement*, Node*);
    9694   
    97     virtual int textBlockInsetLeft() const = 0;
    98     virtual int textBlockInsetRight() const = 0;
    99     virtual int textBlockInsetTop() const = 0;
    100 
    101     void paintPlaceholder(PaintInfo&, const IntPoint&);
    102 
    10395    bool m_lastChangeWasUserEdit;
    10496};
  • trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp

    r90791 r90971  
    3434namespace WebCore {
    3535
    36 RenderTextControlMultiLine::RenderTextControlMultiLine(Node* node, bool placeholderVisible)
    37     : RenderTextControl(node, placeholderVisible)
     36RenderTextControlMultiLine::RenderTextControlMultiLine(Node* node)
     37    : RenderTextControl(node)
    3838{
    3939}
     
    124124    return style();
    125125}
    126    
    127 int RenderTextControlMultiLine::textBlockInsetLeft() const
     126
     127RenderObject* RenderTextControlMultiLine::layoutSpecialExcludedChild(bool relayoutChildren)
    128128{
    129     int inset = borderLeft() + paddingLeft();
    130     if (HTMLElement* innerText = innerTextElement()) {
    131         if (RenderBox* innerTextRenderer = innerText->renderBox())
    132             inset += innerTextRenderer->paddingLeft();
    133     }
    134     return inset;
    135 }
    136 
    137 int RenderTextControlMultiLine::textBlockInsetRight() const
    138 {
    139     int inset = borderRight() + paddingRight();
    140     if (HTMLElement* innerText = innerTextElement()) {
    141         if (RenderBox* innerTextRenderer = innerText->renderBox())
    142             inset += innerTextRenderer->paddingRight();
    143     }
    144     return inset;
    145 }
    146 
    147 int RenderTextControlMultiLine::textBlockInsetTop() const
    148 {
    149     int inset = borderTop() + paddingTop();
    150     if (HTMLElement* innerText = innerTextElement()) {
    151         if (RenderBox* innerTextRenderer = innerText->renderBox())
    152             inset += innerTextRenderer->paddingTop();
    153     }
    154     return inset;
     129    RenderObject* placeholderRenderer = RenderTextControl::layoutSpecialExcludedChild(relayoutChildren);
     130    if (!placeholderRenderer)
     131        return 0;
     132    if (!placeholderRenderer->isBox())
     133        return placeholderRenderer;
     134    RenderBox* placeholderBox = toRenderBox(placeholderRenderer);
     135    placeholderBox->style()->setWidth(Length(contentWidth() - placeholderBox->borderAndPaddingWidth(), Fixed));
     136    placeholderBox->layoutIfNeeded();
     137    placeholderBox->setX(borderLeft() + paddingLeft());
     138    placeholderBox->setY(borderTop() + paddingTop());
     139    return placeholderRenderer;
    155140}
    156141   
  • trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h

    r90775 r90971  
    2929class RenderTextControlMultiLine : public RenderTextControl {
    3030public:
    31     RenderTextControlMultiLine(Node*, bool);
     31    RenderTextControlMultiLine(Node*);
    3232    virtual ~RenderTextControlMultiLine();
    3333
     
    5050    virtual RenderStyle* textBaseStyle() const;
    5151    virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const;
    52     virtual int textBlockInsetLeft() const;
    53     virtual int textBlockInsetRight() const;
    54     virtual int textBlockInsetTop() const;
     52    virtual RenderObject* layoutSpecialExcludedChild(bool relayoutChildren);
    5553};
    5654
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp

    r90791 r90971  
    7070// ----------------------------
    7171
    72 RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node, bool placeholderVisible)
    73     : RenderTextControl(node, placeholderVisible)
     72RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node)
     73    : RenderTextControl(node)
    7474    , m_searchPopupIsVisible(false)
    7575    , m_shouldDrawCapsLockIndicator(false)
     
    325325        innerSpinBox->setLocation(LayoutPoint(parentBox->width() - innerSpinBox->width() + paddingRight(), -paddingTop()));
    326326        innerSpinBox->setHeight(height() - borderTop() - borderBottom());
     327    }
     328
     329    HTMLElement* placeholderElement = inputElement()->placeholderElement();
     330    if (RenderBox* placeholderBox = placeholderElement ? placeholderElement->renderBox() : 0) {
     331        placeholderBox->style()->setWidth(Length(innerTextRenderer->width() - placeholderBox->borderAndPaddingWidth(), Fixed));
     332        placeholderBox->style()->setHeight(Length(innerTextRenderer->height() - placeholderBox->borderAndPaddingHeight(), Fixed));
     333        placeholderBox->layoutIfNeeded();
     334        LayoutPoint textOffset = innerTextRenderer->location();
     335        if (innerBlockElement() && innerBlockElement()->renderBox())
     336            textOffset += toLayoutSize(innerBlockElement()->renderBox()->location());
     337        if (containerRenderer)
     338            textOffset += toLayoutSize(containerRenderer->location());
     339        placeholderBox->setLocation(textOffset);
    327340    }
    328341}
     
    848861}
    849862
    850 int RenderTextControlSingleLine::textBlockInsetLeft() const
    851 {
    852     int inset = borderLeft() + clientPaddingLeft();
    853     if (HTMLElement* innerText = innerTextElement()) {
    854         if (RenderBox* innerTextRenderer = innerText->renderBox())
    855             inset += innerTextRenderer->paddingLeft();
    856     }
    857     return inset;
    858 }
    859    
    860 int RenderTextControlSingleLine::textBlockInsetRight() const
    861 {
    862     int inset = borderRight() + clientPaddingRight();
    863     if (HTMLElement* innerText = innerTextElement()) {
    864         if (RenderBox* innerTextRenderer = innerText->renderBox())
    865             inset += innerTextRenderer->paddingRight();
    866     }
    867     return inset;
    868 }
    869 
    870 int RenderTextControlSingleLine::textBlockInsetTop() const
    871 {
    872     HTMLElement* innerText = innerTextElement();
    873     if (!innerText || !innerText->renderBox())
    874         return borderTop() + paddingTop();
    875     HTMLElement* container = containerElement();
    876     if (!container)
    877         return innerText->renderBox()->y();
    878     ASSERT(innerBlockElement());
    879     if (!container->renderBox() || !innerBlockElement()->renderBox())
    880         return innerText->renderBox()->y();
    881     return container->renderBox()->y() + innerBlockElement()->renderBox()->y();
    882 }   
    883 
    884 }
     863}
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h

    r90791 r90971  
    3636class RenderTextControlSingleLine : public RenderTextControl, private PopupMenuClient {
    3737public:
    38     RenderTextControlSingleLine(Node*, bool);
     38    RenderTextControlSingleLine(Node*);
    3939    virtual ~RenderTextControlSingleLine();
    4040    // FIXME: Move create*Style() to their classes.
    4141    virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const;
    4242    PassRefPtr<RenderStyle> createInnerBlockStyle(const RenderStyle* startStyle) const;
    43 
    44     bool placeholderIsVisible() const { return m_placeholderVisible; }
    45     bool placeholderShouldBeVisible() const;
    4643
    4744    void addSearchResult();
     
    127124    HTMLInputElement* inputElement() const;
    128125
    129     virtual int textBlockInsetLeft() const;
    130     virtual int textBlockInsetRight() const;
    131     virtual int textBlockInsetTop() const;
    132 
    133126    HTMLElement* containerElement() const;
    134127    HTMLElement* innerBlockElement() const;
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.h

    r88526 r90971  
    7575    NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION, FIRST_LINE_INHERITED, SCROLLBAR,
    7676    // Internal IDs follow:
    77     INPUT_PLACEHOLDER,
    7877    SCROLLBAR_THUMB, SCROLLBAR_BUTTON, SCROLLBAR_TRACK, SCROLLBAR_TRACK_PIECE, SCROLLBAR_CORNER, RESIZER,
    7978    INPUT_LIST_BUTTON, VISITED_LINK,
     
    8180    FULL_SCREEN, FULL_SCREEN_DOCUMENT, FULL_SCREEN_ANCESTOR, ANIMATING_FULL_SCREEN_TRANSITION,
    8281    FIRST_PUBLIC_PSEUDOID = FIRST_LINE,
    83     FIRST_INTERNAL_PSEUDOID = INPUT_PLACEHOLDER,
     82    FIRST_INTERNAL_PSEUDOID = SCROLLBAR_THUMB,
    8483    PUBLIC_PSEUDOID_MASK = ((1 << FIRST_INTERNAL_PSEUDOID) - 1) & ~((1 << FIRST_PUBLIC_PSEUDOID) - 1)
    8584};
Note: See TracChangeset for help on using the changeset viewer.