Changeset 63288 in webkit


Ignore:
Timestamp:
Jul 14, 2010 1:20:42 AM (14 years ago)
Author:
tkent@chromium.org
Message:

<input type=number> UI: inner spin button layout
https://bugs.webkit.org/show_bug.cgi?id=41924

Reviewed by Darin Fisher.

WebCore:

Add layout/event/style code for the inner spin button, which is
going to be used for Windows implementation.
No new tests because no ports implement the inner spin button yet.

  • rendering/RenderTextControlSingleLine.cpp: Introduce m_innerSpinButton.

(WebCore::RenderTextControlSingleLine::~RenderTextControlSingleLine):

Detach m_innerSpinButton.

(WebCore::RenderTextControlSingleLine::layout):

Set position and size of m_innerSpinButton.

(WebCore::RenderTextControlSingleLine::nodeAtPoint):

Handle m_innerSpinButton.

(WebCore::RenderTextControlSingleLine::forwardEvent):

Handle m_innerSpinButton.

(WebCore::RenderTextControlSingleLine::textBlockWidth):

Shorten the text block width by m_innerSpinButton width.

(WebCore::RenderTextControlSingleLine::preferredContentWidth):

Add m_innerSpinButton width.

(WebCore::RenderTextControlSingleLine::createSubtreeIfNeeded):

Handle m_innerSpinButton.

(WebCore::RenderTextControlSingleLine::createInnerSpinButtonStyle):

Make style for m_innerSpinButton with INNER_SPIN_BUTTON pseudo class.

  • rendering/RenderTextControlSingleLine.h:

LayoutTests:

Update test expectations because a shadow node is added to
<input type=number>.

  • platform/mac/fast/forms/input-appearance-spinbutton-disabled-readonly-expected.html
  • platform/mac/fast/forms/input-appearance-spinbutton-expected.txt:
  • platform/mac/fast/forms/input-appearance-spinbutton-up-expected.txt:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r63287 r63288  
     12010-07-14  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        <input type=number> UI: inner spin button layout
     6        https://bugs.webkit.org/show_bug.cgi?id=41924
     7
     8        Update test expectations because a shadow node is added to
     9        <input type=number>.
     10
     11        * platform/mac/fast/forms/input-appearance-spinbutton-disabled-readonly-expected.html
     12        * platform/mac/fast/forms/input-appearance-spinbutton-expected.txt:
     13        * platform/mac/fast/forms/input-appearance-spinbutton-up-expected.txt:
     14
    1152010-07-14  Kent Tamura  <tkent@chromium.org>
    216
  • trunk/LayoutTests/platform/mac/fast/forms/input-appearance-spinbutton-disabled-readonly-expected.txt

    r63286 r63288  
    1010        RenderInline {LABEL} at (0,0) size 306x18
    1111          RenderTextControl {INPUT} at (2,2) size 218x29 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     12            RenderBlock {DIV} at (192,2) size 0x25
    1213            RenderBlock {DIV} at (196,1) size 19x27
    1314          RenderText {#text} at (222,10) size 84x18
     
    1617        RenderInline {LABEL} at (0,0) size 314x18
    1718          RenderTextControl {INPUT} at (2,2) size 218x29 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     19            RenderBlock {DIV} at (192,2) size 0x25
    1820            RenderBlock {DIV} at (196,1) size 19x27
    1921          RenderText {#text} at (222,10) size 92x18
     
    2224        RenderInline {LABEL} at (0,0) size 324x18
    2325          RenderTextControl {INPUT} at (2,2) size 218x29 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     26            RenderBlock {DIV} at (192,2) size 0x25
    2427            RenderBlock {DIV} at (196,1) size 19x27
    2528          RenderText {#text} at (222,10) size 102x18
  • trunk/LayoutTests/platform/mac/fast/forms/input-appearance-spinbutton-expected.txt

    r58561 r63288  
    1919                  RenderBR {BR} at (104,14) size 0x0
    2020                  RenderTextControl {INPUT} at (0,19) size 100x16 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     21                    RenderBlock {DIV} at (80,2) size 0x12
    2122                    RenderBlock {DIV} at (84,1) size 13x15
    2223                RenderBlock {DIV} at (1,36) size 178x36
     
    2627                  RenderBR {BR} at (106,14) size 0x0
    2728                  RenderTextControl {INPUT} at (0,19) size 102x17 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     29                    RenderBlock {DIV} at (82,2) size 0x13
    2830                    RenderBlock {DIV} at (86,1) size 13x15
    2931                RenderBlock {DIV} at (1,72) size 178x37
     
    3335                  RenderBR {BR} at (108,14) size 0x0
    3436                  RenderTextControl {INPUT} at (0,19) size 104x18 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     37                    RenderBlock {DIV} at (84,2) size 0x14
    3538                    RenderBlock {DIV} at (88,2) size 13x15
    3639                RenderBlock {DIV} at (1,109) size 178x46
     
    4043                  RenderBR {BR} at (133,16) size 0x0
    4144                  RenderTextControl {INPUT} at (2,25) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     45                    RenderBlock {DIV} at (105,2) size 0x15
    4246                    RenderBlock {DIV} at (109,2) size 13x15
    4347                RenderBlock {DIV} at (1,155) size 178x50
     
    4751                  RenderBR {BR} at (135,17) size 0x0
    4852                  RenderTextControl {INPUT} at (2,27) size 127x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     53                    RenderBlock {DIV} at (107,2) size 0x17
    4954                    RenderBlock {DIV} at (111,3) size 13x15
    5055                RenderBlock {DIV} at (1,205) size 178x52
     
    5459                  RenderBR {BR} at (156,18) size 0x0
    5560                  RenderTextControl {INPUT} at (2,28) size 148x22 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     61                    RenderBlock {DIV} at (126,2) size 0x18
    5662                    RenderBlock {DIV} at (130,0) size 15x22
    5763                RenderBlock {DIV} at (1,257) size 178x54
     
    6167                  RenderBR {BR} at (158,19) size 0x0
    6268                  RenderTextControl {INPUT} at (2,29) size 150x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     69                    RenderBlock {DIV} at (128,2) size 0x19
    6370                    RenderBlock {DIV} at (132,1) size 15x22
    6471                RenderBlock {DIV} at (1,311) size 178x56
     
    6875                  RenderBR {BR} at (178,20) size 0x0
    6976                  RenderTextControl {INPUT} at (2,30) size 170x24 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     77                    RenderBlock {DIV} at (148,2) size 0x20
    7078                    RenderBlock {DIV} at (152,1) size 15x22
    7179              RenderTableCell {TD} at (184,2) size 253x524 [r=0 c=1 rs=1 cs=1]
     
    7684                  RenderBR {BR} at (180,20) size 0x0
    7785                  RenderTextControl {INPUT} at (2,30) size 172x24 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     86                    RenderBlock {DIV} at (150,2) size 0x20
    7887                    RenderBlock {DIV} at (154,1) size 15x22
    7988                RenderBlock {DIV} at (1,57) size 251x60
     
    8392                  RenderBR {BR} at (182,21) size 0x0
    8493                  RenderTextControl {INPUT} at (2,32) size 174x26 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     94                    RenderBlock {DIV} at (152,2) size 0x22
    8595                    RenderBlock {DIV} at (156,2) size 15x22
    8696                RenderBlock {DIV} at (1,117) size 251x62
     
    90100                  RenderBR {BR} at (203,22) size 0x0
    91101                  RenderTextControl {INPUT} at (2,33) size 195x27 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     102                    RenderBlock {DIV} at (169,2) size 0x23
    92103                    RenderBlock {DIV} at (173,0) size 19x27
    93104                RenderBlock {DIV} at (1,179) size 251x64
     
    97108                  RenderBR {BR} at (205,23) size 0x0
    98109                  RenderTextControl {INPUT} at (2,34) size 197x28 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     110                    RenderBlock {DIV} at (171,2) size 0x24
    99111                    RenderBlock {DIV} at (175,1) size 19x27
    100112                RenderBlock {DIV} at (1,243) size 251x66
     
    104116                  RenderBR {BR} at (226,24) size 0x0
    105117                  RenderTextControl {INPUT} at (2,35) size 218x29 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     118                    RenderBlock {DIV} at (192,2) size 0x25
    106119                    RenderBlock {DIV} at (196,1) size 19x27
    107120                RenderBlock {DIV} at (1,309) size 251x68
     
    111124                  RenderBR {BR} at (228,25) size 0x0
    112125                  RenderTextControl {INPUT} at (2,36) size 220x30 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     126                    RenderBlock {DIV} at (194,2) size 0x26
    113127                    RenderBlock {DIV} at (198,2) size 19x27
    114128                RenderBlock {DIV} at (1,377) size 251x72
     
    118132                  RenderBR {BR} at (249,26) size 0x0
    119133                  RenderTextControl {INPUT} at (2,38) size 241x32 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     134                    RenderBlock {DIV} at (215,2) size 0x28
    120135                    RenderBlock {DIV} at (219,3) size 19x27
    121136                RenderBlock {DIV} at (1,449) size 251x74
     
    125140                  RenderBR {BR} at (251,27) size 0x0
    126141                  RenderTextControl {INPUT} at (2,39) size 243x33 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     142                    RenderBlock {DIV} at (217,2) size 0x29
    127143                    RenderBlock {DIV} at (221,3) size 19x27
    128144layer at (14,129) size 94x10
  • trunk/LayoutTests/platform/mac/fast/forms/input-appearance-spinbutton-up-expected.txt

    r61751 r63288  
    1010      RenderBlock (anonymous) at (0,34) size 784x31
    1111        RenderTextControl {INPUT} at (2,2) size 195x27 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     12          RenderBlock {DIV} at (169,2) size 0x23
    1213          RenderBlock {DIV} at (173,0) size 19x27
    1314        RenderText {#text} at (0,0) size 0x0
  • trunk/WebCore/ChangeLog

    r63286 r63288  
     12010-07-14  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        <input type=number> UI: inner spin button layout
     6        https://bugs.webkit.org/show_bug.cgi?id=41924
     7
     8        Add layout/event/style code for the inner spin button, which is
     9        going to be used for Windows implementation.
     10        No new tests because no ports implement the inner spin button yet.
     11
     12        * rendering/RenderTextControlSingleLine.cpp:
     13          Introduce m_innerSpinButton.
     14        (WebCore::RenderTextControlSingleLine::~RenderTextControlSingleLine):
     15          Detach m_innerSpinButton.
     16        (WebCore::RenderTextControlSingleLine::layout):
     17          Set position and size of m_innerSpinButton.
     18        (WebCore::RenderTextControlSingleLine::nodeAtPoint):
     19          Handle m_innerSpinButton.
     20        (WebCore::RenderTextControlSingleLine::forwardEvent):
     21          Handle m_innerSpinButton.
     22        (WebCore::RenderTextControlSingleLine::textBlockWidth):
     23          Shorten the text block width by m_innerSpinButton width.
     24        (WebCore::RenderTextControlSingleLine::preferredContentWidth):
     25          Add m_innerSpinButton width.
     26        (WebCore::RenderTextControlSingleLine::createSubtreeIfNeeded):
     27          Handle m_innerSpinButton.
     28        (WebCore::RenderTextControlSingleLine::createInnerSpinButtonStyle):
     29          Make style for m_innerSpinButton with INNER_SPIN_BUTTON pseudo class.
     30        * rendering/RenderTextControlSingleLine.h:
     31
    1322010-07-14  Kent Tamura  <tkent@chromium.org>
    233
  • trunk/WebCore/rendering/RenderTextControlSingleLine.cpp

    r63179 r63288  
    7070        m_innerBlock->detach();
    7171
     72    if (m_innerSpinButton)
     73        m_innerSpinButton->detach();
    7274    if (m_outerSpinButton)
    7375        m_outerSpinButton->detach();
     
    257259    if (currentHeight < height())
    258260        childBlock->setY((height() - currentHeight) / 2);
     261
     262    // Ignores the paddings for the inner spin button.
     263    if (RenderBox* spinBox = m_innerSpinButton ? m_innerSpinButton->renderBox() : 0) {
     264        spinBox->setLocation(spinBox->x() + paddingRight(), borderTop());
     265        spinBox->setHeight(height() - borderTop() - borderBottom());
     266    }
    259267
    260268    // Center the spin button vertically, and move it to the right by
     
    289297
    290298    // If we found a spin button, we're done.
     299    if (m_innerSpinButton && result.innerNode() == m_innerSpinButton)
     300        return true;
    291301    if (m_outerSpinButton && result.innerNode() == m_outerSpinButton)
    292302        return true;
     
    373383    else if (m_cancelButton && localPoint.x() > textRight)
    374384        m_cancelButton->defaultEventHandler(event);
     385    else if (m_innerSpinButton && localPoint.x() > textRight && localPoint.x() < textRight + m_innerSpinButton->renderBox()->width())
     386        m_innerSpinButton->defaultEventHandler(event);
    375387    else if (m_outerSpinButton && localPoint.x() > textRight)
    376388        m_outerSpinButton->defaultEventHandler(event);
     
    464476        cancelRenderer->calcWidth();
    465477        width -= cancelRenderer->width() + cancelRenderer->marginLeft() + cancelRenderer->marginRight();
     478    }
     479
     480    if (RenderBox* spinRenderer = m_innerSpinButton ? m_innerSpinButton->renderBox() : 0) {
     481        spinRenderer->calcWidth();
     482        width -= spinRenderer->width() + spinRenderer->marginLeft() + spinRenderer->marginRight();
    466483    }
    467484
     
    531548                  cancelRenderer->paddingLeft() + cancelRenderer->paddingRight();
    532549
     550    if (RenderBox* spinRenderer = m_innerSpinButton ? m_innerSpinButton->renderBox() : 0)
     551        result += spinRenderer->minPrefWidth();
     552
    533553#if ENABLE(INPUT_SPEECH)
    534554    if (RenderBox* speechRenderer = m_speechButton ? m_speechButton->renderBox() : 0) {
     
    595615    if (!createSubtree) {
    596616        RenderTextControl::createSubtreeIfNeeded(m_innerBlock.get());
    597         if (inputElement()->hasSpinButton() && !m_outerSpinButton) {
     617        bool hasSpinButton = inputElement()->hasSpinButton();
     618        if (hasSpinButton && !m_innerSpinButton) {
     619            m_innerSpinButton = SpinButtonElement::create(node());
     620            m_innerSpinButton->attachInnerElement(node(), createInnerSpinButtonStyle(), renderArena());
     621        }
     622        if (hasSpinButton && !m_outerSpinButton) {
    598623            m_outerSpinButton = SpinButtonElement::create(node());
    599624            m_outerSpinButton->attachInnerElement(node(), createOuterSpinButtonStyle(), renderArena());
     
    762787    cancelBlockStyle->setVisibility(visibilityForCancelButton());
    763788    return cancelBlockStyle.release();
     789}
     790
     791PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerSpinButtonStyle() const
     792{
     793    ASSERT(node()->isHTMLElement());
     794    RefPtr<RenderStyle> buttonStyle = getCachedPseudoStyle(INNER_SPIN_BUTTON);
     795    if (!buttonStyle)
     796        buttonStyle = RenderStyle::create();
     797    buttonStyle->inheritFrom(style());
     798    return buttonStyle.release();
    764799}
    765800
  • trunk/WebCore/rendering/RenderTextControlSingleLine.h

    r63179 r63288  
    9999    PassRefPtr<RenderStyle> createResultsButtonStyle(const RenderStyle* startStyle) const;
    100100    PassRefPtr<RenderStyle> createCancelButtonStyle(const RenderStyle* startStyle) const;
     101    PassRefPtr<RenderStyle> createInnerSpinButtonStyle() const;
    101102    PassRefPtr<RenderStyle> createOuterSpinButtonStyle() const;
    102103#if ENABLE(INPUT_SPEECH)
     
    147148    RefPtr<SearchFieldResultsButtonElement> m_resultsButton;
    148149    RefPtr<SearchFieldCancelButtonElement> m_cancelButton;
     150    RefPtr<TextControlInnerElement> m_innerSpinButton;
    149151    RefPtr<TextControlInnerElement> m_outerSpinButton;
    150152#if ENABLE(INPUT_SPEECH)
Note: See TracChangeset for help on using the changeset viewer.