Changeset 12345 in webkit
- Timestamp:
- Jan 24, 2006, 11:35:27 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r12344 r12345 1 2006-01-24 Adele Peterson <adele@apple.com> 2 3 Test for focus and blur for new text fields. 4 5 * fast/forms/input-appearance-focus.html: Added. 6 * fast/forms/input-appearance-focus-expected.txt: Added. 7 * fast/forms/input-appearance-focus-expected.png: Added. 8 * fast/forms/input-appearance-focus-expected.checksum: Added. 9 1 10 2006-01-24 Darin Adler <darin@apple.com> 2 11 -
trunk/WebCore/ChangeLog
r12343 r12345 1 2006-01-24 Adele Peterson <adele@apple.com> 2 3 Reviewed by Hyatt. 4 5 This change will allow the new text field elements to get focus, and to respond to the focus and blur events. 6 7 Added: fast/forms/input-appearance-focus.html 8 9 * khtml/html/HTMLElementImpl.cpp: (WebCore::HTMLElementImpl::isFocusable): 10 Removed recently added code that allowed editable elements with no parent to be focusable. 11 We don't need to do this now that we try to focus the input element, instead of the inner div. 12 * khtml/html/HTMLGenericFormElementImpl.cpp: (WebCore::HTMLGenericFormElementImpl::isMouseFocusable): Added case to for text fields. 13 * khtml/html/HTMLInputElementImpl.cpp: 14 (WebCore::HTMLInputElementImpl::focus): Added. Selects contents of text field. 15 (WebCore::HTMLInputElementImpl::setSelectionStart): Added break; in switch statement. 16 (WebCore::HTMLInputElementImpl::setSelectionEnd): ditto. 17 (WebCore::HTMLInputElementImpl::select): ditto. 18 (WebCore::HTMLInputElementImpl::setSelectionRange): ditto. 19 * khtml/html/HTMLInputElementImpl.h: Added focus() 20 * khtml/xml/dom_elementimpl.h: Made focus() virtual. 21 * page/Frame.cpp: (Frame::setFocusNodeIfNeeded): 22 Walk up the Render Tree instead of the DOM tree when trying to find a node to focus. 23 This will let us choose the input node instead of one of the nodes in the shadow tree. 24 * page/FrameView.cpp: (FrameView::dispatchMouseEvent): ditto. 25 * rendering/RenderContainer.cpp: (WebCore::RenderContainer::destroyLeftoverChildren): Corrected misspelling. 26 * rendering/RenderTextField.cpp: 27 (WebCore::RenderTextField::select): Implemented. Select contents of inner div. 28 * rendering/RenderTextField.h: 29 (WebCore::RenderTextField::renderName): Changed order. 30 (WebCore::RenderTextField::removeLeftoverAnonymousBoxes): ditto. 31 1 32 2006-01-24 Darin Adler <darin@apple.com> 2 33 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r12341 r12345 1246 1246 93E62D980985F41600E1B5E3 /* SystemTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SystemTime.cpp; path = platform/mac/SystemTime.cpp; sourceTree = "<group>"; }; 1247 1247 93E62D990985F41600E1B5E3 /* SystemTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SystemTime.h; path = platform/SystemTime.h; sourceTree = "<group>"; }; 1248 93ECDB7E03ABE65B008635CE /* KWQColorData.gperf */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = text; path = KWQColorData.gperf; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };1249 1248 93F19B1908245E59001E9ABC /* Info.plist */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 1250 1249 93F19B1A08245E5A001E9ABC /* WebCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; -
trunk/WebCore/khtml/html/HTMLElementImpl.cpp
r12329 r12345 451 451 bool HTMLElementImpl::isFocusable() const 452 452 { 453 // Added the check for !parent() so shadow elements, like those in engine-based textfields, can get focus. 454 // We may reevaluate this when we resolve outstanding focus issues with these shadow elements. 455 return isContentEditable() && ((parent() && !parent()->isContentEditable()) || !parent()); 453 return isContentEditable() && parent() && !parent()->isContentEditable(); 456 454 } 457 455 -
trunk/WebCore/khtml/html/HTMLGenericFormElementImpl.cpp
r12330 r12345 218 218 { 219 219 if (isFocusable()) { 220 if (renderer()->isWidget()) { 220 if (renderer()->style()->appearance() == TextFieldAppearance) 221 return true; 222 else if (renderer()->isWidget()) { 221 223 return static_cast<RenderWidget*>(renderer())->widget() && 222 224 (static_cast<RenderWidget*>(renderer())->widget()->focusPolicy() & QWidget::ClickFocus); 223 } 225 } 224 226 // For <input type=image> and <button>, we will assume no mouse focusability. This is 225 227 // consistent with OS X behavior for buttons. -
trunk/WebCore/khtml/html/HTMLInputElementImpl.cpp
r12330 r12345 33 33 34 34 #include "cssproperties.h" 35 #include "Frame.h" 35 36 #include "render_form.h" 36 37 #include "render_button.h" … … 126 127 127 128 return true; 129 } 130 131 void HTMLInputElementImpl::focus() 132 { 133 if ((m_type == TEXT) || (m_type == PASSWORD) && renderer()->style()->appearance() == TextFieldAppearance) { 134 DocumentImpl* doc = getDocument(); 135 if (doc) { 136 doc->updateLayout(); 137 if (isFocusable()) { 138 doc->setFocusNode(this); 139 select(); 140 doc->frame()->revealSelection(); 141 } 142 } 143 } else 144 HTMLGenericFormElementImpl::focus(); 145 128 146 } 129 147 … … 324 342 case PASSWORD: 325 343 case TEXT: 326 if (renderer()->style()->appearance() == TextFieldAppearance) 344 if (renderer()->style()->appearance() == TextFieldAppearance) { 327 345 static_cast<RenderTextField *>(renderer())->setSelectionStart(start); 346 break; 347 } 328 348 // Fall through for text fields that don't specify appearance 329 349 case SEARCH: … … 343 363 case PASSWORD: 344 364 case TEXT: 345 if (renderer()->style()->appearance() == TextFieldAppearance) 365 if (renderer()->style()->appearance() == TextFieldAppearance) { 346 366 static_cast<RenderTextField *>(renderer())->setSelectionEnd(end); 367 break; 368 } 347 369 // Fall through for text fields that don't specify appearance 348 370 case SEARCH: … … 365 387 case PASSWORD: 366 388 case TEXT: 367 if (renderer()->style()->appearance() == TextFieldAppearance) 389 if (renderer()->style()->appearance() == TextFieldAppearance) { 368 390 static_cast<RenderTextField *>(renderer())->select(); 391 break; 392 } 369 393 // Fall through for text fields that don't specify appearance 370 394 case SEARCH: … … 392 416 case PASSWORD: 393 417 case TEXT: 394 if (renderer()->style()->appearance() == TextFieldAppearance) 418 if (renderer()->style()->appearance() == TextFieldAppearance) { 395 419 static_cast<RenderTextField *>(renderer())->setSelectionRange(start, end); 420 break; 421 } 396 422 // Fall through for text fields that don't specify appearance 397 423 case SEARCH: -
trunk/WebCore/khtml/html/HTMLInputElementImpl.h
r12330 r12345 75 75 virtual bool isKeyboardFocusable() const; 76 76 virtual bool isEnumeratable() const { return inputType() != IMAGE; } 77 virtual void focus(); 77 78 78 79 virtual const AtomicString& name() const; -
trunk/WebCore/khtml/xml/dom_elementimpl.h
r12313 r12345 264 264 virtual bool isURLAttribute(AttributeImpl *attr) const; 265 265 266 v oid focus();266 virtual void focus(); 267 267 void blur(); 268 268 -
trunk/WebCore/page/Frame.cpp
r12341 r12345 1448 1448 1449 1449 if (target) { 1450 for ( ; target; target = target->parentNode()) { 1450 RenderObject* renderer = target->renderer(); 1451 1452 // Walk up the render tree to search for a node to focus. 1453 // Walking up the DOM tree wouldn't work for shadow trees, like those behind the engine-based text fields. 1454 while (renderer) { 1451 1455 // We don't want to set focus on a subframe when selecting in a parent frame, 1452 1456 // so add the !isFrameElement check here. There's probably a better way to make this 1453 1457 // work in the long term, but this is the safest fix at this time. 1454 if (target ->isMouseFocusable() && !::isFrameElement(target)) {1458 if (target && target->isMouseFocusable() && !::isFrameElement(target)) { 1455 1459 document()->setFocusNode(target); 1456 1460 return; 1457 1461 } 1462 renderer = renderer->parent(); 1463 if (renderer) 1464 target = renderer->element(); 1458 1465 } 1459 1466 document()->setFocusNode(0); -
trunk/WebCore/page/FrameView.cpp
r12268 r12345 1087 1087 // from form fields before the button click is processed. 1088 1088 NodeImpl* node = targetNode; 1089 for ( ; node && !node->isFocusable(); node = node->parentNode()); 1089 RenderObject* renderer = node->renderer(); 1090 1091 // Walk up the render tree to search for a node to focus. 1092 // Walking up the DOM tree wouldn't work for shadow trees, like those behind the engine-based text fields. 1093 while (renderer) { 1094 node = renderer->element(); 1095 if (node && node->isFocusable()) 1096 break; 1097 renderer = renderer->parent(); 1098 } 1090 1099 // If focus shift is blocked, we eat the event. Note we should never clear swallowEvent 1091 1100 // if the page already set it (e.g., by canceling default behavior). -
trunk/WebCore/rendering/RenderContainer.cpp
r12263 r12345 66 66 m_first->remove(); // List markers are owned by their enclosing list and so don't get destroyed by this container. 67 67 else { 68 // Destroy any anonymous children remaining in the render tree, as well as implicit (shadow) DOM elements like those used in the engine-based text fields.68 // Destroy any anonymous children remaining in the render tree, as well as implicit (shadow) DOM elements like those used in the engine-based text fields. 69 69 if (m_first->element()) 70 70 m_first->element()->setRenderer(0); -
trunk/WebCore/rendering/RenderTextField.cpp
r12236 r12345 20 20 21 21 #include "config.h" 22 #include "RenderTextField.h" 23 22 24 #include "DocumentImpl.h" 23 #include " RenderTextField.h"25 #include "Frame.h" 24 26 #include "RenderText.h" 25 27 #include "htmlnames.h" 26 28 #include "HTMLInputElementImpl.h" 27 29 28 using namespace DOM; 30 namespace WebCore { 31 29 32 using namespace HTMLNames; 30 31 namespace WebCore {32 33 33 34 RenderTextField::RenderTextField(NodeImpl* node) … … 148 149 void RenderTextField::select() 149 150 { 150 // FIXME: Implement this. 151 DocumentImpl* doc = document(); 152 if (doc && m_div) 153 doc->frame()->selectContentsOfNode(m_div.get()); 151 154 } 152 155 -
trunk/WebCore/rendering/RenderTextField.h
r12236 r12345 30 30 { 31 31 public: 32 RenderTextField( DOM::NodeImpl* node);32 RenderTextField(NodeImpl* node); 33 33 virtual ~RenderTextField(); 34 34 35 virtual const char *renderName() const { return "RenderTextField"; } 35 36 virtual void removeLeftoverAnonymousBoxes() {}; 37 virtual void setStyle(RenderStyle* style); 38 virtual void updateFromElement(); 39 40 RenderStyle* createDivStyle(RenderStyle* startStyle); 36 41 37 virtual void setStyle(RenderStyle* style);38 RenderStyle* createDivStyle(RenderStyle* startStyle);39 virtual void updateFromElement();40 41 virtual const char *renderName() const { return "RenderTextField"; }42 43 42 int selectionStart(); 44 43 int selectionEnd(); 45 44 void setSelectionStart(int); 46 void setSelectionEnd(int); 47 45 void setSelectionEnd(int); 48 46 void select(); 49 47 void setSelectionRange(int, int);
Note:
See TracChangeset
for help on using the changeset viewer.