Changeset 13555 in webkit


Ignore:
Timestamp:
Mar 29, 2006 1:38:54 AM (18 years ago)
Author:
mjs
Message:

LayoutTests:

Reviewed by Anders.


Test cases for Element.contains, including testing fix for
<rdar://problem/4405353> JavaScript flickers popups onmouseover

  • fast/dom/Element/contains-method-expected.txt: Added.
  • fast/dom/Element/contains-method.html: Added.
  • fast/dom/Element/resources/contains-method.js: Added.
  • fast/events/capture-on-target.html:

WebCore:

Reviewed by Anders.


  • fixed <rdar://problem/4454976> repro crash in -[NSTextView(NSSharing) setSelectedRanges:affinity:stillSelecting:] when navigating


Also fixed other issues with contains. The problem that caused the bug was:

  • contains should return true for the element itself, unlike isAncestor


Other problems I fixed:

  • contains shouldn't be present on non-Element nodes
  • contains should return false when passed a non-Element node
  • contains should return false when passed a non-Node
  • bindings/scripts/CodeGeneratorJS.pm: Handle Element as a parameter.
  • dom/Element.cpp: (WebCore::Element::contains): Added new implementation.
  • dom/Element.h: Added prototype for contains.
  • dom/Element.idl: Added IDL declaration for contains.
  • khtml/ecma/kjs_dom.cpp: (KJS::DOMNodeProtoFunc::callAsFunction): Added old wrong contains().
Location:
trunk
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r13553 r13555  
     12006-03-29  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Anders.
     4       
     5        Test cases for Element.contains, including testing fix for
     6        <rdar://problem/4405353> JavaScript flickers popups onmouseover
     7
     8        * fast/dom/Element/contains-method-expected.txt: Added.
     9        * fast/dom/Element/contains-method.html: Added.
     10        * fast/dom/Element/resources/contains-method.js: Added.
     11        * fast/events/capture-on-target.html:
     12
    1132006-03-28  Beth Dakin  <bdakin@apple.com>
    214
  • trunk/WebCore/ChangeLog

    r13554 r13555  
     12006-03-29  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Anders.
     4       
     5        - fixed  <rdar://problem/4454976> repro crash in -[NSTextView(NSSharing) setSelectedRanges:affinity:stillSelecting:] when navigating
     6       
     7        Also fixed other issues with contains. The problem that caused the bug was:
     8        - contains should return true for the element itself, unlike isAncestor
     9       
     10        Other problems I fixed:
     11        - contains shouldn't be present on non-Element nodes
     12        - contains should return false when passed a non-Element node
     13        - contains should return false when passed a non-Node
     14
     15        * bindings/scripts/CodeGeneratorJS.pm: Handle Element as a parameter.
     16        * dom/Element.cpp:
     17        (WebCore::Element::contains): Added new implementation.
     18        * dom/Element.h: Added prototype for contains.
     19        * dom/Element.idl: Added IDL declaration for contains.
     20        * khtml/ecma/kjs_dom.cpp:
     21        (KJS::DOMNodeProtoFunc::callAsFunction): Added old wrong contains().
     22
    1232006-03-28  Beth Dakin  <bdakin@apple.com>
    224
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r13548 r13555  
    711711    return "AbstractView*";
    712712  } elsif ($type eq "Node" or
     713           $type eq "Element" or
    713714           $type eq "Attr" or
    714715           $type eq "DocumentType" or
     
    748749  } elsif ($type eq "Node") {
    749750      return 0;
     751  } elsif ($type eq "Element") {
     752      return 0;
    750753  } elsif ($type eq "Attr") {
    751754      $implIncludes{"ExceptionCode.h"} = 1;
     
    807810      $implIncludes{"JSRange.h"} = 1;
    808811      return "toRange($value)";
     812  } elsif ($type eq "Element") {
     813    $implIncludes{"kjs_dom.h"} = 1;
     814    return "toElement($value)";
    809815  } else {
    810816    die "Don't know how to convert a JS value of type $type."
  • trunk/WebCore/dom/Element.cpp

    r13547 r13555  
    289289}
    290290
     291bool Element::contains(const Element* element) const
     292{
     293    if (!element)
     294        return false;
     295    return this == element || element->isAncestor(this);
     296}
     297
    291298void Element::createAttributeMap() const
    292299{
  • trunk/WebCore/dom/Element.h

    r13492 r13555  
    144144
    145145    Node* insertAdjacentElement(const String& where, Node* newChild, int& exception);
     146    bool contains(const Element*) const;
    146147 
    147148protected:
  • trunk/WebCore/dom/Element.idl

    r13492 r13555  
    8080        void blur();
    8181
    82         // IE only extension
    83         Node insertAdjacentElement(in DOMString position,
    84                                    in Node newAttr)
    85             raises(DOMException);
    86 
    8782        readonly attribute CSSStyleDeclaration style;
    8883
     84        // IE only extensions
     85        Node insertAdjacentElement(in DOMString position,
     86                                   in Node newElement)
     87            raises(DOMException);
     88       
     89        boolean contains(in Element element);
    8990    };
    9091
  • trunk/WebCore/khtml/ecma/kjs_dom.cpp

    r13548 r13555  
    8888  lookupNamespaceURI    DOMNode::LookupNamespaceURI DontDelete|Function 1
    8989  lookupPrefix  DOMNode::LookupPrefix   DontDelete|Function 1
    90 # IE extension
    91   contains      DOMNode::Contains       DontDelete|Function 1
    9290# "DOM level 0" (from Gecko DOM reference; also in WinIE)
    9391  item          DOMNode::Item           DontDelete|Function 1
     
    321319        return args[1];
    322320      return jsNull();
    323     case DOMNode::Contains:
    324       if (node.isElementNode())
    325         if (Node *node0 = toNode(args[0]))
    326           return jsBoolean(node.isAncestor(node0));
    327       // FIXME: Is there a good reason to return undefined rather than false
    328       // when the parameter is not a node? When the object is not an element?
    329       return jsUndefined();
    330321    case DOMNode::Item:
    331322      return thisObj->get(exec, args[0]->toInt32(exec));
Note: See TracChangeset for help on using the changeset viewer.