Changeset 116389 in webkit


Ignore:
Timestamp:
May 7, 2012 8:49:57 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

width/height attributes of input element cannot be accessed by JavaScript.
https://bugs.webkit.org/show_bug.cgi?id=70304

Patch by Dongwoo Im <dw.im@samsung.com> on 2012-05-07
Reviewed by Darin Adler.

If the type of input element is image button, width/height attributes should be supported.
These attributes are defined in HTML5 spec.
http://www.w3.org/TR/html5/the-map-element.html#attr-dim-width

Source/WebCore:

Tests: fast/forms/input-width-height-attributes-without-renderer-loaded-image.html

fast/forms/input-width-height-attributes-without-renderer-not-loaded-image.html
fast/forms/input-width-height-attributes-without-renderer.html
fast/forms/input-width-height-attributes.html

  • html/HTMLInputElement.cpp: Add setter/getter functions to query/set width/height of input element.

(WebCore):
(WebCore::HTMLInputElement::height): Gets height of input element.
(WebCore::HTMLInputElement::width): Gets width of input element.
(WebCore::HTMLInputElement::setHeight): Sets height of input element.
(WebCore::HTMLInputElement::setWidth): Sets width of input element.

  • html/HTMLInputElement.h: Add public prototype.

(HTMLInputElement):

  • html/HTMLInputElement.idl: Add width/height attributes.
  • html/ImageInputType.cpp: Add getter functions if the element is an image button.

(WebCore):
(WebCore::ImageInputType::height): Gets height of input element.
(WebCore::ImageInputType::width): Gets width of input element.

  • html/ImageInputType.h: Add prototype.

(ImageInputType):

  • html/InputType.cpp: Add getter functions.

(WebCore::InputType::height): Returns zero.
(WebCore):
(WebCore::InputType::width): Returns zero.

  • html/InputType.h: Add prototype.

(InputType):

LayoutTests:

  • fast/forms/input-width-height-attributes-expected.txt: Added.
  • fast/forms/input-width-height-attributes-without-renderer-expected.txt: Added.
  • fast/forms/input-width-height-attributes-without-renderer-loaded-image-expected.txt: Added.
  • fast/forms/input-width-height-attributes-without-renderer-loaded-image.html: Added.
  • fast/forms/input-width-height-attributes-without-renderer-not-loaded-image-expected.txt: Added.
  • fast/forms/input-width-height-attributes-without-renderer-not-loaded-image.html: Added.
  • fast/forms/input-width-height-attributes-without-renderer.html: Added.
  • fast/forms/input-width-height-attributes.html: Added.
  • fast/forms/resources/green.jpg: Added.
  • fast/forms/resources/image-slow.pl: Added.
Location:
trunk
Files:
10 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r116388 r116389  
     12012-05-07  Dongwoo Im  <dw.im@samsung.com>
     2
     3        width/height attributes of input element cannot be accessed by JavaScript.
     4        https://bugs.webkit.org/show_bug.cgi?id=70304
     5
     6        Reviewed by Darin Adler.
     7
     8        If the type of input element is image button, width/height attributes should be supported.
     9        These attributes are defined in HTML5 spec.
     10        http://www.w3.org/TR/html5/the-map-element.html#attr-dim-width
     11
     12        * fast/forms/input-width-height-attributes-expected.txt: Added.
     13        * fast/forms/input-width-height-attributes-without-renderer-expected.txt: Added.
     14        * fast/forms/input-width-height-attributes-without-renderer-loaded-image-expected.txt: Added.
     15        * fast/forms/input-width-height-attributes-without-renderer-loaded-image.html: Added.
     16        * fast/forms/input-width-height-attributes-without-renderer-not-loaded-image-expected.txt: Added.
     17        * fast/forms/input-width-height-attributes-without-renderer-not-loaded-image.html: Added.
     18        * fast/forms/input-width-height-attributes-without-renderer.html: Added.
     19        * fast/forms/input-width-height-attributes.html: Added.
     20        * fast/forms/resources/green.jpg: Added.
     21        * fast/forms/resources/image-slow.pl: Added.
     22
    1232012-05-07  Kinuko Yasuda  <kinuko@chromium.org>
    224
  • trunk/Source/WebCore/ChangeLog

    r116388 r116389  
     12012-05-07  Dongwoo Im  <dw.im@samsung.com>
     2
     3        width/height attributes of input element cannot be accessed by JavaScript.
     4        https://bugs.webkit.org/show_bug.cgi?id=70304
     5
     6        Reviewed by Darin Adler.
     7
     8        If the type of input element is image button, width/height attributes should be supported.
     9        These attributes are defined in HTML5 spec.
     10        http://www.w3.org/TR/html5/the-map-element.html#attr-dim-width
     11
     12        Tests: fast/forms/input-width-height-attributes-without-renderer-loaded-image.html
     13               fast/forms/input-width-height-attributes-without-renderer-not-loaded-image.html
     14               fast/forms/input-width-height-attributes-without-renderer.html
     15               fast/forms/input-width-height-attributes.html
     16
     17        * html/HTMLInputElement.cpp: Add setter/getter functions to query/set width/height of input element.
     18        (WebCore):
     19        (WebCore::HTMLInputElement::height): Gets height of input element.
     20        (WebCore::HTMLInputElement::width): Gets width of input element.
     21        (WebCore::HTMLInputElement::setHeight): Sets height of input element.
     22        (WebCore::HTMLInputElement::setWidth): Sets width of input element.
     23        * html/HTMLInputElement.h: Add public prototype.
     24        (HTMLInputElement):
     25        * html/HTMLInputElement.idl: Add width/height attributes.
     26        * html/ImageInputType.cpp: Add getter functions if the element is an image button.
     27        (WebCore):
     28        (WebCore::ImageInputType::height): Gets height of input element.
     29        (WebCore::ImageInputType::width): Gets width of input element.
     30        * html/ImageInputType.h: Add prototype.
     31        (ImageInputType):
     32        * html/InputType.cpp: Add getter functions.
     33        (WebCore::InputType::height): Returns zero.
     34        (WebCore):
     35        (WebCore::InputType::width): Returns zero.
     36        * html/InputType.h: Add prototype.
     37        (InputType):
     38
    1392012-05-07  Kinuko Yasuda  <kinuko@chromium.org>
    240
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r115434 r116389  
    88 * Copyright (C) 2010 Google Inc. All rights reserved.
    99 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
     10 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
    1011 *
    1112 * This library is free software; you can redistribute it and/or
     
    18441845        buttons->removeButton(this);
    18451846}
     1847
     1848unsigned HTMLInputElement::height() const
     1849{
     1850    return m_inputType->height();
     1851}
     1852
     1853unsigned HTMLInputElement::width() const
     1854{
     1855    return m_inputType->width();
     1856}
     1857
     1858void HTMLInputElement::setHeight(unsigned height)
     1859{
     1860    setAttribute(heightAttr, String::number(height));
     1861}
     1862
     1863void HTMLInputElement::setWidth(unsigned width)
     1864{
     1865    setAttribute(widthAttr, String::number(width));
     1866}
     1867
    18461868} // namespace
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r114545 r116389  
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    55 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
     6 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
    67 *
    78 * This library is free software; you can redistribute it and/or
     
    237238    static const int maximumLength;
    238239
     240    unsigned height() const;
     241    unsigned width() const;
     242    void setHeight(unsigned);
     243    void setWidth(unsigned);
     244
    239245protected:
    240246    HTMLInputElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
  • trunk/Source/WebCore/html/HTMLInputElement.idl

    r113532 r116389  
    22 * Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
     4 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    3738        attribute [Reflect] boolean formNoValidate;
    3839        attribute [Reflect] DOMString formTarget;
     40        attribute unsigned long height;
    3941        attribute boolean indeterminate;
    4042        readonly attribute [Conditional=DATALIST] HTMLElement list;
     
    6668        void stepDown(in [Optional] long n) raises(DOMException);
    6769
     70        attribute unsigned long width;
    6871        readonly attribute boolean willValidate;
    6972        readonly attribute ValidityState validity;
  • trunk/Source/WebCore/html/ImageInputType.cpp

    r112215 r116389  
    22 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
    33 * Copyright (C) 2010 Google Inc. All rights reserved.
     4 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    2728#include "HTMLImageLoader.h"
    2829#include "HTMLInputElement.h"
     30#include "HTMLNames.h"
     31#include "HTMLParserIdioms.h"
    2932#include "MouseEvent.h"
    3033#include "RenderImage.h"
     
    3235
    3336namespace WebCore {
     37
     38using namespace HTMLNames;
    3439
    3540inline ImageInputType::ImageInputType(HTMLInputElement* element)
     
    175180}
    176181
     182unsigned ImageInputType::height() const
     183{
     184    RefPtr<HTMLInputElement> element = this->element();
     185
     186    if (!element->renderer()) {
     187        // Check the attribute first for an explicit pixel value.
     188        unsigned height;
     189        if (parseHTMLNonNegativeInteger(element->fastGetAttribute(heightAttr), height))
     190            return height;
     191
     192        // If the image is available, use its height.
     193        if (m_imageLoader->image())
     194            return m_imageLoader->image()->imageSizeForRenderer(element->renderer(), 1).height();
     195    }
     196
     197    element->document()->updateLayout();
     198
     199    RenderBox* box = element->renderBox();
     200    return box ? adjustForAbsoluteZoom(box->contentHeight(), box) : 0;
     201}
     202
     203unsigned ImageInputType::width() const
     204{
     205    RefPtr<HTMLInputElement> element = this->element();
     206
     207    if (!element->renderer()) {
     208        // Check the attribute first for an explicit pixel value.
     209        unsigned width;
     210        if (parseHTMLNonNegativeInteger(element->fastGetAttribute(widthAttr), width))
     211            return width;
     212
     213        // If the image is available, use its width.
     214        if (m_imageLoader->image())
     215            return m_imageLoader->image()->imageSizeForRenderer(element->renderer(), 1).width();
     216    }
     217
     218    element->document()->updateLayout();
     219
     220    RenderBox* box = element->renderBox();
     221    return box ? adjustForAbsoluteZoom(box->contentWidth(), box) : 0;
     222}
     223
    177224} // namespace WebCore
  • trunk/Source/WebCore/html/ImageInputType.h

    r103400 r116389  
    22 * Copyright (C) 2010 Google Inc. All rights reserved.
    33 * Copyright (C) 2011 Apple Inc. All rights reserved.
     4 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    6263    virtual bool isEnumeratable() OVERRIDE;
    6364    virtual bool shouldRespectHeightAndWidthAttributes() OVERRIDE;
     65    virtual unsigned height() const OVERRIDE;
     66    virtual unsigned width() const OVERRIDE;
    6467
    6568    OwnPtr<HTMLImageLoader> m_imageLoader;
  • trunk/Source/WebCore/html/InputType.cpp

    r116277 r116389  
    77 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
    88 * Copyright (C) 2010 Google Inc. All rights reserved.
     9 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
    910 *
    1011 * This library is free software; you can redistribute it and/or
     
    4344#include "HTMLFormElement.h"
    4445#include "HTMLInputElement.h"
     46#include "HTMLNames.h"
     47#include "HTMLParserIdioms.h"
    4548#include "HTMLShadowElement.h"
    4649#include "HiddenInputType.h"
     
    773776}
    774777
     778unsigned InputType::height() const
     779{
     780    return 0;
     781}
     782
     783unsigned InputType::width() const
     784{
     785    return 0;
     786}
     787
    775788namespace InputTypeNames {
    776789
  • trunk/Source/WebCore/html/InputType.h

    r115704 r116389  
    22 * Copyright (C) 2010 Google Inc. All rights reserved.
    33 * Copyright (C) 2011 Apple Inc. All rights reserved.
     4 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    276277    virtual bool supportsIndeterminateAppearance() const;
    277278
     279    // Gets width and height of the input element if the type of the
     280    // element is image. It returns 0 if the element is not image type.
     281    virtual unsigned height() const;
     282    virtual unsigned width() const;
     283
    278284protected:
    279285    InputType(HTMLInputElement* element) : m_element(element) { }
Note: See TracChangeset for help on using the changeset viewer.