[webkit-changes] cvs commit: WebCore/kwq DOM.mm DOMExtensions.h

Adele adele at opensource.apple.com
Mon Nov 14 23:31:07 PST 2005


adele       05/11/14 23:31:07

  Modified:    .        Tag: Safari-2-0-branch ChangeLog
               khtml/dom Tag: Safari-2-0-branch dom_element.cpp
                        dom_element.h
               khtml/ecma Tag: Safari-2-0-branch kjs_dom.cpp kjs_dom.h
               khtml/html Tag: Safari-2-0-branch html_elementimpl.cpp
               khtml/xml Tag: Safari-2-0-branch dom_docimpl.cpp
                        dom_docimpl.h
               kwq      Tag: Safari-2-0-branch DOM.mm DOMExtensions.h
  Log:
          Merged fix from TOT to Safari-2-0-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.1.2.63  +34 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.1.2.62
  retrieving revision 1.1.2.63
  diff -u -r1.1.2.62 -r1.1.2.63
  --- ChangeLog	15 Nov 2005 03:26:32 -0000	1.1.2.62
  +++ ChangeLog	15 Nov 2005 07:30:49 -0000	1.1.2.63
  @@ -1,3 +1,37 @@
  +2005-11-14  Adele Peterson  <adele at apple.com>
  +
  +        Merged fix from TOT to Safari-2-0-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]):
  +
   === WebCore-417.5 ===
   
   2005-11-14  Timothy Hatcher  <timothy at apple.com>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.9.18.2  +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.18.1
  retrieving revision 1.9.18.2
  diff -u -r1.9.18.1 -r1.9.18.2
  --- dom_element.cpp	4 Aug 2005 01:58:18 -0000	1.9.18.1
  +++ dom_element.cpp	15 Nov 2005 07:30:55 -0000	1.9.18.2
  @@ -300,6 +300,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.80.2  +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.80.1
  retrieving revision 1.6.80.2
  diff -u -r1.6.80.1 -r1.6.80.2
  --- dom_element.h	4 Aug 2005 01:58:18 -0000	1.6.80.1
  +++ dom_element.h	15 Nov 2005 07:30:55 -0000	1.6.80.2
  @@ -556,6 +556,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.6.11 +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.6.10
  retrieving revision 1.66.6.11
  diff -u -r1.66.6.10 -r1.66.6.11
  --- kjs_dom.cpp	4 Aug 2005 01:58:19 -0000	1.66.6.10
  +++ kjs_dom.cpp	15 Nov 2005 07:30:56 -0000	1.66.6.11
  @@ -1108,6 +1108,8 @@
     getElementsByTagNameNS DOMElement::GetElementsByTagNameNS	DontDelete|Function 2
     hasAttributeNS	DOMElement::HasAttributeNS	DontDelete|Function 2
     scrollIntoView        DOMElement::ScrollIntoView      DontDelete|Function 1
  +  focus                 DOMElement::ElementFocus        DontDelete|Function 0
  +  blur                  DOMElement::ElementBlur         DontDelete|Function 0
   
   # extension for Safari RSS
     scrollByLines         DOMElement::ScrollByLines       DontDelete|Function 1
  @@ -1243,6 +1245,12 @@
           return Undefined();
           
       }
  +    case DOMElement::ElementFocus:
  +        element.focus();
  +        return Undefined();
  +    case DOMElement::ElementBlur:
  +        element.blur();
  +        return Undefined();
     default:
       return Undefined();
     }
  
  
  
  1.34.6.7  +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.6.6
  retrieving revision 1.34.6.7
  diff -u -r1.34.6.6 -r1.34.6.7
  --- kjs_dom.h	4 Aug 2005 01:58:19 -0000	1.34.6.6
  +++ kjs_dom.h	15 Nov 2005 07:30:57 -0000	1.34.6.7
  @@ -159,7 +159,7 @@
              SetAttributeNode, RemoveAttributeNode, GetElementsByTagName,
              GetAttributeNS, SetAttributeNS, RemoveAttributeNS, GetAttributeNodeNS,
              SetAttributeNodeNS, GetElementsByTagNameNS, HasAttribute, HasAttributeNS,
  -           ScrollByLines, ScrollByPages, ScrollIntoView};
  +           ScrollByLines, ScrollByPages, ScrollIntoView, ElementFocus, ElementBlur};
     };
   
     class DOMDOMImplementation : public DOMObject {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.76.8.5  +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.8.4
  retrieving revision 1.76.8.5
  diff -u -r1.76.8.4 -r1.76.8.5
  --- html_elementimpl.cpp	28 Sep 2005 18:24:43 -0000	1.76.8.4
  +++ html_elementimpl.cpp	15 Nov 2005 07:30:59 -0000	1.76.8.5
  @@ -481,6 +481,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.6.12 +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.6.11
  retrieving revision 1.211.6.12
  diff -u -r1.211.6.11 -r1.211.6.12
  --- dom_docimpl.cpp	14 Nov 2005 23:03:24 -0000	1.211.6.11
  +++ dom_docimpl.cpp	15 Nov 2005 07:31:00 -0000	1.211.6.12
  @@ -2572,6 +2572,7 @@
       bool focusChangeBlocked = false;
       NodeImpl *oldFocusNode = m_focusNode;
       m_focusNode = 0;
  +    clearSelectionIfNeeded(newFocusNode);
   
       // Remove focus from the existing focus node (if any)
       if (oldFocusNode) {
  @@ -2590,12 +2591,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;
  @@ -2605,14 +2608,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)) {
  @@ -2651,8 +2646,13 @@
               }
               if (focusWidget)
                   focusWidget->setFocus();
  -            else
  +            else {
                   view()->setFocus();
  +                if (m_focusNode->renderer()) {
  +                    updateLayout();
  +                    m_focusNode->renderer()->enclosingLayer()->scrollRectToVisible(m_focusNode->getRect());
  +                }
  +            }
           }
      }
   
  @@ -2666,6 +2666,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.6.8 +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.6.7
  retrieving revision 1.104.6.8
  diff -u -r1.104.6.7 -r1.104.6.8
  --- dom_docimpl.h	14 Nov 2005 23:03:25 -0000	1.104.6.7
  +++ dom_docimpl.h	15 Nov 2005 07:31:02 -0000	1.104.6.8
  @@ -425,6 +425,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.8.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.8.1
  diff -u -r1.32 -r1.32.8.1
  --- DOM.mm	17 Feb 2005 00:14:29 -0000	1.32
  +++ DOM.mm	15 Nov 2005 07:31:04 -0000	1.32.8.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
  
  
  
  1.9.16.1  +5 -0      WebCore/kwq/DOMExtensions.h
  
  Index: DOMExtensions.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/DOMExtensions.h,v
  retrieving revision 1.9
  retrieving revision 1.9.16.1
  diff -u -r1.9 -r1.9.16.1
  --- DOMExtensions.h	25 May 2004 21:00:02 -0000	1.9
  +++ DOMExtensions.h	15 Nov 2005 07:31:05 -0000	1.9.16.1
  @@ -32,6 +32,11 @@
   - (DOMCSSStyleDeclaration *)createCSSStyleDeclaration;
   @end
   
  + at interface DOMElement (DOMElementExtensions)
  +- (void)focus;
  +- (void)blur;
  + at end
  +
   @interface DOMHTMLElement (DOMHTMLElementExtensions)
   - (NSString *)innerHTML;
   - (void)setInnerHTML:(NSString *)innerHTML;
  
  
  



More information about the webkit-changes mailing list