Changeset 72052 in webkit


Ignore:
Timestamp:
Nov 15, 2010 6:09:43 PM (13 years ago)
Author:
adele@apple.com
Message:

WebCore: Fix for: https://bugs.webkit.org/show_bug.cgi?id=49452
Placeholder should not be swapped in and out of the text control's inner text element

Reviewed by Darin Adler.

There's no need to swap the placeholder text in and out of the inner text element. Instead, just paint the text.
This reduces complexity and makes it easier to make independent decisions about the placeholder text and the text control value.

  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::setValueFromRenderer):

Since updatePlaceholderVisibility checks the value, set the value before calling updatePlaceholderVisibility.

  • rendering/RenderTextControl.cpp:

(WebCore::RenderTextControl::updatePlaceholderVisibility): Remove code that set the inner text value with the placeholder text.
(WebCore::RenderTextControl::paintObject): Paint the placeholder text during the background phase.

  • rendering/RenderTextControl.h:
  • rendering/RenderTextControlMultiLine.cpp:

(WebCore::RenderTextControlMultiLine::nodeAtPoint): Remove custom hit testing that tried to avoid hitting the placeholder text at the wrong time.
(WebCore::RenderTextControlMultiLine::updateFromElement): Remove code that set the inner text value with the placeholder text.
(WebCore::RenderTextControlMultiLine::createInnerTextStyle): Remove code that created the inner text style based on the placeholder pseudoelement.
(WebCore::RenderTextControlMultiLine::textBoxInsetLeft): Added.
(WebCore::RenderTextControlMultiLine::textBoxInsetRight): Added.

  • rendering/RenderTextControlMultiLine.h:
  • rendering/RenderTextControlSingleLine.cpp:

(WebCore::RenderTextControlSingleLine::updateFromElement): Remove code that set the inner text value with the placeholder text.
(WebCore::RenderTextControlSingleLine::createInnerTextStyle): Remove code that created the inner text style based on the placeholder pseudoelement.
(WebCore::RenderTextControlSingleLine::textBoxInsetLeft): Added.
(WebCore::RenderTextControlSingleLine::textBoxInsetRight): Added.

  • rendering/RenderTextControlSingleLine.h:
  • rendering/TextControlInnerElements.cpp: Removed custom hit testing that tried to avoid hitting the placeholder text at the wrong time.

LayoutTests: Test for: https://bugs.webkit.org/show_bug.cgi?id=49452
Placeholder should not be swapped in and out of the text control's inner text element

Reviewed by Darin Adler.

The only visual change that occurred is in pseudo-cache-stale.html. The placeholder text did not
use to paint over the spot where the cancel button will display. Since the cancel button is not
present when the placeholder is drawn, now the placeholder text can draw to the edge of the field.

  • platform/mac/fast/css/pseudo-cache-stale-expected.checksum:
  • platform/mac/fast/css/pseudo-cache-stale-expected.png:
  • platform/mac/fast/css/pseudo-cache-stale-expected.txt:
  • 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.txt:
  • 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.txt:
  • platform/mac/fast/forms/textarea-placeholder-pseudo-style-expected.txt:
  • platform/mac/fast/forms/textarea-placeholder-set-attribute-expected.txt:
Location:
trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r72050 r72052  
     12010-11-15 Adele Peterson  <adele@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Test for: https://bugs.webkit.org/show_bug.cgi?id=49452
     6        Placeholder should not be swapped in and out of the text control's inner text element
     7
     8        The only visual change that occurred is in pseudo-cache-stale.html.  The placeholder text did not
     9        use to paint over the spot where the cancel button will display.  Since the cancel button is not
     10        present when the placeholder is drawn, now the placeholder text can draw to the edge of the field.
     11
     12        * platform/mac/fast/css/pseudo-cache-stale-expected.checksum:
     13        * platform/mac/fast/css/pseudo-cache-stale-expected.png:
     14        * platform/mac/fast/css/pseudo-cache-stale-expected.txt:
     15        * platform/mac/fast/forms/isindex-placeholder-expected.txt:
     16        * platform/mac/fast/forms/password-placeholder-expected.txt:
     17        * platform/mac/fast/forms/password-placeholder-text-security-expected.txt:
     18        * platform/mac/fast/forms/placeholder-pseudo-style-expected.txt:
     19        * platform/mac/fast/forms/placeholder-set-attribute-expected.txt:
     20        * platform/mac/fast/forms/placeholder-stripped-expected.txt:
     21        * platform/mac/fast/forms/search-placeholder-value-changed-expected.txt:
     22        * platform/mac/fast/forms/search-styled-expected.txt:
     23        * platform/mac/fast/forms/textarea-placeholder-pseudo-style-expected.txt:
     24        * platform/mac/fast/forms/textarea-placeholder-set-attribute-expected.txt:
     25
    1262010-11-15  Gavin Barraclough  <barraclough@apple.com>
    227
  • trunk/LayoutTests/platform/mac/fast/css/pseudo-cache-stale-expected.checksum

    r59251 r72052  
    1 b22ad20cdd4a8b52a334434c3ae0026b
     19366e258b90951ee374befbc02a391b3
  • trunk/LayoutTests/platform/mac/fast/css/pseudo-cache-stale-expected.txt

    r63403 r72052  
    2020        RenderText {#text} at (0,0) size 0x0
    2121        RenderText {#text} at (0,0) size 0x0
    22 layer at (21,87) size 98x13 scrollWidth 116
    23   RenderBlock {DIV} at (8,0) size 98x13 [color=#008000]
    24     RenderText {#text} at (1,0) size 114x13
    25       text run at (1,0) width 114: "This should be green"
     22layer at (21,87) size 98x13
     23  RenderBlock {DIV} at (8,0) size 98x13
  • trunk/LayoutTests/platform/mac/fast/forms/isindex-placeholder-expected.txt

    r64712 r72052  
    3535        RenderBlock {HR} at (0,41) size 784x2 [border: (1px inset #000000)]
    3636layer at (335,83) size 119x13
    37   RenderBlock {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"
     37  RenderBlock {DIV} at (3,3) size 119x13
    4038layer at (335,168) size 119x13
    41   RenderBlock {DIV} at (3,3) size 119x13 [color=#008000]
    42     RenderText {#text} at (1,0) size 63x13
    43       text run at (1,0) width 63: "placeholder"
     39  RenderBlock {DIV} at (3,3) size 119x13
  • trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.txt

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

    r54748 r72052  
    2323      RenderBR {BR} at (719,80) size 0x0
    2424layer at (370,31) size 119x13
    25   RenderBlock {DIV} at (3,3) size 119x13 [color=#A9A9A9]
    26     RenderText {#text} at (1,0) size 63x13
    27       text run at (1,0) width 63: "placeholder"
     25  RenderBlock {DIV} at (3,3) size 119x13
    2826layer at (420,54) size 119x13
    2927  RenderBlock {DIV} at (3,3) size 119x13
     
    3129      text run at (1,0) width 25: "\x{2022}\x{2022}\x{2022}\x{2022}"
    3230layer at (603,77) size 119x13
    33   RenderBlock {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"
     31  RenderBlock {DIV} at (3,3) size 119x13
  • trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.txt

    r54748 r72052  
    2828      RenderText {#text} at (0,0) size 0x0
    2929layer at (13,31) size 119x13
    30   RenderBlock {DIV} at (3,3) size 119x13 [color=#640000]
    31     RenderText {#text} at (1,0) size 22x13
    32       text run at (1,0) width 22: "text"
     30  RenderBlock {DIV} at (3,3) size 119x13
    3331layer at (154,31) size 98x13
    34   RenderBlock {DIV} at (8,0) size 98x13 [color=#640000]
    35     RenderText {#text} at (1,0) size 35x13
    36       text run at (1,0) width 35: "search"
     32  RenderBlock {DIV} at (8,0) size 98x13
    3733layer at (279,31) size 119x13
    38   RenderBlock {DIV} at (3,3) size 119x13 [color=#640000]
    39     RenderText {#text} at (1,0) size 51x13
    40       text run at (1,0) width 51: "password"
     34  RenderBlock {DIV} at (3,3) size 119x13
    4135layer at (412,31) size 119x13
    42   RenderBlock {DIV} at (3,3) size 119x13 [color=#B80000]
    43     RenderText {#text} at (1,0) size 70x13
    44       text run at (1,0) width 70: "disabled text"
     36  RenderBlock {DIV} at (3,3) size 119x13 [color=#545454]
    4537layer at (545,31) size 119x13
    46   RenderBlock {DIV} at (3,3) size 119x13 [color=#A9A9A9]
    47     RenderText {#text} at (1,0) size 38x13
    48       text run at (1,0) width 38: "default"
     38  RenderBlock {DIV} at (3,3) size 119x13
    4939layer at (13,54) size 119x13
    50   RenderBlock {DIV} at (3,3) size 119x13 [color=#A9A9A9]
    51     RenderText {#text} at (1,0) size 86x13
    52       text run at (1,0) width 86: "default disabled"
     40  RenderBlock {DIV} at (3,3) size 119x13
  • trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.txt

    r54748 r72052  
    1010        RenderTextControl {INPUT} at (2,2) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
    1111layer at (13,47) size 119x13
    12   RenderBlock {DIV} at (3,3) size 119x13 [color=#A9A9A9]
    13     RenderText {#text} at (1,0) size 62x13
    14       text run at (1,0) width 62: "Placeholder"
     12  RenderBlock {DIV} at (3,3) size 119x13
  • trunk/LayoutTests/platform/mac/fast/forms/placeholder-stripped-expected.txt

    r63403 r72052  
    1616        RenderText {#text} at (0,0) size 0x0
    1717layer at (13,73) size 119x13
    18   RenderBlock {DIV} at (3,3) size 119x13 [color=#A9A9A9]
    19     RenderText {#text} at (1,0) size 109x13
    20       text run at (1,0) width 109: "first line second line"
     18  RenderBlock {DIV} at (3,3) size 119x13
    2119layer at (13,96) size 119x13
    2220  RenderBlock {DIV} at (3,3) size 119x13
    2321layer at (10,116) size 161x32 clip at (11,117) size 159x30
    2422  RenderTextControl {TEXTAREA} at (2,48) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    25     RenderBlock {DIV} at (3,3) size 155x13 [color=#A9A9A9]
    26       RenderText {#text} at (0,0) size 109x13
    27         text run at (0,0) width 109: "first line second line"
     23    RenderBlock {DIV} at (3,3) size 155x13
    2824layer at (10,156) size 161x32 clip at (11,157) size 159x30
    2925  RenderTextControl {TEXTAREA} at (2,88) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
  • trunk/LayoutTests/platform/mac/fast/forms/search-placeholder-value-changed-expected.txt

    r54748 r72052  
    1111      RenderText {#text} at (0,0) size 0x0
    1212layer at (21,13) size 98x13
    13   RenderBlock {DIV} at (8,0) size 98x13 [color=#A9A9A9]
    14     RenderText {#text} at (1,0) size 63x13
    15       text run at (1,0) width 63: "Test Passed"
     13  RenderBlock {DIV} at (8,0) size 98x13
  • trunk/LayoutTests/platform/mac/fast/forms/search-styled-expected.txt

    r63403 r72052  
    99          RenderBlock {DIV} at (106,0) size 13x11
    1010      RenderText {#text} at (0,0) size 0x0
    11 layer at (35,13) size 84x13 scrollWidth 95
    12   RenderBlock {DIV} at (22,0) size 84x13 [color=#A9A9A9]
    13     RenderText {#text} at (1,0) size 93x13
    14       text run at (1,0) width 93: "Search for Events"
     11layer at (35,13) size 84x13
     12  RenderBlock {DIV} at (22,0) size 84x13
  • trunk/LayoutTests/platform/mac/fast/forms/textarea-placeholder-pseudo-style-expected.txt

    r54748 r72052  
    1616layer at (10,28) size 161x32 clip at (11,29) size 159x30
    1717  RenderTextControl {TEXTAREA} at (2,20) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    18     RenderBlock {DIV} at (3,3) size 155x13 [color=#640000]
    19       RenderText {#text} at (0,0) size 22x13
    20         text run at (0,0) width 22: "text"
     18    RenderBlock {DIV} at (3,3) size 155x13
    2119layer at (179,28) size 161x32 clip at (180,29) size 159x30
    2220  RenderTextControl {TEXTAREA} at (171,20) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    23     RenderBlock {DIV} at (3,3) size 155x13 [color=#B80000]
    24       RenderText {#text} at (0,0) size 70x13
    25         text run at (0,0) width 70: "disabled text"
     21    RenderBlock {DIV} at (3,3) size 155x13 [color=#545454]
    2622layer at (348,28) size 161x32 clip at (349,29) size 159x30
    2723  RenderTextControl {TEXTAREA} at (340,20) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    28     RenderBlock {DIV} at (3,3) size 155x13 [color=#A9A9A9]
    29       RenderText {#text} at (0,0) size 38x13
    30         text run at (0,0) width 38: "default"
     24    RenderBlock {DIV} at (3,3) size 155x13
    3125layer at (517,28) size 161x32 clip at (518,29) size 159x30
    3226  RenderTextControl {TEXTAREA} at (509,20) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    33     RenderBlock {DIV} at (3,3) size 155x13 [color=#A9A9A9]
    34       RenderText {#text} at (0,0) size 86x13
    35         text run at (0,0) width 86: "default disabled"
     27    RenderBlock {DIV} at (3,3) size 155x13 [color=#545454]
  • trunk/LayoutTests/platform/mac/fast/forms/textarea-placeholder-set-attribute-expected.txt

    r54748 r72052  
    1010layer at (10,44) size 161x32 clip at (11,45) size 159x30
    1111  RenderTextControl {TEXTAREA} at (2,2) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    12     RenderBlock {DIV} at (3,3) size 155x13 [color=#A9A9A9]
    13       RenderText {#text} at (0,0) size 62x13
    14         text run at (0,0) width 62: "Placeholder"
     12    RenderBlock {DIV} at (3,3) size 155x13
  • trunk/WebCore/ChangeLog

    r72049 r72052  
     12010-11-15  Adele Peterson  <adele@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Fix for: https://bugs.webkit.org/show_bug.cgi?id=49452
     6        Placeholder should not be swapped in and out of the text control's inner text element
     7
     8        There's no need to swap the placeholder text in and out of the inner text element.  Instead, just paint the text.
     9        This reduces complexity and makes it easier to make independent decisions about the placeholder text and the text control value.
     10
     11        * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::setValueFromRenderer):
     12        Since updatePlaceholderVisibility checks the value, set the value before calling updatePlaceholderVisibility.
     13        * rendering/RenderTextControl.cpp:
     14        (WebCore::RenderTextControl::updatePlaceholderVisibility): Remove code that set the inner text value with the placeholder text.
     15        (WebCore::RenderTextControl::paintObject):  Paint the placeholder text during the background phase.
     16        * rendering/RenderTextControl.h:
     17        * rendering/RenderTextControlMultiLine.cpp:
     18        (WebCore::RenderTextControlMultiLine::nodeAtPoint): Remove custom hit testing that tried to avoid hitting the placeholder text at the wrong time.
     19        (WebCore::RenderTextControlMultiLine::updateFromElement):  Remove code that set the inner text value with the placeholder text.
     20        (WebCore::RenderTextControlMultiLine::createInnerTextStyle): Remove code that created the inner text style based on the placeholder pseudoelement.
     21        (WebCore::RenderTextControlMultiLine::textBoxInsetLeft): Added.
     22        (WebCore::RenderTextControlMultiLine::textBoxInsetRight): Added.
     23        * rendering/RenderTextControlMultiLine.h:
     24        * rendering/RenderTextControlSingleLine.cpp:
     25        (WebCore::RenderTextControlSingleLine::updateFromElement): Remove code that set the inner text value with the placeholder text.
     26        (WebCore::RenderTextControlSingleLine::createInnerTextStyle): Remove code that created the inner text style based on the placeholder pseudoelement.
     27        (WebCore::RenderTextControlSingleLine::textBoxInsetLeft): Added.
     28        (WebCore::RenderTextControlSingleLine::textBoxInsetRight): Added.
     29        * rendering/RenderTextControlSingleLine.h:
     30        * rendering/TextControlInnerElements.cpp: Removed custom hit testing that tried to avoid hitting the placeholder text at the wrong time.
     31
    1322010-11-15  Andreas Kling  <kling@webkit.org>
    233
  • trunk/WebCore/html/HTMLInputElement.cpp

    r72038 r72052  
    11261126    ASSERT(deprecatedInputType() != FILE);
    11271127    m_data.setSuggestedValue(String());
     1128    InputElement::setValueFromRenderer(m_data, this, this, value);
    11281129    updatePlaceholderVisibility(false);
    1129     InputElement::setValueFromRenderer(m_data, this, this, value);
    11301130    setNeedsValidityCheck();
    11311131
  • trunk/WebCore/rendering/RenderTextControl.cpp

    r71880 r72052  
    579579    bool oldPlaceholderVisible = m_placeholderVisible;
    580580    m_placeholderVisible = placeholderShouldBeVisible;
    581     if (oldPlaceholderVisible != m_placeholderVisible || placeholderValueChanged) {
    582         // Sets the inner text style to the normal style or :placeholder style.
    583         setInnerTextStyle(createInnerTextStyle(textBaseStyle()));
    584 
    585         // updateFromElement() of the subclasses updates the text content
    586         // to the element's value(), placeholder(), or the empty string.
    587         updateFromElement();
    588     }
     581    if (oldPlaceholderVisible != m_placeholderVisible || placeholderValueChanged)
     582        repaint();
     583}
     584
     585void RenderTextControl::paintPlaceholder(PaintInfo& paintInfo, int tx, int ty)
     586{
     587    if (style()->visibility() != VISIBLE)
     588        return;
     589   
     590    IntRect clipRect(tx + borderLeft(), ty + borderTop(), width() - borderLeft() - borderRight(), height() - borderBottom() - borderTop());
     591    if (clipRect.isEmpty())
     592        return;
     593   
     594    paintInfo.context->save();
     595   
     596    paintInfo.context->clip(clipRect);
     597   
     598    RefPtr<RenderStyle> placeholderStyle = getCachedPseudoStyle(INPUT_PLACEHOLDER);
     599    if (!placeholderStyle)
     600        placeholderStyle = style();
     601   
     602    paintInfo.context->setFillColor(placeholderStyle->visitedDependentColor(CSSPropertyColor), placeholderStyle->colorSpace());
     603   
     604    String placeholderText = static_cast<HTMLTextFormControlElement*>(node())->strippedPlaceholder();
     605    TextRun textRun(placeholderText.characters(), placeholderText.length(), 0, 0, 0, !placeholderStyle->isLeftToRightDirection(), placeholderStyle->unicodeBidi() == Override, false, false);
     606   
     607    RenderBox* textRenderer = innerTextElement() ? innerTextElement()->renderBox() : 0;
     608    if (textRenderer) {
     609        IntPoint textPoint;
     610        textPoint.setY(ty + borderTop() + paddingTop() + textRenderer->paddingTop() + placeholderStyle->font().ascent());
     611        if (placeholderStyle->isLeftToRightDirection())
     612            textPoint.setX(tx + textBlockInsetLeft());
     613        else
     614            textPoint.setX(tx + width() - textBlockInsetRight() - style()->font().width(textRun));
     615       
     616        paintInfo.context->drawBidiText(placeholderStyle->font(), textRun, textPoint);
     617    }
     618    paintInfo.context->restore();   
     619}
     620
     621void RenderTextControl::paintObject(PaintInfo& paintInfo, int tx, int ty)
     622{   
     623    if (m_placeholderVisible && paintInfo.phase == PaintPhaseForeground)
     624        paintPlaceholder(paintInfo, tx, ty);
     625   
     626    RenderBlock::paintObject(paintInfo, tx, ty);
    589627}
    590628
  • trunk/WebCore/rendering/RenderTextControl.h

    r71880 r72052  
    9797    virtual bool avoidsFloats() const { return true; }
    9898    void setInnerTextStyle(PassRefPtr<RenderStyle>);
     99    virtual void paintObject(PaintInfo&, int tx, int ty);
    99100   
    100101    virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
     
    109110    friend void setSelectionRange(Node*, int start, int end);
    110111    bool isSelectableElement(Node*) const;
     112   
     113    virtual int textBlockInsetLeft() const = 0;
     114    virtual int textBlockInsetRight() const = 0;
     115
     116    void paintPlaceholder(PaintInfo&, int tx, int ty);
    111117
    112118    bool m_wasChangedSinceLastChangeEvent;
  • trunk/WebCore/rendering/RenderTextControlMultiLine.cpp

    r71934 r72052  
    6262        return false;
    6363
    64     bool resultIsTextValueOrPlaceholder
    65         = (!m_placeholderVisible && result.innerNode() == innerTextElement())
    66         || (m_placeholderVisible && result.innerNode()->isDescendantOf(innerTextElement()));
    67     if (result.innerNode() == node() || resultIsTextValueOrPlaceholder)
     64    if (result.innerNode() == node() || result.innerNode() == innerTextElement())
    6865        hitInnerTextElement(result, x, y, tx, ty);
    6966
     
    108105    RenderTextControl::updateFromElement();
    109106
    110     HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(node());
    111     if (m_placeholderVisible)
    112         setInnerTextValue(textArea->strippedPlaceholder());
    113     else
    114         setInnerTextValue(textArea->value());
     107    setInnerTextValue(static_cast<HTMLTextAreaElement*>(node())->value());
    115108}
    116109
     
    122115PassRefPtr<RenderStyle> RenderTextControlMultiLine::createInnerTextStyle(const RenderStyle* startStyle) const
    123116{
    124     RefPtr<RenderStyle> textBlockStyle;
    125     if (m_placeholderVisible) {
    126         if (RenderStyle* pseudoStyle = getCachedPseudoStyle(INPUT_PLACEHOLDER))
    127             textBlockStyle = RenderStyle::clone(pseudoStyle);
    128     }
    129     if (!textBlockStyle) {
    130         textBlockStyle = RenderStyle::create();
    131         textBlockStyle->inheritFrom(startStyle);
    132     }
    133 
     117    RefPtr<RenderStyle> textBlockStyle = RenderStyle::create();
     118    textBlockStyle->inheritFrom(startStyle);
    134119    adjustInnerTextStyle(startStyle, textBlockStyle.get());
    135120    textBlockStyle->setDisplay(BLOCK);
     
    142127    return style();
    143128}
     129   
     130int RenderTextControlMultiLine::textBlockInsetLeft() const
     131{
     132    int inset = borderLeft() + paddingLeft();
     133    if (HTMLElement* innerText = innerTextElement()) {
     134        if (RenderBox* innerTextRenderer = innerText->renderBox())
     135            inset += innerTextRenderer->paddingLeft();
     136    }
     137    return inset;
     138}
     139
     140int RenderTextControlMultiLine::textBlockInsetRight() const
     141{
     142    int inset = borderRight() + paddingRight();
     143    if (HTMLElement* innerText = innerTextElement()) {
     144        if (RenderBox* innerTextRenderer = innerText->renderBox())
     145            inset += innerTextRenderer->paddingRight();
     146    }
     147    return inset;
     148}
    144149
    145150}
  • trunk/WebCore/rendering/RenderTextControlMultiLine.h

    r70072 r72052  
    5151    virtual RenderStyle* textBaseStyle() const;
    5252    virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const;
     53    virtual int textBlockInsetLeft() const;
     54    virtual int textBlockInsetRight() const;
    5355};
    5456
  • trunk/WebCore/rendering/RenderTextControlSingleLine.cpp

    r71618 r72052  
    675675        updateCancelButtonVisibility();
    676676
    677     if (m_placeholderVisible) {
    678         // node() must be an HTMLInputElement. WMLInputElement doesn't support placeholder.
    679         ASSERT(node()->isHTMLElement());
    680         ExceptionCode ec = 0;
    681         innerTextElement()->setInnerText(static_cast<HTMLInputElement*>(node())->strippedPlaceholder(), ec);
    682         ASSERT(!ec);
    683     } else {
    684         if (!inputElement()->suggestedValue().isNull())
    685             setInnerTextValue(inputElement()->suggestedValue());
    686         else {
    687             bool shouldUpdateValue = true;
    688             if (node()->isHTMLElement()) {
    689                 // For HTMLInputElement, update the renderer value if the element
    690                 // supports placeholder or the formControlValueMatchesRenderer()
    691                 // flag is false. It protects an unacceptable renderer value from
    692                 // being overwritten with the DOM value.
    693                 shouldUpdateValue = static_cast<HTMLTextFormControlElement*>(node())->supportsPlaceholder() || !static_cast<HTMLInputElement*>(node())->formControlValueMatchesRenderer();
    694             }
    695             if (shouldUpdateValue)
     677    if (!inputElement()->suggestedValue().isNull())
     678        setInnerTextValue(inputElement()->suggestedValue());
     679    else {
     680        if (node()->hasTagName(inputTag)) {
     681            // For HTMLInputElement, update the renderer value if the formControlValueMatchesRenderer()
     682            // flag is false. It protects an unacceptable renderer value from
     683            // being overwritten with the DOM value.
     684            if (!static_cast<HTMLInputElement*>(node())->formControlValueMatchesRenderer())
    696685                setInnerTextValue(inputElement()->value());
    697686        }
     
    709698PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerTextStyle(const RenderStyle* startStyle) const
    710699{
    711     RefPtr<RenderStyle> textBlockStyle;
    712     if (m_placeholderVisible) {
    713         if (RenderStyle* pseudoStyle = getCachedPseudoStyle(INPUT_PLACEHOLDER))
    714             textBlockStyle = RenderStyle::clone(pseudoStyle);
    715     }
    716     if (!textBlockStyle) {
    717         textBlockStyle = RenderStyle::create();   
    718         textBlockStyle->inheritFrom(startStyle);
    719     }
    720 
     700    RefPtr<RenderStyle> textBlockStyle = RenderStyle::create();   
     701    textBlockStyle->inheritFrom(startStyle);
    721702    adjustInnerTextStyle(startStyle, textBlockStyle.get());
    722703
     
    740721    textBlockStyle->setPaddingLeft(Length(1, Fixed));
    741722    textBlockStyle->setPaddingRight(Length(1, Fixed));
    742 
    743     // When the placeholder is going to be displayed, temporarily override the text security to be "none".
    744     // After this, updateFromElement will immediately update the text displayed.
    745     // When the placeholder is no longer visible, updatePlaceholderVisiblity will reset the style,
    746     // and the text security mode will be set back to the computed value correctly.
    747     if (m_placeholderVisible)
    748         textBlockStyle->setTextSecurity(TSNONE);
    749723
    750724    return textBlockStyle.release();
     
    11131087}
    11141088
    1115 }
     1089int RenderTextControlSingleLine::textBlockInsetLeft() const
     1090{
     1091    int inset = borderLeft() + clientPaddingLeft();
     1092    if (HTMLElement* innerText = innerTextElement()) {
     1093        if (RenderBox* innerTextRenderer = innerText->renderBox())
     1094            inset += innerTextRenderer->paddingLeft();
     1095    }
     1096    return inset;
     1097}
     1098   
     1099int RenderTextControlSingleLine::textBlockInsetRight() const
     1100{
     1101    int inset = borderRight() + clientPaddingRight();
     1102    if (HTMLElement* innerText = innerTextElement()) {
     1103        if (RenderBox* innerTextRenderer = innerText->renderBox())
     1104            inset += innerTextRenderer->paddingRight();
     1105    }
     1106    return inset;
     1107}
     1108
     1109}
  • trunk/WebCore/rendering/RenderTextControlSingleLine.h

    r71900 r72052  
    144144    InputElement* inputElement() const;
    145145
     146    virtual int textBlockInsetLeft() const;
     147    virtual int textBlockInsetRight() const;
     148
    146149    bool m_searchPopupIsVisible;
    147150    bool m_shouldDrawCapsLockIndicator;
  • trunk/WebCore/rendering/TextControlInnerElements.cpp

    r71934 r72052  
    5252
    5353private:
    54     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
    5554    virtual VisiblePosition positionForPoint(const IntPoint&);
    5655
    5756    bool m_multiLine;
    5857};
    59 
    60 bool RenderTextControlInnerBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction)
    61 {
    62     RenderObject* renderer = node()->shadowAncestorNode()->renderer();
    63 
    64     bool placeholderIsVisible = false;
    65     if (renderer->isTextField())
    66         placeholderIsVisible = toRenderTextControlSingleLine(renderer)->placeholderIsVisible();
    67 
    68     return RenderBlock::nodeAtPoint(request, result, x, y, tx, ty, placeholderIsVisible ? HitTestBlockBackground : hitTestAction);
    69 }
    7058
    7159VisiblePosition RenderTextControlInnerBlock::positionForPoint(const IntPoint& point)
Note: See TracChangeset for help on using the changeset viewer.