Changeset 54999 in webkit


Ignore:
Timestamp:
Feb 18, 2010 9:00:52 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-02-18 Yaar Schnitman <yaar@chromium.org>

Reviewed by Darin Adler.

Normalize custom ctors for Image, Option, Audio
https://bugs.webkit.org/show_bug.cgi?id=34782

  • fast/js/custom-constructors-expected.txt: Added.
  • fast/js/custom-constructors.html: Added.
  • fast/js/script-tests/custom-constructors.js: Added.

2010-02-18 Yaar Schnitman <yaar@chromium.org>

Reviewed by Darin Adler.

Normalize custom ctors for Image, Option, Audio
https://bugs.webkit.org/show_bug.cgi?id=34782

Test: fast/js/custom-constructors.html

  • bindings/js/JSAudioConstructor.cpp: (WebCore::JSAudioConstructor::JSAudioConstructor): (WebCore::constructAudio):
  • bindings/js/JSImageConstructor.cpp: (WebCore::constructImage):
  • bindings/js/JSOptionConstructor.cpp: (WebCore::constructHTMLOptionElement):
  • bindings/v8/custom/V8HTMLAudioElementConstructor.cpp: (WebCore::v8HTMLAudioElementConstructorCallback):
  • bindings/v8/custom/V8HTMLImageElementConstructor.cpp: (WebCore::v8HTMLImageElementConstructorCallback):
  • bindings/v8/custom/V8HTMLOptionElementConstructor.cpp: (WebCore::v8HTMLOptionElementConstructorCallback):
  • html/HTMLAudioElement.cpp: (WebCore::HTMLAudioElement::HTMLAudioElement): (WebCore::HTMLAudioElement::createForJSConstructor):
  • html/HTMLAudioElement.h:
  • html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::createForJSConstructor): (WebCore::HTMLImageElement::mapToEntry): (WebCore::HTMLImageElement::createRenderer): (WebCore::HTMLImageElement::attach): (WebCore::HTMLImageElement::width): (WebCore::HTMLImageElement::height): (WebCore::HTMLImageElement::naturalHeight):
  • html/HTMLImageElement.h:
  • html/HTMLOptionElement.cpp: (WebCore::HTMLOptionElement::HTMLOptionElement): (WebCore::HTMLOptionElement::createForJSConstructor): (WebCore::HTMLOptionElement::ownerSelectElement): (WebCore::HTMLOptionElement::nonRendererRenderStyle): (WebCore::HTMLOptionElement::disabled): (WebCore::HTMLOptionElement::insertedIntoTree):
  • html/HTMLOptionElement.h:
Location:
trunk
Files:
3 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r54993 r54999  
     12010-02-18  Yaar Schnitman  <yaar@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Normalize custom ctors for Image, Option, Audio
     6        https://bugs.webkit.org/show_bug.cgi?id=34782
     7
     8        * fast/js/custom-constructors-expected.txt: Added.
     9        * fast/js/custom-constructors.html: Added.
     10        * fast/js/script-tests/custom-constructors.js: Added.
     11
    1122010-02-18  Alexey Proskuryakov  <ap@apple.com>
    213
  • trunk/WebCore/ChangeLog

    r54997 r54999  
     12010-02-18  Yaar Schnitman  <yaar@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Normalize custom ctors for Image, Option, Audio
     6        https://bugs.webkit.org/show_bug.cgi?id=34782
     7
     8        Test: fast/js/custom-constructors.html
     9
     10        * bindings/js/JSAudioConstructor.cpp:
     11        (WebCore::JSAudioConstructor::JSAudioConstructor):
     12        (WebCore::constructAudio):
     13        * bindings/js/JSImageConstructor.cpp:
     14        (WebCore::constructImage):
     15        * bindings/js/JSOptionConstructor.cpp:
     16        (WebCore::constructHTMLOptionElement):
     17        * bindings/v8/custom/V8HTMLAudioElementConstructor.cpp:
     18        (WebCore::v8HTMLAudioElementConstructorCallback):
     19        * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
     20        (WebCore::v8HTMLImageElementConstructorCallback):
     21        * bindings/v8/custom/V8HTMLOptionElementConstructor.cpp:
     22        (WebCore::v8HTMLOptionElementConstructorCallback):
     23        * html/HTMLAudioElement.cpp:
     24        (WebCore::HTMLAudioElement::HTMLAudioElement):
     25        (WebCore::HTMLAudioElement::createForJSConstructor):
     26        * html/HTMLAudioElement.h:
     27        * html/HTMLImageElement.cpp:
     28        (WebCore::HTMLImageElement::createForJSConstructor):
     29        (WebCore::HTMLImageElement::mapToEntry):
     30        (WebCore::HTMLImageElement::createRenderer):
     31        (WebCore::HTMLImageElement::attach):
     32        (WebCore::HTMLImageElement::width):
     33        (WebCore::HTMLImageElement::height):
     34        (WebCore::HTMLImageElement::naturalHeight):
     35        * html/HTMLImageElement.h:
     36        * html/HTMLOptionElement.cpp:
     37        (WebCore::HTMLOptionElement::HTMLOptionElement):
     38        (WebCore::HTMLOptionElement::createForJSConstructor):
     39        (WebCore::HTMLOptionElement::ownerSelectElement):
     40        (WebCore::HTMLOptionElement::nonRendererRenderStyle):
     41        (WebCore::HTMLOptionElement::disabled):
     42        (WebCore::HTMLOptionElement::insertedIntoTree):
     43        * html/HTMLOptionElement.h:
     44
    1452010-02-12  Brett Wilson  <brettw@chromium.org>
    246
  • trunk/WebCore/bindings/js/JSAudioConstructor.cpp

    r47236 r54999  
    11/*
    2  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
     
    3131
    3232#include "HTMLAudioElement.h"
    33 #include "HTMLNames.h"
    3433#include "JSHTMLAudioElement.h"
    35 #include "ScriptExecutionContext.h"
    36 #include "Text.h"
    3734#include <runtime/Error.h>
    3835
     
    4744{
    4845    putDirect(exec->propertyNames().prototype, JSHTMLAudioElementPrototype::self(exec, globalObject), None);
    49     putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
     46    putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum);
    5047}
    5148
    5249static JSObject* constructAudio(ExecState* exec, JSObject* constructor, const ArgList& args)
    5350{
    54     JSAudioConstructor* jsAudio = static_cast<JSAudioConstructor*>(constructor);
    55     // FIXME: Why doesn't this need the call toJS on the document like JSImageConstructor?
    56     Document* document = jsAudio->document();
     51    JSAudioConstructor* jsConstructor = static_cast<JSAudioConstructor*>(constructor);
     52
     53    Document* document = jsConstructor->document();
    5754    if (!document)
    5855        return throwError(exec, ReferenceError, "Audio constructor associated document is unavailable");
    5956
    60     RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(HTMLNames::audioTag, document);
    61     audio->setAutobuffer(true);
    62     if (args.size() > 0) {
    63         audio->setSrc(args.at(0).toString(exec));
    64         audio->scheduleLoad();
    65     }
    66     return asObject(toJS(exec, jsAudio->globalObject(), audio.release()));
     57    // Calling toJS on the document causes the JS document wrapper to be
     58    // added to the window object. This is done to ensure that JSDocument::markChildren
     59    // will be called, which will cause the audio element to be marked if necessary.
     60    toJS(exec, jsConstructor->globalObject(), document);
     61
     62    // FIXME: This converts an undefined argument to the string "undefined", but possibly we
     63    // should treat it as if no argument was passed instead, by checking the value of args.at
     64    // rather than looking at args.size.
     65    String src;
     66    if (args.size() > 0)
     67        src = args.at(0).toString(exec);
     68    return asObject(toJS(exec, jsConstructor->globalObject(),
     69        HTMLAudioElement::createForJSConstructor(document, src)));
    6770}
    6871
  • trunk/WebCore/bindings/js/JSImageConstructor.cpp

    r47236 r54999  
    11/*
    22 *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
    3  *  Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     3 *  Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
    44 *
    55 *  This library is free software; you can redistribute it and/or
     
    2525#include "JSHTMLImageElement.h"
    2626#include "JSNode.h"
    27 #include "ScriptExecutionContext.h"
    2827#include <runtime/Error.h>
    2928
     
    4443static JSObject* constructImage(ExecState* exec, JSObject* constructor, const ArgList& args)
    4544{
    46     bool widthSet = false;
    47     bool heightSet = false;
    48     int width = 0;
    49     int height = 0;
    50     if (args.size() > 0) {
    51         widthSet = true;
    52         width = args.at(0).toInt32(exec);
    53     }
    54     if (args.size() > 1) {
    55         heightSet = true;
    56         height = args.at(1).toInt32(exec);
    57     }
    58 
    5945    JSImageConstructor* jsConstructor = static_cast<JSImageConstructor*>(constructor);
    6046    Document* document = jsConstructor->document();
     
    6349
    6450    // Calling toJS on the document causes the JS document wrapper to be
    65     // added to the window object. This is done to ensure that JSDocument::mark
    66     // will be called (which will cause the image element to be marked if necessary).
     51    // added to the window object. This is done to ensure that JSDocument::markChildren
     52    // will be called, which will cause the image element to be marked if necessary.
    6753    toJS(exec, jsConstructor->globalObject(), document);
     54    int width;
     55    int height;
     56    int* optionalWidth = 0;
     57    int* optionalHeight = 0;
     58    if (args.size() > 0) {
     59        width = args.at(0).toInt32(exec);
     60        optionalWidth = &width;
     61    }
     62    if (args.size() > 1) {
     63        height = args.at(1).toInt32(exec);
     64        optionalHeight = &height;
     65    }
    6866
    69     RefPtr<HTMLImageElement> image = new HTMLImageElement(HTMLNames::imgTag, document);
    70     if (widthSet)
    71         image->setWidth(width);
    72     if (heightSet)
    73         image->setHeight(height);
    74     return asObject(toJS(exec, jsConstructor->globalObject(), image.release()));
     67    return asObject(toJS(exec, jsConstructor->globalObject(),
     68        HTMLImageElement::createForJSConstructor(document, optionalWidth, optionalHeight)));
    7569}
    7670
  • trunk/WebCore/bindings/js/JSOptionConstructor.cpp

    r47236 r54999  
    5050        return throwError(exec, ReferenceError, "Option constructor associated document is unavailable");
    5151
    52     RefPtr<HTMLOptionElement> element = static_pointer_cast<HTMLOptionElement>(document->createElement(HTMLNames::optionTag, false));
     52    String data;
     53    if (!args.at(0).isUndefined())
     54        data = args.at(0).toString(exec);
     55
     56    String value;
     57    if (!args.at(1).isUndefined())
     58        value = args.at(1).toString(exec);
     59    bool defaultSelected = args.at(2).toBoolean(exec);
     60    bool selected = args.at(3).toBoolean(exec);
    5361
    5462    ExceptionCode ec = 0;
    55     RefPtr<Text> text = document->createTextNode("");
    56     if (!args.at(0).isUndefined())
    57         text->setData(args.at(0).toString(exec), ec);
    58     if (ec == 0)
    59         element->appendChild(text.release(), ec);
    60     if (ec == 0 && !args.at(1).isUndefined())
    61         element->setValue(args.at(1).toString(exec));
    62     if (ec == 0)
    63         element->setDefaultSelected(args.at(2).toBoolean(exec));
    64     if (ec == 0)
    65         element->setSelected(args.at(3).toBoolean(exec));
    66 
     63    RefPtr<HTMLOptionElement> element = HTMLOptionElement::createForJSConstructor(document, data, value, defaultSelected, selected, ec);
    6764    if (ec) {
    6865        setDOMException(exec, ec);
  • trunk/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp

    r54425 r54999  
    1515 * contributors may be used to endorse or promote products derived from
    1616 * this software without specific prior written permission.
    17  * 
     17 *
    1818 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    6161
    6262    // Make sure the document is added to the DOM Node map. Otherwise, the HTMLAudioElement instance
    63     // may end up being the only node in the map and get garbage-ccollected prematurely.
     63    // may end up being the only node in the map and get garbage-collected prematurely.
    6464    toV8(document);
    6565
    66     RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(HTMLNames::audioTag, document);
    67     audio->setAutobuffer(true);
    68     if (args.Length() > 0) {
    69         audio->setSrc(toWebCoreString(args[0]));
    70         audio->scheduleLoad();
    71     }
     66
     67    String src;
     68    if (args.Length() > 0)
     69        src = toWebCoreString(args[0]);
     70    RefPtr<HTMLAudioElement> audio = HTMLAudioElement::createForJSConstructor(document, src);
    7271
    7372    V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::AUDIO), audio.get());
  • trunk/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp

    r54425 r54999  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
     2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    1515 * contributors may be used to endorse or promote products derived from
    1616 * this software without specific prior written permission.
    17  * 
     17 *
    1818 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    6262    // Make sure the document is added to the DOM Node map. Otherwise, the HTMLImageElement instance
    6363    // may end up being the only node in the map and get garbage-ccollected prematurely.
     64    // FIXME: The correct way to do this would be to make HTMLImageElement derive from
     65    // ActiveDOMObject and use its interface to keep its wrapper alive. Then we would
     66    // remove this code and the special case in isObservableThroughDOM.
    6467    toV8(document);
    6568
    66     RefPtr<HTMLImageElement> image = new HTMLImageElement(HTMLNames::imgTag, document);
     69    int width;
     70    int height;
     71    int* optionalWidth = 0;
     72    int* optionalHeight = 0;
    6773    if (args.Length() > 0) {
    68         image->setWidth(toInt32(args[0]));
    69         if (args.Length() > 1)
    70             image->setHeight(toInt32(args[1]));
     74        width = toInt32(args[0]);
     75        optionalWidth = &width;
     76    }
     77    if (args.Length() > 1) {
     78        height = toInt32(args[1]);
     79        optionalHeight = &height;
    7180    }
    7281
     82    RefPtr<HTMLImageElement> image = HTMLImageElement::createForJSConstructor(document, optionalWidth, optionalHeight);
    7383    V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::IMAGE), image.get());
    7484    image->ref();
  • trunk/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp

    r54425 r54999  
    1515 * contributors may be used to endorse or promote products derived from
    1616 * this software without specific prior written permission.
    17  * 
     17 *
    1818 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    6060        return throwError("Option constructor associated document is unavailable", V8Proxy::ReferenceError);
    6161
    62     RefPtr<HTMLOptionElement> option = new HTMLOptionElement(HTMLNames::optionTag, document);
     62    String data;
     63    String value;
     64    bool defaultSelected = false;
     65    bool selected = false;
     66    if (args.Length() > 0 && !args[0]->IsUndefined())
     67        data = toWebCoreString(args[0]);
     68    if (args.Length() > 1 && !args[1]->IsUndefined())
     69        value = toWebCoreString(args[1]);
     70    if (args.Length() > 2)
     71        defaultSelected = args[2]->BooleanValue();
     72    if (args.Length() > 3)
     73        selected = args[3]->BooleanValue();
    6374
    6475    ExceptionCode ec = 0;
    65     RefPtr<Text> text = document->createTextNode("");
    66     if (args.Length() > 0) {
    67         if (!args[0]->IsUndefined()) {
    68             text->setData(toWebCoreString(args[0]), ec);
    69             if (ec)
    70                 throwError(ec);
    71         }
     76    RefPtr<HTMLOptionElement> option = HTMLOptionElement::createForJSConstructor(document, data, value, defaultSelected, selected, ec);
    7277
    73         option->appendChild(text.release(), ec);
    74         if (ec)
    75             throwError(ec);
    76 
    77         if (args.Length() > 1) {
    78             if (!args[1]->IsUndefined())
    79                 option->setValue(toWebCoreString(args[1]));
    80 
    81             if (args.Length() > 2) {
    82                 option->setDefaultSelected(args[2]->BooleanValue());
    83                 if (args.Length() > 3)
    84                     option->setSelected(args[3]->BooleanValue());
    85             }
    86         }
    87     }
     78    if (ec)
     79        throwError(ec);
    8880
    8981    V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::OPTION), option.get());
  • trunk/WebCore/html/HTMLAudioElement.cpp

    r38881 r54999  
    11/*
    2  * Copyright (C) 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2007, 2010 Apple Inc. All rights reserved.
     3 * Copyright (C) 2010 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2122 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2223 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2425 */
    2526
     
    3536using namespace HTMLNames;
    3637
    37 HTMLAudioElement::HTMLAudioElement(const QualifiedName& tagName, Document* doc)
    38     : HTMLMediaElement(tagName, doc)
     38HTMLAudioElement::HTMLAudioElement(const QualifiedName& tagName, Document* document)
     39    : HTMLMediaElement(tagName, document)
    3940{
    4041    ASSERT(hasTagName(audioTag));
    4142}
    4243
     44PassRefPtr<HTMLAudioElement> HTMLAudioElement::createForJSConstructor(Document* document, const String& src)
     45{
     46    RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(audioTag, document);
     47    audio->setAutobuffer(true);
     48    if (!src.isNull()) {
     49        audio->setSrc(src);
     50        audio->scheduleLoad();
     51    }
     52    return audio.release();
     53}
     54
    4355}
    4456#endif
  • trunk/WebCore/html/HTMLAudioElement.h

    r54849 r54999  
    11/*
    22 * Copyright (C) 2007, 2010 Apple Inc. All rights reserved.
     3 * Copyright (C) 2010 Google Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2122 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2223 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2425 */
    2526
     
    2930#if ENABLE(VIDEO)
    3031
     32#include "Document.h"
    3133#include "HTMLMediaElement.h"
    3234
     
    3537class HTMLAudioElement : public HTMLMediaElement {
    3638public:
     39    static PassRefPtr<HTMLAudioElement> createForJSConstructor(Document*, const String& src);
    3740    HTMLAudioElement(const QualifiedName&, Document*);
    38 
    3941private:
    4042    virtual bool isVideo() const { return false; }
  • trunk/WebCore/html/HTMLImageElement.cpp

    r54242 r54999  
    22 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    33 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    4  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
     5 * Copyright (C) 2010 Google Inc. All rights reserved.
    56 *
    67 * This library is free software; you can redistribute it and/or
     
    5960}
    6061
     62PassRefPtr<HTMLImageElement> HTMLImageElement::createForJSConstructor(Document* document, const int* optionalWidth, const int* optionalHeight)
     63{
     64    RefPtr<HTMLImageElement> image = new HTMLImageElement(imgTag, document);
     65    if (optionalWidth)
     66        image->setWidth(*optionalWidth);
     67    if (optionalHeight > 0)
     68        image->setHeight(*optionalHeight);
     69    return image.release();
     70}
     71
    6172bool HTMLImageElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
    6273{
     
    6980        return false;
    7081    }
    71    
     82
    7283    if (attrName == borderAttr || attrName == alignAttr) {
    7384        result = eReplaced; // Shared with embed and iframe elements.
     
    162173     if (style->contentData())
    163174        return RenderObject::createObject(this, style);
    164      
     175
    165176     return new (arena) RenderImage(this);
    166177}
     
    175186            return;
    176187        imageObj->setCachedImage(m_imageLoader.image());
    177        
     188
    178189        // If we have no image at all because we have no src attribute, set
    179190        // image height and width for the alt text instead.
     
    242253        if (ok)
    243254            return width;
    244        
     255
    245256        // if the image is available, use its width
    246257        if (m_imageLoader.image()) {
     
    266277        if (ok)
    267278            return height;
    268        
     279
    269280        // if the image is available, use its height
    270281        if (m_imageLoader.image()) {
     
    294305    if (!m_imageLoader.image())
    295306        return 0;
    296    
     307
    297308    return m_imageLoader.image()->imageSize(1.0f).height();
    298309}
    299    
     310
    300311bool HTMLImageElement::isURLAttribute(Attribute* attr) const
    301312{
  • trunk/WebCore/html/HTMLImageElement.h

    r53812 r54999  
    22 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    33 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    4  * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
     4 * Copyright (C) 2004, 2008, 2010 Apple Inc. All rights reserved.
     5 * Copyright (C) 2010 Google Inc. All rights reserved.
    56 *
    67 * This library is free software; you can redistribute it and/or
     
    3536    friend class HTMLFormElement;
    3637public:
     38    static PassRefPtr<HTMLImageElement> createForJSConstructor(Document*, const int* optionalWidth, const int* optionalHeight);
     39
    3740    HTMLImageElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
    3841    ~HTMLImageElement();
     
    5457    int naturalWidth() const;
    5558    int naturalHeight() const;
    56    
     59
    5760    bool isServerMap() const { return ismap && usemap.isEmpty(); }
    5861
  • trunk/WebCore/html/HTMLOptionElement.cpp

    r53761 r54999  
    33 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
    65 *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
     6 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
     7 * Copyright (C) 2010 Google Inc. All rights reserved.
    78 *
    89 * This library is free software; you can redistribute it and/or
     
    4243using namespace HTMLNames;
    4344
    44 HTMLOptionElement::HTMLOptionElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* f)
    45     : HTMLFormControlElement(tagName, doc, f)
     45HTMLOptionElement::HTMLOptionElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
     46    : HTMLFormControlElement(tagName, document, form)
    4647    , m_style(0)
    4748{
    4849    ASSERT(hasTagName(optionTag));
     50}
     51
     52PassRefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document* document, const String& data, const String& value,
     53        bool defaultSelected, bool selected, ExceptionCode& ec)
     54{
     55    RefPtr<HTMLOptionElement> element = new HTMLOptionElement(optionTag, document);
     56
     57    RefPtr<Text> text = Text::create(document, data.isNull() ? "" : data);
     58
     59    ec = 0;
     60    element->appendChild(text.release(), ec);
     61    if (ec)
     62        return 0;
     63
     64    if (!value.isNull())
     65        element->setValue(value);
     66    element->setDefaultSelected(defaultSelected);
     67    element->setSelected(selected);
     68
     69    return element.release();
    4970}
    5071
     
    175196    if (!select)
    176197        return 0;
    177    
     198
    178199    return static_cast<HTMLSelectElement*>(select);
    179200}
     
    204225}
    205226
    206 RenderStyle* HTMLOptionElement::nonRendererRenderStyle() const 
    207 { 
    208     return m_style.get(); 
     227RenderStyle* HTMLOptionElement::nonRendererRenderStyle() const
     228{
     229    return m_style.get();
    209230}
    210231
     
    215236
    216237bool HTMLOptionElement::disabled() const
    217 { 
    218     return ownElementDisabled() || (parentNode() && static_cast<HTMLFormControlElement*>(parentNode())->disabled()); 
     238{
     239    return ownElementDisabled() || (parentNode() && static_cast<HTMLFormControlElement*>(parentNode())->disabled());
    219240}
    220241
     
    228249        select->scrollToSelection();
    229250    }
    230    
     251
    231252    HTMLFormControlElement::insertedIntoTree(deep);
    232253}
  • trunk/WebCore/html/HTMLOptionElement.h

    r53512 r54999  
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    55 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
     6 * Copyright (C) 2010 Google Inc. All rights reserved.
    67 *
    78 * This library is free software; you can redistribute it and/or
     
    4041    HTMLOptionElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
    4142
     43    static PassRefPtr<HTMLOptionElement> createForJSConstructor(Document*, const String& data, const String& value,
     44       bool defaultSelected, bool selected, ExceptionCode&);
     45
    4246    virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
    4347    virtual int tagPriority() const { return 2; }
     
    4953    virtual void detach();
    5054    virtual void setRenderStyle(PassRefPtr<RenderStyle>);
    51    
     55
    5256    virtual const AtomicString& formControlType() const;
    5357
     
    7983    bool ownElementDisabled() const { return HTMLFormControlElement::disabled(); }
    8084    virtual bool disabled() const;
    81    
     85
    8286    virtual void insertedIntoTree(bool);
    8387    virtual void accessKeyAction(bool);
    84    
     88
    8589private:
    8690    virtual RenderStyle* nonRendererRenderStyle() const;
Note: See TracChangeset for help on using the changeset viewer.