Changeset 29888 in webkit


Ignore:
Timestamp:
Jan 31, 2008, 10:50:43 AM (17 years ago)
Author:
Adam Roben
Message:

Add line box drawing code to InspectorController::drawNodeHighlight

This makes drawNodeHighlight a complete replacement for the painting
code in WebKit/mac/WebNodeHighlightView.mm, and also brings line box
rects to Windows for the first time.

Reviewed by Darin.

  • dom/Node.h: Changed isSVGElement to always exist, but to only be virtual when ENABLE(SVG) is true. This way you can always call node->isSVGElement() without checking ENABLE(SVG).
  • page/InspectorController.cpp: (WebCore::InspectorController::drawNodeHighlight): Ported line box rect code from the Mac implementation in WebNodeHighlightView.mm.
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r29887 r29888  
     12008-01-31  Adam Roben  <aroben@apple.com>
     2
     3        Add line box drawing code to InspectorController::drawNodeHighlight
     4
     5        This makes drawNodeHighlight a complete replacement for the painting
     6        code in WebKit/mac/WebNodeHighlightView.mm, and also brings line box
     7        rects to Windows for the first time.
     8
     9        Reviewed by Darin.
     10
     11        * dom/Node.h: Changed isSVGElement to always exist, but to only be
     12        virtual when ENABLE(SVG) is true. This way you can always call
     13        node->isSVGElement() without checking ENABLE(SVG).
     14        * page/InspectorController.cpp:
     15        (WebCore::InspectorController::drawNodeHighlight): Ported line box
     16        rect code from the Mac implementation in WebNodeHighlightView.mm.
     17
    1182008-01-31  Adam Roben  <aroben@apple.com>
    219
  • trunk/WebCore/dom/Node.h

    r29481 r29888  
    143143    virtual bool isElementNode() const { return false; }
    144144    virtual bool isHTMLElement() const { return false; }
     145
    145146#if ENABLE(SVG)
    146     virtual bool isSVGElement() const { return false; }
     147    virtual
    147148#endif
     149        bool isSVGElement() const { return false; }
     150
    148151    virtual bool isStyledElement() const { return false; }
    149152    virtual bool isFrameOwnerElement() const { return false; }
  • trunk/WebCore/page/InspectorController.cpp

    r29887 r29888  
    15981598    IntRect nodeRect(renderer->absoluteBoundingBoxRect());
    15991599
     1600    Vector<IntRect> rects;
     1601    if (renderer->isInline() || (renderer->isText() && !m_highlightedNode->isSVGElement()))
     1602        renderer->addLineBoxRects(rects);
     1603    if (rects.isEmpty())
     1604        rects.append(nodeRect);
     1605
    16001606    if (!overlayRect.contains(nodeRect) && !nodeRect.contains(enclosingIntRect(overlayRect))) {
    16011607        Element* element;
     
    16071613    }
    16081614
    1609     context.clipOut(nodeRect);
    1610 
     1615    // Draw translucent gray fill, out of which we will cut holes.
    16111616    context.fillRect(overlayRect, overlayFillColor);
    16121617
    1613     IntRect outlineRect(nodeRect);
    1614     outlineRect.inflate(outlineThickness);
    1615     context.fillRect(outlineRect, Color::white);
     1618    // Draw white frames around holes in first pass, so they will be erased in
     1619    // places where holes overlap or abut.
     1620    for (size_t i = 0; i < rects.size(); ++i) {
     1621        IntRect rect = rects[i];
     1622        rect.inflate(outlineThickness);
     1623        context.fillRect(rect, Color::white);
     1624    }
     1625
     1626    // Erase holes in second pass.
     1627    for (size_t i = 0; i < rects.size(); ++i)
     1628        context.clearRect(rects[i]);
    16161629}
    16171630
Note: See TracChangeset for help on using the changeset viewer.