[webkit-changes] cvs commit: WebCore/kwq DOM.mm
Timothy
thatcher at opensource.apple.com
Tue Nov 15 16:11:07 PST 2005
thatcher 05/11/15 16:11:06
Modified: . Tag: Safari-1-3-branch ChangeLog
khtml/dom Tag: Safari-1-3-branch dom_element.cpp
dom_element.h
khtml/ecma Tag: Safari-1-3-branch kjs_dom.cpp kjs_dom.h
khtml/html Tag: Safari-1-3-branch html_elementimpl.cpp
khtml/xml Tag: Safari-1-3-branch dom_docimpl.cpp
dom_docimpl.h
kwq Tag: Safari-1-3-branch DOM.mm
Log:
Applied fix for the Safari-1-3-branch
2005-11-14 Adele Peterson <adele at apple.com>
Reviewed by Maciej and Darin.
- fix for <rdar://problem/4233938> calling focus on contentEditable block elements should scroll them into view
- fix for <rdar://problem/3624946> No 'blur' method defined on editable non-form DOM objects
Added
* fast/dom/focus-contenteditable.html
* fast/dom/blur-contenteditable.html
* khtml/ecma/kjs_dom.cpp: Added ElementFocus and ElementBlur to DOMElementProtoTable
(KJS::DOMElementProtoFunc::callAsFunction): Added cases for ElementFocus and ElementBlur
* khtml/ecma/kjs_dom.h: (KJS::DOMElement::): Added ElementFocus and ElementBlur to enum
* khtml/html/html_elementimpl.cpp:
(HTMLElementImpl::parseMappedAttribute): Added case for onblur.
* khtml/xml/dom_elementimpl.cpp:
(ElementImpl::focus): If the element isFocusable, calls setFocusNode to give element focus.
(ElementImpl::blur): If the element is focused, calls setFocusNode to take away focus.
* khtml/xml/dom_elementimpl.h: Added focus and blur functions
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::setFocusNode): If we're trying to take focus away from a node, then we should clear the selection before we fire events.
If we don't, then efforts to focus the cursor during the event can reset focus on the old node.
(DocumentImpl::clearSelectionIfNeeded): Added function since we need to clear the selection at multiple points.
* khtml/xml/dom_docimpl.h: Added clearSelectionIfNeeded.
* kwq/DOMExtensions.h: Added Obj-C bindings for focus and blur.
* kwq/DOM.mm:
(-[DOMElement focus]):
(-[DOMElement blur]):
Revision Changes Path
No revision
No revision
1.335.2.21 +34 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.335.2.20
retrieving revision 1.335.2.21
diff -u -r1.335.2.20 -r1.335.2.21
--- ChangeLog 14 Nov 2005 23:04:53 -0000 1.335.2.20
+++ ChangeLog 16 Nov 2005 00:10:55 -0000 1.335.2.21
@@ -1,3 +1,37 @@
+2005-11-15 Timothy Hatcher <timothy at apple.com>
+
+ Applied fix for the Safari-1-3-branch
+
+ 2005-11-14 Adele Peterson <adele at apple.com>
+
+ Reviewed by Maciej and Darin.
+
+ - fix for <rdar://problem/4233938> calling focus on contentEditable block elements should scroll them into view
+ - fix for <rdar://problem/3624946> No 'blur' method defined on editable non-form DOM objects
+
+ Added
+ * fast/dom/focus-contenteditable.html
+ * fast/dom/blur-contenteditable.html
+
+ * khtml/ecma/kjs_dom.cpp: Added ElementFocus and ElementBlur to DOMElementProtoTable
+ (KJS::DOMElementProtoFunc::callAsFunction): Added cases for ElementFocus and ElementBlur
+ * khtml/ecma/kjs_dom.h: (KJS::DOMElement::): Added ElementFocus and ElementBlur to enum
+ * khtml/html/html_elementimpl.cpp:
+ (HTMLElementImpl::parseMappedAttribute): Added case for onblur.
+ * khtml/xml/dom_elementimpl.cpp:
+ (ElementImpl::focus): If the element isFocusable, calls setFocusNode to give element focus.
+ (ElementImpl::blur): If the element is focused, calls setFocusNode to take away focus.
+ * khtml/xml/dom_elementimpl.h: Added focus and blur functions
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::setFocusNode): If we're trying to take focus away from a node, then we should clear the selection before we fire events.
+ If we don't, then efforts to focus the cursor during the event can reset focus on the old node.
+ (DocumentImpl::clearSelectionIfNeeded): Added function since we need to clear the selection at multiple points.
+ * khtml/xml/dom_docimpl.h: Added clearSelectionIfNeeded.
+ * kwq/DOMExtensions.h: Added Obj-C bindings for focus and blur.
+ * kwq/DOM.mm:
+ (-[DOMElement focus]):
+ (-[DOMElement blur]):
+
2005-11-14 Timothy Hatcher <timothy at apple.com>
Applied fix for the Safari-1-3-branch
No revision
No revision
1.9.16.1 +16 -0 WebCore/khtml/dom/Attic/dom_element.cpp
Index: dom_element.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/dom/Attic/dom_element.cpp,v
retrieving revision 1.9
retrieving revision 1.9.16.1
diff -u -r1.9 -r1.9.16.1
--- dom_element.cpp 10 Feb 2004 20:52:11 -0000 1.9
+++ dom_element.cpp 16 Nov 2005 00:10:59 -0000 1.9.16.1
@@ -294,6 +294,22 @@
return ((ElementImpl *)impl)->isHTMLElement();
}
+void Element::focus()
+{
+ if(!impl) return;
+ DocumentImpl* doc = impl->getDocument();
+ if (doc && impl->isFocusable())
+ doc->setFocusNode(impl);
+}
+
+void Element::blur()
+{
+ if(!impl) return;
+ DocumentImpl* doc = impl->getDocument();
+ if (doc && doc->focusNode() == impl)
+ doc->setFocusNode(0);
+}
+
// FIXME: This should move down to HTMLElement.
CSSStyleDeclaration Element::style()
{
1.6.78.1 +3 -0 WebCore/khtml/dom/Attic/dom_element.h
Index: dom_element.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/dom/Attic/dom_element.h,v
retrieving revision 1.6
retrieving revision 1.6.78.1
diff -u -r1.6 -r1.6.78.1
--- dom_element.h 26 Oct 2002 23:21:42 -0000 1.6
+++ dom_element.h 16 Nov 2005 00:10:59 -0000 1.6.78.1
@@ -547,6 +547,9 @@
* not part of the DOM
*/
bool isHTMLElement() const;
+
+ void focus();
+ void blur();
static bool khtmlValidAttrName(const DOMString &name);
static bool khtmlValidPrefix(const DOMString &name);
No revision
No revision
1.66.4.3 +8 -0 WebCore/khtml/ecma/kjs_dom.cpp
Index: kjs_dom.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_dom.cpp,v
retrieving revision 1.66.4.2
retrieving revision 1.66.4.3
diff -u -r1.66.4.2 -r1.66.4.3
--- kjs_dom.cpp 13 Jul 2005 05:17:59 -0000 1.66.4.2
+++ kjs_dom.cpp 16 Nov 2005 00:11:00 -0000 1.66.4.3
@@ -1037,6 +1037,8 @@
setAttributeNodeNS DOMElement::SetAttributeNodeNS DontDelete|Function 1
getElementsByTagNameNS DOMElement::GetElementsByTagNameNS DontDelete|Function 2
hasAttributeNS DOMElement::HasAttributeNS DontDelete|Function 2
+ focus DOMElement::ElementFocus DontDelete|Function 0
+ blur DOMElement::ElementBlur DontDelete|Function 0
# extension for Safari RSS
scrollByLines DOMElement::ScrollByLines DontDelete|Function 1
scrollByPages DOMElement::ScrollByPages DontDelete|Function 1
@@ -1167,6 +1169,12 @@
return Undefined();
}
+ case DOMElement::ElementFocus:
+ element.focus();
+ return Undefined();
+ case DOMElement::ElementBlur:
+ element.blur();
+ return Undefined();
default:
return Undefined();
}
1.34.4.3 +1 -1 WebCore/khtml/ecma/kjs_dom.h
Index: kjs_dom.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_dom.h,v
retrieving revision 1.34.4.2
retrieving revision 1.34.4.3
diff -u -r1.34.4.2 -r1.34.4.3
--- kjs_dom.h 13 Jul 2005 05:17:59 -0000 1.34.4.2
+++ kjs_dom.h 16 Nov 2005 00:11:01 -0000 1.34.4.3
@@ -158,7 +158,7 @@
SetAttributeNode, RemoveAttributeNode, GetElementsByTagName,
GetAttributeNS, SetAttributeNS, RemoveAttributeNS, GetAttributeNodeNS,
SetAttributeNodeNS, GetElementsByTagNameNS, HasAttribute, HasAttributeNS,
- ScrollByLines, ScrollByPages};
+ ScrollByLines, ScrollByPages, ElementFocus, ElementBlur};
};
class DOMDOMImplementation : public DOMObject {
No revision
No revision
1.76.6.4 +4 -0 WebCore/khtml/html/html_elementimpl.cpp
Index: html_elementimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_elementimpl.cpp,v
retrieving revision 1.76.6.3
retrieving revision 1.76.6.4
diff -u -r1.76.6.3 -r1.76.6.4
--- html_elementimpl.cpp 12 Jul 2005 21:18:09 -0000 1.76.6.3
+++ html_elementimpl.cpp 16 Nov 2005 00:11:02 -0000 1.76.6.4
@@ -477,6 +477,10 @@
setHTMLEventListener(EventImpl::DOMFOCUSIN_EVENT,
getDocument()->createHTMLEventListener(attr->value().string(), this));
break;
+ case ATTR_ONBLUR:
+ setHTMLEventListener(EventImpl::DOMFOCUSOUT_EVENT,
+ getDocument()->createHTMLEventListener(attr->value().string(), this));
+ break;
case ATTR_ONKEYDOWN:
setHTMLEventListener(EventImpl::KEYDOWN_EVENT,
getDocument()->createHTMLEventListener(attr->value().string(), this));
No revision
No revision
1.211.4.10 +21 -9 WebCore/khtml/xml/dom_docimpl.cpp
Index: dom_docimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.cpp,v
retrieving revision 1.211.4.9
retrieving revision 1.211.4.10
diff -u -r1.211.4.9 -r1.211.4.10
--- dom_docimpl.cpp 14 Nov 2005 23:04:58 -0000 1.211.4.9
+++ dom_docimpl.cpp 16 Nov 2005 00:11:03 -0000 1.211.4.10
@@ -2568,6 +2568,7 @@
bool focusChangeBlocked = false;
NodeImpl *oldFocusNode = m_focusNode;
m_focusNode = 0;
+ clearSelectionIfNeeded(newFocusNode);
// Remove focus from the existing focus node (if any)
if (oldFocusNode) {
@@ -2586,12 +2587,14 @@
focusChangeBlocked = true;
newFocusNode = 0;
}
+ clearSelectionIfNeeded(newFocusNode);
oldFocusNode->dispatchUIEvent(EventImpl::DOMFOCUSOUT_EVENT);
if (m_focusNode != 0) {
// handler shifted focus
focusChangeBlocked = true;
newFocusNode = 0;
}
+ clearSelectionIfNeeded(newFocusNode);
if ((oldFocusNode == this) && oldFocusNode->hasOneRef()) {
oldFocusNode->deref(); // deletes this
return true;
@@ -2601,14 +2604,6 @@
}
}
- // Clear the selection when changing the focus node to null or to a node that is not
- // contained by the current selection.
- if (part()) {
- NodeImpl *startContainer = part()->selection().start().node();
- if (!newFocusNode || (startContainer && startContainer != newFocusNode && !startContainer->isAncestor(newFocusNode)))
- part()->clearSelection();
- }
-
if (newFocusNode) {
#if APPLE_CHANGES
if (newFocusNode->isContentEditable() && !acceptsEditingFocus(newFocusNode)) {
@@ -2647,8 +2642,13 @@
}
if (focusWidget)
focusWidget->setFocus();
- else
+ else {
view()->setFocus();
+ if (m_focusNode->renderer()) {
+ updateLayout();
+ m_focusNode->renderer()->enclosingLayer()->scrollRectToVisible(m_focusNode->getRect());
+ }
+ }
}
}
@@ -2662,6 +2662,18 @@
return !focusChangeBlocked;
}
+void DocumentImpl::clearSelectionIfNeeded(NodeImpl *newFocusNode)
+{
+ if (!part())
+ return;
+
+ // Clear the selection when changing the focus node to null or to a node that is not
+ // contained by the current selection.
+ NodeImpl *startContainer = part()->selection().start().node();
+ if (!newFocusNode || (startContainer && startContainer != newFocusNode && !startContainer->isAncestor(newFocusNode)))
+ part()->clearSelection();
+}
+
void DocumentImpl::setCSSTarget(NodeImpl* n)
{
if (m_cssTarget)
1.104.4.7 +1 -0 WebCore/khtml/xml/dom_docimpl.h
Index: dom_docimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.h,v
retrieving revision 1.104.4.6
retrieving revision 1.104.4.7
diff -u -r1.104.4.6 -r1.104.4.7
--- dom_docimpl.h 14 Nov 2005 23:04:58 -0000 1.104.4.6
+++ dom_docimpl.h 16 Nov 2005 00:11:04 -0000 1.104.4.7
@@ -423,6 +423,7 @@
NodeImpl *focusNode() const { return m_focusNode; }
bool setFocusNode(NodeImpl *newFocusNode);
+ void clearSelectionIfNeeded(NodeImpl *newFocusNode);
NodeImpl *hoverNode() const { return m_hoverNode; }
void setHoverNode(NodeImpl *newHoverNode);
No revision
No revision
1.32.6.1 +16 -0 WebCore/kwq/DOM.mm
Index: DOM.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/DOM.mm,v
retrieving revision 1.32
retrieving revision 1.32.6.1
diff -u -r1.32 -r1.32.6.1
--- DOM.mm 17 Feb 2005 00:14:29 -0000 1.32
+++ DOM.mm 16 Nov 2005 00:11:05 -0000 1.32.6.1
@@ -1548,6 +1548,22 @@
@end
+ at implementation DOMElement (DOMElementExtensions)
+
+- (void)focus
+{
+ Element element(ElementImpl::createInstance([self _elementImpl]));
+ element.focus();
+}
+
+- (void)blur
+{
+ Element element(ElementImpl::createInstance([self _elementImpl]));
+ element.blur();
+}
+
+ at end
+
@implementation DOMElement (WebCoreInternal)
+ (DOMElement *)_elementWithImpl:(ElementImpl *)impl
More information about the webkit-changes
mailing list