Changeset 14935 in webkit
- Timestamp:
- Jun 21, 2006, 12:23:06 AM (19 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r14934 r14935 1 2006-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 1 25 2006-06-20 Brady Eidson <beidson@apple.com> 2 26 -
trunk/WebCore/css/html4.css
r14889 r14935 323 323 324 324 textarea { 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; 328 327 border: 1px solid; 329 328 -webkit-rtl-ordering: logical; -
trunk/WebCore/html/HTMLTextAreaElement.cpp
r14931 r14935 80 80 { 81 81 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(); 88 85 } 89 86 return 0; … … 93 90 { 94 91 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(); 101 95 } 102 96 return 0; … … 105 99 void HTMLTextAreaElement::setSelectionStart(int start) 106 100 { 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); 113 103 } 114 104 115 105 void HTMLTextAreaElement::setSelectionEnd(int end) 116 106 { 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); 123 109 } 124 110 125 111 void HTMLTextAreaElement::select() 126 112 { 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(); 133 115 } 134 116 135 117 void HTMLTextAreaElement::setSelectionRange(int start, int end) 136 118 { 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); 143 121 } 144 122 … … 187 165 RenderObject* HTMLTextAreaElement::createRenderer(RenderArena* arena, RenderStyle* style) 188 166 { 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); 192 168 } 193 169 … … 198 174 199 175 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(); 205 177 encoding.appendData(name(), v); 206 178 return true; … … 215 187 { 216 188 // 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(); 220 190 } 221 191 222 192 bool HTMLTextAreaElement::isMouseFocusable() const 223 193 { 224 if (renderer() && renderer()->style()->appearance() == TextAreaAppearance) 225 return HTMLGenericFormElement::isFocusable(); 226 return HTMLGenericFormElement::isMouseFocusable(); 194 return HTMLGenericFormElement::isFocusable(); 227 195 } 228 196 229 197 void HTMLTextAreaElement::focus() 230 198 { 231 if (renderer() && renderer()->style()->appearance() == TextAreaAppearance) {199 if (renderer()) { 232 200 Document* doc = document(); 233 201 if (doc->focusNode() == this) … … 243 211 // If this is the first focus, set a caret at the end of the text. 244 212 // 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(); 250 214 setSelectionRange(max, max); 251 215 } else … … 262 226 void HTMLTextAreaElement::defaultEventHandler(Event *evt) 263 227 { 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)) 265 229 static_cast<RenderTextField*>(renderer())->forwardEvent(evt); 266 230 … … 277 241 if (!valueMatchesRenderer()) { 278 242 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(); 283 244 setValueMatchesRenderer(); 284 245 } … … 306 267 // Restore a caret at the starting point of the old selection. 307 268 // 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) { 309 270 ASSERT(cachedSelEnd >= 0); 310 271 setSelectionRange(cachedSelStart, cachedSelStart);
Note:
See TracChangeset
for help on using the changeset viewer.