Changeset 238404 in webkit


Ignore:
Timestamp:
Nov 20, 2018 8:17:44 AM (5 years ago)
Author:
Antti Koivisto
Message:

Update hover state in composed tree
https://bugs.webkit.org/show_bug.cgi?id=191860

Reviewed by Zalan Bujtas.

The code was already mostly switched over from render tree to composed tree.
This patch replaces the remaining common ancestor search code with a DOM based equivalent.

  • dom/Document.cpp:

(WebCore::findNearestCommonComposedAncestor):
(WebCore::Document::updateHoverActiveState):
(WebCore::nearestCommonHoverAncestor): Deleted.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::hoverAncestor const): Deleted.

  • rendering/RenderBlock.h:
  • rendering/RenderElement.cpp:

(WebCore::RenderElement::hoverAncestor const): Deleted.

No longer needed.

  • rendering/RenderElement.h:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r238403 r238404  
     12018-11-20  Antti Koivisto  <antti@apple.com>
     2
     3        Update hover state in composed tree
     4        https://bugs.webkit.org/show_bug.cgi?id=191860
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        The code was already mostly switched over from render tree to composed tree.
     9        This patch replaces the remaining common ancestor search code with a DOM based equivalent.
     10
     11        * dom/Document.cpp:
     12        (WebCore::findNearestCommonComposedAncestor):
     13        (WebCore::Document::updateHoverActiveState):
     14        (WebCore::nearestCommonHoverAncestor): Deleted.
     15        * rendering/RenderBlock.cpp:
     16        (WebCore::RenderBlock::hoverAncestor const): Deleted.
     17        * rendering/RenderBlock.h:
     18        * rendering/RenderElement.cpp:
     19        (WebCore::RenderElement::hoverAncestor const): Deleted.
     20
     21        No longer needed.
     22
     23        * rendering/RenderElement.h:
     24
    1252018-11-20  Zalan Bujtas  <zalan@apple.com>
    226
  • trunk/Source/WebCore/dom/Document.cpp

    r238377 r238404  
    71377137}
    71387138
    7139 static RenderElement* nearestCommonHoverAncestor(RenderElement* obj1, RenderElement* obj2)
    7140 {
    7141     if (!obj1 || !obj2)
     7139static Element* findNearestCommonComposedAncestor(Element* elementA, Element* elementB)
     7140{
     7141    if (!elementA || !elementB)
    71427142        return nullptr;
    71437143
    7144     for (RenderElement* currObj1 = obj1; currObj1; currObj1 = currObj1->hoverAncestor()) {
    7145         for (RenderElement* currObj2 = obj2; currObj2; currObj2 = currObj2->hoverAncestor()) {
    7146             if (currObj1 == currObj2)
    7147                 return currObj1;
    7148         }
    7149     }
    7150 
     7144    if (elementA == elementB)
     7145        return elementA;
     7146
     7147    HashSet<Element*> ancestorChain;
     7148    for (auto* element = elementA; element; element = element->parentElementInComposedTree())
     7149        ancestorChain.add(element);
     7150
     7151    for (auto* element = elementB; element; element = element->parentElementInComposedTree()) {
     7152        if (ancestorChain.contains(element))
     7153            return element;
     7154    }
    71517155    return nullptr;
    71527156}
     
    72097213    m_hoveredElement = newHoveredElement;
    72107214
    7211     // We have two different objects. Fetch their renderers.
    7212     RenderElement* oldHoverObj = oldHoveredElement ? oldHoveredElement->renderer() : nullptr;
    7213     RenderElement* newHoverObj = newHoveredElement ? newHoveredElement->renderer() : nullptr;
    7214 
    7215     // Locate the common ancestor render object for the two renderers.
    7216     RenderElement* ancestor = nearestCommonHoverAncestor(oldHoverObj, newHoverObj);
     7215    auto* commonAncestor = findNearestCommonComposedAncestor(oldHoveredElement.get(), newHoveredElement);
    72177216
    72187217    Vector<RefPtr<Element>, 32> elementsToRemoveFromChain;
    72197218    Vector<RefPtr<Element>, 32> elementsToAddToChain;
    72207219
    7221     if (oldHoverObj != newHoverObj) {
     7220    if (oldHoveredElement != newHoveredElement) {
    72227221        for (auto* element = oldHoveredElement.get(); element; element = element->parentElementInComposedTree()) {
    7223             if (ancestor && ancestor->element() == element)
     7222            if (element == commonAncestor)
    72247223                break;
    72257224            if (!mustBeInActiveChain || element->inActiveChain())
     
    72287227        // Unset hovered nodes in sub frame documents if the old hovered node was a frame owner.
    72297228        if (is<HTMLFrameOwnerElement>(oldHoveredElement)) {
    7230             if (Document* contentDocument = downcast<HTMLFrameOwnerElement>(*oldHoveredElement).contentDocument())
     7229            if (auto* contentDocument = downcast<HTMLFrameOwnerElement>(*oldHoveredElement).contentDocument())
    72317230                contentDocument->updateHoverActiveState(request, nullptr);
    72327231        }
     
    72457244        if (allowActiveChanges)
    72467245            element->setActive(true);
    7247         if (ancestor && element == ancestor->element())
     7246        if (element == commonAncestor)
    72487247            sawCommonAncestor = true;
    72497248        if (!sawCommonAncestor) {
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r238359 r238404  
    27822782}
    27832783
    2784 RenderElement* RenderBlock::hoverAncestor() const
    2785 {
    2786     if (auto* continuation = this->continuation())
    2787         return continuation;
    2788     return RenderBox::hoverAncestor();
    2789 }
    2790 
    27912784void RenderBlock::updateDragState(bool dragOn)
    27922785{
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r235358 r238404  
    458458    const RenderStyle& outlineStyleForRepaint() const final;
    459459
    460     RenderElement* hoverAncestor() const final;
    461460    void updateDragState(bool dragOn) final;
    462461
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r238071 r238404  
    975975}
    976976
    977 RenderElement* RenderElement::hoverAncestor() const
    978 {
    979     return parent();
    980 }
    981 
    982977static inline void paintPhase(RenderElement& element, PaintPhase phase, PaintInfo& paintInfo, const LayoutPoint& childPoint)
    983978{
  • trunk/Source/WebCore/rendering/RenderElement.h

    r232229 r238404  
    9898    RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint, bool checkParent = true);
    9999
    100     virtual RenderElement* hoverAncestor() const;
    101 
    102100    virtual void dirtyLinesFromChangedChild(RenderObject&) { }
    103101
Note: See TracChangeset for help on using the changeset viewer.