Changeset 142054 in webkit


Ignore:
Timestamp:
Feb 6, 2013 4:41:07 PM (11 years ago)
Author:
ojan@chromium.org
Message:

display:none file upload button crashes
https://bugs.webkit.org/show_bug.cgi?id=109102

Reviewed by Levi Weintraub.

Source/WebCore:

Test: fast/forms/file/display-none-upload-button.html

  • rendering/RenderFileUploadControl.cpp:

(WebCore::nodeWidth):
(WebCore::RenderFileUploadControl::paintObject):
Having an upload button doesn't mean we have a rendered upload button.
Null check the renderer before trying to access it.

LayoutTests:

  • fast/forms/file/display-none-upload-button-expected.txt: Added.
  • fast/forms/file/display-none-upload-button.html: Added.

Tests that we don't crash. Also exposes a bug that the baseline and height of
the input don't include the height of the filename text.

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r142053 r142054  
     12013-02-06  Ojan Vafai  <ojan@chromium.org>
     2
     3        display:none file upload button crashes
     4        https://bugs.webkit.org/show_bug.cgi?id=109102
     5
     6        Reviewed by Levi Weintraub.
     7
     8        * fast/forms/file/display-none-upload-button-expected.txt: Added.
     9        * fast/forms/file/display-none-upload-button.html: Added.
     10        Tests that we don't crash. Also exposes a bug that the baseline and height of
     11        the input don't include the height of the filename text.
     12
    1132013-02-06  Stephen Chenney  <schenney@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r142051 r142054  
     12013-02-06  Ojan Vafai  <ojan@chromium.org>
     2
     3        display:none file upload button crashes
     4        https://bugs.webkit.org/show_bug.cgi?id=109102
     5
     6        Reviewed by Levi Weintraub.
     7
     8        Test: fast/forms/file/display-none-upload-button.html
     9
     10        * rendering/RenderFileUploadControl.cpp:
     11        (WebCore::nodeWidth):
     12        (WebCore::RenderFileUploadControl::paintObject):
     13        Having an upload button doesn't mean we have a rendered upload button.
     14        Null check the renderer before trying to access it.
     15
    1162013-02-06  Dirk Schulze  <dschulze@adobe.com>
    217
  • trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp

    r139329 r142054  
    9090static int nodeWidth(Node* node)
    9191{
    92     return node ? node->renderBox()->pixelSnappedWidth() : 0;
     92    return (node && node->renderBox()) ? node->renderBox()->pixelSnappedWidth() : 0;
    9393}
    9494
     
    137137        else
    138138            textX = contentLeft + contentWidth() - buttonAndIconWidth - font.width(textRun);
     139
     140        LayoutUnit textY = 0;
    139141        // We want to match the button's baseline
    140         RenderButton* buttonRenderer = toRenderButton(button->renderer());
    141142        // FIXME: Make this work with transforms.
    142         LayoutUnit textY = paintOffset.y() + buttonRenderer->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine);
     143        if (RenderButton* buttonRenderer = toRenderButton(button->renderer()))
     144            textY = paintOffset.y() + buttonRenderer->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine);
     145        else
     146            textY = baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine);
    143147
    144148        paintInfo.context->setFillColor(style()->visitedDependentColor(CSSPropertyColor), style()->colorSpace());
Note: See TracChangeset for help on using the changeset viewer.