Changeset 85190 in webkit


Ignore:
Timestamp:
Apr 28, 2011 9:12:14 AM (13 years ago)
Author:
satish@chromium.org
Message:

2011-04-28 Satish Sampath <satish@chromium.org>

Reviewed by Tony Gentilcore.

Speech input button layout issues with padding and border.
https://bugs.webkit.org/show_bug.cgi?id=59613

  • fast/speech/input-text-speechbutton-expected.txt:
  • fast/speech/input-text-speechbutton.html: Updated to test with padding.

2011-04-28 Satish Sampath <satish@chromium.org>

Reviewed by Tony Gentilcore.

Speech input button layout issues with padding and border.
https://bugs.webkit.org/show_bug.cgi?id=59613

  • rendering/RenderTextControlSingleLine.cpp: (WebCore::RenderTextControlSingleLine::layout): (WebCore::RenderTextControlSingleLine::nodeAtPoint): (WebCore::RenderTextControlSingleLine::forwardEvent):
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r85187 r85190  
     12011-04-28  Satish Sampath  <satish@chromium.org>
     2
     3        Reviewed by Tony Gentilcore.
     4
     5        Speech input button layout issues with padding and border.
     6        https://bugs.webkit.org/show_bug.cgi?id=59613
     7
     8        * fast/speech/input-text-speechbutton-expected.txt:
     9        * fast/speech/input-text-speechbutton.html: Updated to test with padding.
     10
    1112011-04-28  Chris Fleizach  <cfleizach@apple.com>
    212
  • trunk/LayoutTests/fast/speech/input-text-speechbutton-expected.txt

    r74097 r85190  
    44
    55
    6 PASS document.getElementById("speechInput").value is "Pictures of the moon"
    7 PASS document.getElementById("speechInput").value is "Pictures of the moon"
     6PASS document.getElementById("speechInput1").value is "Pictures of the moon"
     7PASS document.getElementById("speechInput2").value is "Pictures of the moon"
     8PASS document.getElementById("speechInput3").value is "Pictures of the moon"
     9PASS document.getElementById("speechInput4").value is "Pictures of the moon"
    810PASS successfullyParsed is true
    911
    1012TEST COMPLETE
    11 
     13   
  • trunk/LayoutTests/fast/speech/input-text-speechbutton.html

    r72591 r85190  
    1111description('Tests for speech button click with &lt;input type="text" speech>.');
    1212
     13function startSpeechInput(id) {
     14    // Clicking the speech button should fill in mock speech-recognized text.
     15    var input = document.getElementById(id);
     16    var x = input.offsetLeft + input.offsetWidth - 4;
     17    var y = input.offsetTop + input.offsetHeight / 2;
     18    if (input.style.paddingRight.length)
     19        x -= parseInt(input.style.paddingRight.substr(0, input.style.paddingRight.length - 2));
     20    eventSender.mouseMoveTo(x, y);
     21    eventSender.mouseDown();
     22    eventSender.mouseUp();
     23}
     24
     25var testIndex = 1;
    1326function onWebkitSpeechChange() {
    14     shouldBeEqualToString('document.getElementById("speechInput").value', 'Pictures of the moon');
     27    shouldBeEqualToString('document.getElementById("speechInput' + testIndex + '").value', 'Pictures of the moon');
     28    if (testIndex == 4) {
     29        finishJSTest();
     30        return;
     31    }
     32    ++testIndex;
    1533    setTimeout(function() {
    16         var input = document.getElementById('speechInput');
    17         input.dir = 'rtl';
    18         input.value = '';
    19         input.onwebkitspeechchange = function() {
    20             shouldBeEqualToString('document.getElementById("speechInput").value',
    21                                   'Pictures of the moon');
    22             finishJSTest();
    23         };
    24 
    25         var x = input.offsetLeft + 4;
    26         var y = input.offsetTop + input.offsetHeight / 2;
    27         eventSender.mouseMoveTo(x, y);
    28         eventSender.mouseDown();
    29         eventSender.mouseUp();
     34        startSpeechInput("speechInput" + testIndex);
    3035    }, 50);
    3136}
     
    3439    if (window.layoutTestController && window.eventSender) {
    3540        layoutTestController.addMockSpeechInputResult('Pictures of the moon', 1.0, '');
    36 
    37         // Clicking the speech button should fill in mock speech-recognized text.
    38         var input = document.getElementById('speechInput');
    39         var x = input.offsetLeft + input.offsetWidth - 4;
    40         var y = input.offsetTop + input.offsetHeight / 2;
    41         eventSender.mouseMoveTo(x, y);
    42         eventSender.mouseDown();
    43         eventSender.mouseUp();
     41        startSpeechInput("speechInput" + testIndex);
    4442    }
    4543}
     
    5048</script>
    5149<script src="../js/resources/js-test-post.js"></script>
    52 <input id='speechInput' x-webkit-speech onwebkitspeechchange="onWebkitSpeechChange()">
     50<input id='speechInput1' x-webkit-speech onwebkitspeechchange="onWebkitSpeechChange()">
     51<input id='speechInput2' x-webkit-speech onwebkitspeechchange="onWebkitSpeechChange()" dir="rtl">
     52<input id='speechInput3' x-webkit-speech onwebkitspeechchange="onWebkitSpeechChange()" style="padding:5px 10px">
     53<input id='speechInput4' x-webkit-speech onwebkitspeechchange="onWebkitSpeechChange()" style="padding:5px 10px" dir="rtl">
    5354</body>
    5455</html>
     56
  • trunk/Source/WebCore/ChangeLog

    r85188 r85190  
     12011-04-28  Satish Sampath  <satish@chromium.org>
     2
     3        Reviewed by Tony Gentilcore.
     4
     5        Speech input button layout issues with padding and border.
     6        https://bugs.webkit.org/show_bug.cgi?id=59613
     7
     8        * rendering/RenderTextControlSingleLine.cpp:
     9        (WebCore::RenderTextControlSingleLine::layout):
     10        (WebCore::RenderTextControlSingleLine::nodeAtPoint):
     11        (WebCore::RenderTextControlSingleLine::forwardEvent):
     12
    1132011-04-28  Carlos Garcia Campos  <cgarcia@igalia.com>
    214
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp

    r84695 r85190  
    309309            button->setLocation(x, y);
    310310        } else {
    311             // For non-search fields which are simpler and we let the defaut layout handle things
    312             // except for small tweaking below.
    313             button->setLocation(button->x() + paddingRight(), (height() - button->height()) / 2);
     311            int x = width() - borderRight() - paddingRight() - button->width();
     312            RenderBox* spinBox = m_innerSpinButton ? m_innerSpinButton->renderBox() : 0;
     313            if (style()->isLeftToRightDirection())
     314                x -= spinBox ? spinBox->width() : 0;
     315            else
     316                innerTextRenderer->setX(paddingLeft() + borderLeft() + (spinBox ? spinBox->width() : 0));
     317            int y = (height() - button->height()) / 2;
     318            button->setLocation(x, y);
    314319        }
    315320    }
     
    370375        innerNode = m_resultsButton.get();
    371376
     377#if ENABLE(INPUT_SPEECH)
     378    if (!innerNode && m_speechButton && m_speechButton->renderer()) {
     379        int buttonLeft = tx + x() + innerBlockRenderer->x() + innerBlockRenderer->width() - m_speechButton->renderBox()->width();
     380        if (xPos >= buttonLeft)
     381            innerNode = m_speechButton.get();
     382    }
     383#endif
     384
    372385    if (!innerNode) {
    373386        int textRight = textLeft + innerTextRenderer->width();
     
    406419#if ENABLE(INPUT_SPEECH)
    407420    if (RenderBox* speechBox = m_speechButton ? m_speechButton->renderBox() : 0) {
    408         FloatPoint pointInTextControlCoords = absoluteToLocal(static_cast<MouseEvent*>(event)->absoluteLocation(), false, true);
     421        RenderBox* parent = innerTextRenderer ? innerTextRenderer : this;
     422        FloatPoint pointInTextControlCoords = parent->absoluteToLocal(static_cast<MouseEvent*>(event)->absoluteLocation(), false, true);
    409423        if (speechBox->frameRect().contains(roundedIntPoint(pointInTextControlCoords))) {
    410424            m_speechButton->defaultEventHandler(event);
Note: See TracChangeset for help on using the changeset viewer.