Changeset 150783 in webkit


Ignore:
Timestamp:
May 27, 2013 4:53:47 PM (11 years ago)
Author:
Darin Adler
Message:

Move hasNonEmptyBoundingBox from Node to HTMLAnchorElement
https://bugs.webkit.org/show_bug.cgi?id=116842

Reviewed by Antti Koivisto.

  • dom/Node.cpp: Removed hasNonEmptyBoundingBox.
  • dom/Node.h: Ditto.
  • html/HTMLAnchorElement.cpp:

(WebCore::HTMLAnchorElement::isMouseFocusable): Fixed #if to be more readable and
added more-explicit clearer comments. No behavior change.
(WebCore::hasNonEmptyBox): Added. Has the same code that was in
Node::hasNonEmptyBoundingBox with some additional comments.
(WebCore::HTMLAnchorElement::isKeyboardFocusable): Call hasNonEmptyBox.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150782 r150783  
     12013-05-27  Darin Adler  <darin@apple.com>
     2
     3        Move hasNonEmptyBoundingBox from Node to HTMLAnchorElement
     4        https://bugs.webkit.org/show_bug.cgi?id=116842
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * dom/Node.cpp: Removed hasNonEmptyBoundingBox.
     9        * dom/Node.h: Ditto.
     10
     11        * html/HTMLAnchorElement.cpp:
     12        (WebCore::HTMLAnchorElement::isMouseFocusable): Fixed #if to be more readable and
     13        added more-explicit clearer comments. No behavior change.
     14        (WebCore::hasNonEmptyBox): Added.  Has the same code that was in
     15        Node::hasNonEmptyBoundingBox with some additional comments.
     16        (WebCore::HTMLAnchorElement::isKeyboardFocusable): Call hasNonEmptyBox.
     17
    1182013-05-27  Darin Adler  <darin@apple.com>
    219
  • trunk/Source/WebCore/dom/Node.cpp

    r150782 r150783  
    774774}
    775775
    776 bool Node::hasNonEmptyBoundingBox() const
    777 {
    778     // Before calling absoluteRects, check for the common case where the renderer
    779     // is non-empty, since this is a faster check and almost always returns true.
    780     RenderBoxModelObject* box = renderBoxModelObject();
    781     if (!box)
    782         return false;
    783     if (!box->borderBoundingBox().isEmpty())
    784         return true;
    785 
    786     Vector<IntRect> rects;
    787     FloatPoint absPos = renderer()->localToAbsolute();
    788     renderer()->absoluteRects(rects, flooredLayoutPoint(absPos));
    789     size_t n = rects.size();
    790     for (size_t i = 0; i < n; ++i)
    791         if (!rects[i].isEmpty())
    792             return true;
    793 
    794     return false;
    795 }
    796 
    797776inline void Node::setStyleChange(StyleChangeType changeType)
    798777{
  • trunk/Source/WebCore/dom/Node.h

    r150782 r150783  
    427427    IntRect pixelSnappedRenderRect(bool* isReplaced) { return pixelSnappedIntRect(renderRect(isReplaced)); }
    428428
    429     // Returns true if the node has a non-empty bounding box in layout.
    430     // This does not 100% guarantee the user can see it, but is pretty close.
    431     // Note: This method only works properly after layout has occurred.
    432     bool hasNonEmptyBoundingBox() const;
    433 
    434429    unsigned nodeIndex() const;
    435430
  • trunk/Source/WebCore/html/HTMLAnchorElement.cpp

    r150715 r150783  
    9595bool HTMLAnchorElement::isMouseFocusable() const
    9696{
    97     // Anchor elements should be mouse focusable, https://bugs.webkit.org/show_bug.cgi?id=26856
    98 #if !PLATFORM(GTK) && !PLATFORM(QT) && !PLATFORM(EFL)
     97#if !(PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(QT))
     98    // Only allow links with tabIndex or contentEditable to be mouse focusable.
     99    // This is our rule for the Mac platform; on many other platforms we focus any link you click on.
    99100    if (isLink())
    100         // Only allow links with tabIndex or contentEditable to be mouse focusable.
    101101        return HTMLElement::supportsFocus();
    102102#endif
    103103
    104     // Allow tab index etc to control focus.
    105104    return HTMLElement::isMouseFocusable();
     105}
     106
     107static bool hasNonEmptyBox(RenderModelBoxObject* renderer)
     108{
     109    if (!renderer)
     110        return false;
     111
     112    // Before calling absoluteRects, check for the common case where borderBoundingBox
     113    // is non-empty, since this is a faster check and almost always returns true.
     114    // FIXME: Why do we need to call absoluteRects at all?
     115    if (!renderer->borderBoundingBox().isEmpty())
     116        return true;
     117
     118    // FIXME: Since all we are checking is whether the rects are empty, could we just
     119    // pass in 0,0 for the layout point instead of calling localToAbsolute?
     120    Vector<IntRect> rects;
     121    renderer->absoluteRects(rects, flooredLayoutPoint(renderer->localToAbsolute()));
     122    size_t size = rects.size();
     123    for (size_t i = 0; i < size; ++i) {
     124        if (!rects[i].isEmpty())
     125            return true;
     126    }
     127
     128    return false;
    106129}
    107130
     
    123146        return true;
    124147
    125     return hasNonEmptyBoundingBox();
     148    return hasNonEmptyBox(renderBoxModelObject());
    126149}
    127150
Note: See TracChangeset for help on using the changeset viewer.