Changeset 14935 in webkit


Ignore:
Timestamp:
Jun 21, 2006 12:23:06 AM (18 years ago)
Author:
adele
Message:

Reviewed by Anders.

Fix for: http://bugzilla.opendarwin.org/show_bug.cgi?id=8948
Switch to use new text field implementation for <textarea>

  • css/html4.css:
  • html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::selectionStart): (WebCore::HTMLTextAreaElement::selectionEnd): (WebCore::HTMLTextAreaElement::setSelectionStart): (WebCore::HTMLTextAreaElement::setSelectionEnd): (WebCore::HTMLTextAreaElement::select): (WebCore::HTMLTextAreaElement::setSelectionRange): (WebCore::HTMLTextAreaElement::createRenderer): (WebCore::HTMLTextAreaElement::appendFormData): (WebCore::HTMLTextAreaElement::isKeyboardFocusable): (WebCore::HTMLTextAreaElement::isMouseFocusable): (WebCore::HTMLTextAreaElement::focus): (WebCore::HTMLTextAreaElement::defaultEventHandler): (WebCore::HTMLTextAreaElement::updateValue): (WebCore::HTMLTextAreaElement::setValue):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r14934 r14935  
     12006-06-20  Adele Peterson  <adele@apple.com>
     2
     3        Reviewed by Anders.
     4
     5        Fix for: http://bugzilla.opendarwin.org/show_bug.cgi?id=8948
     6        Switch to use new text field implementation for <textarea>
     7
     8        * css/html4.css:
     9        * html/HTMLTextAreaElement.cpp:
     10        (WebCore::HTMLTextAreaElement::selectionStart):
     11        (WebCore::HTMLTextAreaElement::selectionEnd):
     12        (WebCore::HTMLTextAreaElement::setSelectionStart):
     13        (WebCore::HTMLTextAreaElement::setSelectionEnd):
     14        (WebCore::HTMLTextAreaElement::select):
     15        (WebCore::HTMLTextAreaElement::setSelectionRange):
     16        (WebCore::HTMLTextAreaElement::createRenderer):
     17        (WebCore::HTMLTextAreaElement::appendFormData):
     18        (WebCore::HTMLTextAreaElement::isKeyboardFocusable):
     19        (WebCore::HTMLTextAreaElement::isMouseFocusable):
     20        (WebCore::HTMLTextAreaElement::focus):
     21        (WebCore::HTMLTextAreaElement::defaultEventHandler):
     22        (WebCore::HTMLTextAreaElement::updateValue):
     23        (WebCore::HTMLTextAreaElement::setValue):
     24
    1252006-06-20  Brady Eidson  <beidson@apple.com>
    226
  • trunk/WebCore/css/html4.css

    r14889 r14935  
    323323
    324324textarea {
    325 //  FIXME: Uncomment these when we flip the switch for the new textarea implementation
    326 //  -webkit-appearance: textarea;
    327 //   background-color: white;
     325    -webkit-appearance: textarea;
     326    background-color: white;
    328327    border: 1px solid;
    329328    -webkit-rtl-ordering: logical;
  • trunk/WebCore/html/HTMLTextAreaElement.cpp

    r14931 r14935  
    8080{
    8181    if (renderer()) {
    82         if (renderer()->style()->appearance() == TextAreaAppearance) {
    83             if (document()->focusNode() != this && cachedSelStart >= 0)
    84                 return cachedSelStart;
    85             return static_cast<RenderTextField *>(renderer())->selectionStart();
    86         }
    87         return static_cast<RenderTextArea*>(renderer())->selectionStart();
     82        if (document()->focusNode() != this && cachedSelStart >= 0)
     83            return cachedSelStart;
     84        return static_cast<RenderTextField *>(renderer())->selectionStart();
    8885    }
    8986    return 0;
     
    9390{
    9491    if (renderer()) {
    95         if (renderer()->style()->appearance() == TextAreaAppearance) {
    96             if (document()->focusNode() != this && cachedSelEnd >= 0)
    97                 return cachedSelEnd;
    98             return static_cast<RenderTextField *>(renderer())->selectionEnd();
    99         }
    100         return static_cast<RenderTextArea*>(renderer())->selectionEnd();
     92        if (document()->focusNode() != this && cachedSelEnd >= 0)
     93            return cachedSelEnd;
     94        return static_cast<RenderTextField *>(renderer())->selectionEnd();
    10195    }
    10296    return 0;
     
    10599void HTMLTextAreaElement::setSelectionStart(int start)
    106100{
    107     if (renderer()) {
    108         if (renderer()->style()->appearance() == TextAreaAppearance)
    109             static_cast<RenderTextField*>(renderer())->setSelectionStart(start);
    110         else
    111             static_cast<RenderTextArea*>(renderer())->setSelectionStart(start);
    112     }
     101    if (renderer())
     102        static_cast<RenderTextField*>(renderer())->setSelectionStart(start);
    113103}
    114104
    115105void HTMLTextAreaElement::setSelectionEnd(int end)
    116106{
    117     if (renderer()) {
    118         if (renderer()->style()->appearance() == TextAreaAppearance)
    119             static_cast<RenderTextField*>(renderer())->setSelectionEnd(end);
    120         else
    121             static_cast<RenderTextArea*>(renderer())->setSelectionEnd(end);
    122     }
     107    if (renderer())
     108        static_cast<RenderTextField*>(renderer())->setSelectionEnd(end);
    123109}
    124110
    125111void HTMLTextAreaElement::select()
    126112{
    127     if (renderer()) {
    128         if (renderer()->style()->appearance() == TextAreaAppearance)
    129             static_cast<RenderTextField *>(renderer())->select();
    130         else
    131             static_cast<RenderTextArea *>(renderer())->select();
    132     }
     113    if (renderer())
     114        static_cast<RenderTextField *>(renderer())->select();
    133115}
    134116
    135117void HTMLTextAreaElement::setSelectionRange(int start, int end)
    136118{
    137     if (renderer()) {
    138         if (renderer()->style()->appearance() == TextAreaAppearance)
    139             static_cast<RenderTextField*>(renderer())->setSelectionRange(start, end);
    140         else
    141             static_cast<RenderTextArea*>(renderer())->setSelectionRange(start, end);   
    142     }
     119    if (renderer())
     120        static_cast<RenderTextField*>(renderer())->setSelectionRange(start, end);
    143121}
    144122
     
    187165RenderObject* HTMLTextAreaElement::createRenderer(RenderArena* arena, RenderStyle* style)
    188166{
    189     if (style->appearance() == TextAreaAppearance)
    190         return new (arena) RenderTextField(this, true);
    191     return new (arena) RenderTextArea(this);
     167    return new (arena) RenderTextField(this, true);
    192168}
    193169
     
    198174       
    199175    bool hardWrap = renderer() && wrap() == ta_Physical;
    200     String v;
    201     if (renderer() && renderer()->style()->appearance() == TextAreaAppearance)
    202         v = hardWrap ? static_cast<RenderTextField*>(renderer())->textWithHardLineBreaks() : value();
    203     else
    204         v = hardWrap ? static_cast<RenderTextArea*>(renderer())->textWithHardLineBreaks() : value();
     176    String v = hardWrap ? static_cast<RenderTextField*>(renderer())->textWithHardLineBreaks() : value();
    205177    encoding.appendData(name(), v);
    206178    return true;
     
    215187{
    216188    // If text areas can be focused, then they should always be keyboard focusable
    217     if (renderer() && renderer()->style()->appearance() == TextAreaAppearance)
    218         return HTMLGenericFormElement::isFocusable();
    219     return HTMLGenericFormElement::isKeyboardFocusable();
     189    return HTMLGenericFormElement::isFocusable();
    220190}
    221191
    222192bool HTMLTextAreaElement::isMouseFocusable() const
    223193{
    224     if (renderer() && renderer()->style()->appearance() == TextAreaAppearance)
    225         return HTMLGenericFormElement::isFocusable();
    226     return HTMLGenericFormElement::isMouseFocusable();
     194    return HTMLGenericFormElement::isFocusable();
    227195}
    228196
    229197void HTMLTextAreaElement::focus()
    230198{
    231     if (renderer() && renderer()->style()->appearance() == TextAreaAppearance) {
     199    if (renderer()) {
    232200        Document* doc = document();
    233201        if (doc->focusNode() == this)
     
    243211            // If this is the first focus, set a caret at the end of the text. 
    244212            // This matches other browsers' behavior.
    245             int max;
    246             if (renderer()->style()->appearance() == TextAreaAppearance)
    247                 max = static_cast<RenderTextField*>(renderer())->text().length();
    248             else
    249                 max = static_cast<RenderTextArea*>(renderer())->text().length();
     213            int max = static_cast<RenderTextField*>(renderer())->text().length();
    250214            setSelectionRange(max, max);
    251215        } else
     
    262226void HTMLTextAreaElement::defaultEventHandler(Event *evt)
    263227{
    264     if (renderer() && renderer()->style()->appearance() == TextAreaAppearance && (evt->isMouseEvent() || evt->isDragEvent() || evt->isWheelEvent() || evt->type() == blurEvent))
     228    if (renderer() && (evt->isMouseEvent() || evt->isDragEvent() || evt->isWheelEvent() || evt->type() == blurEvent))
    265229        static_cast<RenderTextField*>(renderer())->forwardEvent(evt);
    266230
     
    277241    if (!valueMatchesRenderer()) {
    278242        ASSERT(renderer());
    279         if (renderer()->style()->appearance() == TextAreaAppearance)
    280             m_value = static_cast<RenderTextField*>(renderer())->text();
    281         else
    282             m_value = static_cast<RenderTextArea*>(renderer())->text();
     243        m_value = static_cast<RenderTextField*>(renderer())->text();
    283244        setValueMatchesRenderer();
    284245    }
     
    306267    // Restore a caret at the starting point of the old selection.
    307268    // This matches Safari 2.0 behavior.
    308     if (document()->focusNode() == this && cachedSelStart >= 0 && renderer() && renderer()->style()->appearance() == TextAreaAppearance) {
     269    if (document()->focusNode() == this && cachedSelStart >= 0) {
    309270        ASSERT(cachedSelEnd >= 0);
    310271        setSelectionRange(cachedSelStart, cachedSelStart);
Note: See TracChangeset for help on using the changeset viewer.