Changeset 86491 in webkit


Ignore:
Timestamp:
May 14, 2011 11:10:14 AM (13 years ago)
Author:
rniwa@webkit.org
Message:

2011-05-14 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Eric Seidel.

Make canHaveChildrenForEditing more efficient
https://bugs.webkit.org/show_bug.cgi?id=53564

Improved the performance (1-2% in release and 20% in debug) by adding virtual member function
canContainRangeEndPoint to Node. It returns true whenever the associated node can have be a container
node for a position.

As of this revision, canContainRangeEndPoint returns true on Document, DocumentFragment, Text nodes
and any elements except:

HTML: applet, br, embed, frame, frameset, hr (unless has children), img, input, keygen,

meter, object (unless uses fallback content), output, progress, select, and textarea.

No new tests are added since this change cannot be tested directly.

  • dom/Document.h: (WebCore::Document::canContainRangeEndPoint): Added; returns false.
  • dom/DocumentFragment.h: (WebCore::DocumentFragment::canContainRangeEndPoint): Added; returns true.
  • dom/Element.h: (WebCore::Element::canContainRangeEndPoint): Ditto.
  • dom/Node.h: (WebCore::Node::canContainRangeEndPoint): Added; returns false.
  • dom/Text.h: (WebCore::Text::canContainRangeEndPoint): Added; returns true.
  • editing/htmlediting.cpp: Removed editingIgnoresContent and canHaveChildrenForEditing.
  • editing/htmlediting.h: (WebCore::editingIgnoresContent): Moved from htmlediting.cpp; made it inline. (WebCore::canHaveChildrenForEditing): Ditto.
  • html/HTMLBRElement.h: (WebCore::HTMLBRElement::canContainRangeEndPoint): Added; returns false.
  • html/HTMLButtonElement.h: (WebCore::HTMLDataGridElement::canContainRangeEndPoint): Ditto.
  • html/HTMLFormControlElement.h: (WebCore::HTMLFormControlElementWithState::canContainRangeEndPoint): Ditto.
  • html/HTMLFrameElementBase.h: (WebCore::HTMLFrameElementBase::canContainRangeEndPoint): Ditto.
  • html/HTMLImageElement.h: (WebCore::HTMLImageElement::canContainRangeEndPoint): Ditto.
  • html/HTMLMeterElement.h: (WebCore::HTMLMeterElement::canContainRangeEndPoint): Ditto.
  • html/HTMLOutputElement.h: (WebCore::HTMLOutputElement::canContainRangeEndPoint): Ditto.
  • html/HTMLPlugInElement.h: (WebCore::HTMLPlugInElement::canContainRangeEndPoint): Ditto.
  • html/HTMLProgressElement.h: (WebCore::HTMLProgressElement::canContainRangeEndPoint): Ditto.
  • html/HTMLHRElement.h: (WebCore::HTMLHRElement::canContainRangeEndPoint): Added; returns true iff it has children.
  • html/HTMLObjectElement.h: (WebCore::HTMLObjectElement::canContainRangeEndPoint): Added; returns true iff it uses fallback content.
Location:
trunk/Source/WebCore
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86488 r86491  
     12011-05-14  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Make canHaveChildrenForEditing more efficient
     6        https://bugs.webkit.org/show_bug.cgi?id=53564
     7
     8        Improved the performance (1-2% in release and 20% in debug) by adding virtual member function
     9        canContainRangeEndPoint to Node. It returns true whenever the associated node can have be a container
     10        node for a position.
     11
     12        As of this revision, canContainRangeEndPoint returns true on Document, DocumentFragment, Text nodes
     13        and any elements except:
     14
     15        HTML: applet, br, embed, frame, frameset, hr (unless has children), img, input, keygen,
     16              meter, object (unless uses fallback content), output, progress, select, and textarea.
     17
     18        No new tests are added since this change cannot be tested directly.
     19
     20        * dom/Document.h:
     21        (WebCore::Document::canContainRangeEndPoint): Added; returns false.
     22        * dom/DocumentFragment.h:
     23        (WebCore::DocumentFragment::canContainRangeEndPoint): Added; returns true.
     24        * dom/Element.h:
     25        (WebCore::Element::canContainRangeEndPoint): Ditto.
     26        * dom/Node.h:
     27        (WebCore::Node::canContainRangeEndPoint): Added; returns false.
     28        * dom/Text.h:
     29        (WebCore::Text::canContainRangeEndPoint): Added; returns true.
     30        * editing/htmlediting.cpp: Removed editingIgnoresContent and canHaveChildrenForEditing.
     31        * editing/htmlediting.h:
     32        (WebCore::editingIgnoresContent): Moved from htmlediting.cpp; made it inline.
     33        (WebCore::canHaveChildrenForEditing): Ditto.
     34        * html/HTMLBRElement.h:
     35        (WebCore::HTMLBRElement::canContainRangeEndPoint): Added; returns false.
     36        * html/HTMLButtonElement.h:
     37        (WebCore::HTMLDataGridElement::canContainRangeEndPoint): Ditto.
     38        * html/HTMLFormControlElement.h:
     39        (WebCore::HTMLFormControlElementWithState::canContainRangeEndPoint): Ditto.
     40        * html/HTMLFrameElementBase.h:
     41        (WebCore::HTMLFrameElementBase::canContainRangeEndPoint): Ditto.
     42        * html/HTMLImageElement.h:
     43        (WebCore::HTMLImageElement::canContainRangeEndPoint): Ditto.
     44        * html/HTMLMeterElement.h:
     45        (WebCore::HTMLMeterElement::canContainRangeEndPoint): Ditto.
     46        * html/HTMLOutputElement.h:
     47        (WebCore::HTMLOutputElement::canContainRangeEndPoint): Ditto.
     48        * html/HTMLPlugInElement.h:
     49        (WebCore::HTMLPlugInElement::canContainRangeEndPoint): Ditto.
     50        * html/HTMLProgressElement.h:
     51        (WebCore::HTMLProgressElement::canContainRangeEndPoint): Ditto.
     52        * html/HTMLHRElement.h:
     53        (WebCore::HTMLHRElement::canContainRangeEndPoint): Added; returns true iff it has children.
     54        * html/HTMLObjectElement.h:
     55        (WebCore::HTMLObjectElement::canContainRangeEndPoint): Added; returns true iff it uses fallback
     56        content.
     57
    1582011-05-14  Jeremy Noble  <jer.noble@apple.com>
    259
  • trunk/Source/WebCore/dom/Document.h

    r86488 r86491  
    249249    Element* getElementById(const AtomicString& id) const;
    250250
     251    virtual bool canContainRangeEndPoint() const { return true; }
     252
    251253    Element* getElementByAccessKey(const String& key);
    252254    void invalidateAccessKeyMap();
  • trunk/Source/WebCore/dom/DocumentFragment.h

    r83816 r86491  
    3636    void parseHTML(const String&, Element* contextElement, FragmentScriptingPermission = FragmentScriptingAllowed);
    3737    bool parseXML(const String&, Element* contextElement, FragmentScriptingPermission = FragmentScriptingAllowed);
     38   
     39    virtual bool canContainRangeEndPoint() const { return true; }
    3840
    3941protected:
  • trunk/Source/WebCore/dom/Element.h

    r85811 r86491  
    327327    virtual bool isFrameElementBase() const { return false; }
    328328
     329    virtual bool canContainRangeEndPoint() const { return true; }
     330
    329331    virtual bool formControlValueMatchesRenderer() const { return false; }
    330332    virtual void setFormControlValueMatchesRenderer(bool) { }
  • trunk/Source/WebCore/dom/Node.h

    r86248 r86491  
    238238    void setNextSibling(Node* next) { m_next = next; }
    239239
     240    virtual bool canContainRangeEndPoint() const { return false; }
     241
    240242    // FIXME: These two functions belong in editing -- "atomic node" is an editing concept.
    241243    Node* previousNodeConsideringAtomicNodes() const;
  • trunk/Source/WebCore/dom/Text.h

    r83816 r86491  
    4343
    4444    virtual void attach();
     45   
     46    virtual bool canContainRangeEndPoint() const { return true; }
    4547
    4648protected:
  • trunk/Source/WebCore/editing/htmlediting.cpp

    r85256 r86491  
    6262}
    6363
    64 // Returns true for nodes that either have no content, or have content that is ignored (skipped
    65 // over) while editing.  There are no VisiblePositions inside these nodes.
    66 bool editingIgnoresContent(const Node* node)
    67 {
    68     return !canHaveChildrenForEditing(node) && !node->isTextNode();
    69 }
    70 
    71 bool canHaveChildrenForEditing(const Node* node)
    72 {
    73     return !node->isTextNode()
    74         && !node->hasTagName(brTag)
    75         && !node->hasTagName(imgTag)
    76         && !node->hasTagName(inputTag)
    77         && !node->hasTagName(textareaTag)
    78         && (!node->hasTagName(objectTag) || static_cast<const HTMLObjectElement*>(node)->useFallbackContent())
    79         && !node->hasTagName(iframeTag)
    80         && !node->hasTagName(embedTag)
    81         && !node->hasTagName(appletTag)
    82         && !node->hasTagName(selectTag)
    83         && (!node->hasTagName(hrTag) || node->hasChildNodes());
    84 }
    85 
    8664// Compare two positions, taking into account the possibility that one or both
    8765// could be inside a shadow tree. Only works for non-null values.
  • trunk/Source/WebCore/editing/htmlediting.h

    r86325 r86491  
    7777// boolean functions on Node
    7878
    79 bool editingIgnoresContent(const Node*);
    80 bool canHaveChildrenForEditing(const Node*);
     79// FIXME: editingIgnoresContent, canHaveChildrenForEditing, and isAtomicNode
     80// should be renamed to reflect its usage.
     81
     82// Returns true for nodes that either have no content, or have content that is ignored (skipped over) while editing.
     83// There are no VisiblePositions inside these nodes.
     84inline bool editingIgnoresContent(const Node* node)
     85{
     86    return !node->canContainRangeEndPoint();
     87}
     88
     89inline bool canHaveChildrenForEditing(const Node* node)
     90{
     91    return !node->isTextNode() && node->canContainRangeEndPoint();
     92}
     93
    8194bool isAtomicNode(const Node*);
    8295bool isBlock(const Node*);
  • trunk/Source/WebCore/html/HTMLBRElement.h

    r78232 r86491  
    3434    static PassRefPtr<HTMLBRElement> create(const QualifiedName&, Document*);
    3535
     36    virtual bool canContainRangeEndPoint() const { return false; }
     37
    3638private:
    3739    HTMLBRElement(const QualifiedName&, Document*);
  • trunk/Source/WebCore/html/HTMLFormControlElement.h

    r82925 r86491  
    173173    virtual ~HTMLFormControlElementWithState();
    174174
     175    virtual bool canContainRangeEndPoint() const { return false; }
     176
    175177protected:
    176178    HTMLFormControlElementWithState(const QualifiedName& tagName, Document*, HTMLFormElement*);
  • trunk/Source/WebCore/html/HTMLFrameElementBase.h

    r84706 r86491  
    4949    virtual bool containsFullScreenElement() const { return m_containsFullScreenElement; };
    5050#endif
     51
     52    virtual bool canContainRangeEndPoint() const { return false; }
    5153
    5254protected:
  • trunk/Source/WebCore/html/HTMLHRElement.h

    r78232 r86491  
    3333    static PassRefPtr<HTMLHRElement> create(const QualifiedName&, Document*);
    3434
     35    virtual bool canContainRangeEndPoint() const { return hasChildNodes(); }
     36
    3537private:
    3638    HTMLHRElement(const QualifiedName&, Document*);
  • trunk/Source/WebCore/html/HTMLImageElement.h

    r85375 r86491  
    7676    bool hasPendingActivity();
    7777
     78    virtual bool canContainRangeEndPoint() const { return false; }
     79
    7880protected:
    7981    HTMLImageElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
  • trunk/Source/WebCore/html/HTMLMeterElement.h

    r82899 r86491  
    6060    GaugeRegion gaugeRegion() const;
    6161
     62    bool canContainRangeEndPoint() const { return false; }
     63
    6264private:
    6365    HTMLMeterElement(const QualifiedName&, Document*, HTMLFormElement*);
  • trunk/Source/WebCore/html/HTMLObjectElement.h

    r82925 r86491  
    6464    using TreeShared<ContainerNode>::deref;
    6565
     66    virtual bool canContainRangeEndPoint() const { return useFallbackContent(); }
     67
    6668private:
    6769    HTMLObjectElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
  • trunk/Source/WebCore/html/HTMLOutputElement.h

    r82925 r86491  
    5050    void setFor(const String&);
    5151    DOMSettableTokenList* htmlFor() const;
     52   
     53    virtual bool canContainRangeEndPoint() const { return false; }
    5254
    5355private:
  • trunk/Source/WebCore/html/HTMLPlugInElement.h

    r78232 r86491  
    5252    void setIsCapturingMouseEvents(bool capturing) { m_isCapturingMouseEvents = capturing; }
    5353
     54    bool canContainRangeEndPoint() const { return false; }
     55
    5456protected:
    5557    HTMLPlugInElement(const QualifiedName& tagName, Document*);
  • trunk/Source/WebCore/html/HTMLProgressElement.h

    r84156 r86491  
    4444    double position() const;
    4545
     46    virtual bool canContainRangeEndPoint() const { return false; }
     47
    4648private:
    4749    HTMLProgressElement(const QualifiedName&, Document*, HTMLFormElement*);
Note: See TracChangeset for help on using the changeset viewer.