| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) | 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) |
| 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) | 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) |
| 5 * (C) 2001 Peter Kelly (pmk@post.com) | 5 * (C) 2001 Peter Kelly (pmk@post.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 } | 1575 } |
| 1576 | 1576 |
| 1577 FloatRect Range::boundingRect() const | 1577 FloatRect Range::boundingRect() const |
| 1578 { | 1578 { |
| 1579 m_ownerDocument->updateLayoutIgnorePendingStylesheets(); | 1579 m_ownerDocument->updateLayoutIgnorePendingStylesheets(); |
| 1580 | 1580 |
| 1581 Vector<FloatQuad> quads; | 1581 Vector<FloatQuad> quads; |
| 1582 getBorderAndTextQuads(quads); | 1582 getBorderAndTextQuads(quads); |
| 1583 | 1583 |
| 1584 FloatRect result; | 1584 FloatRect result; |
| 1585 // As per section 10 in https://www.w3.org/TR/cssom-view/ | 1585 for (const FloatQuad& quad : quads) |
| 1586 // "Return a static DOMRect object describing the smallest rectangle that | 1586 result.unite(quad.boundingBox()); // Skips empty rects. |
| 1587 // includes the first rectangle in list and all of the remaining rectangles | 1587 |
| 1588 // of which the height or width is not zero." | 1588 // If all rects are empty, return the first rect. |
| 1589 for (const FloatQuad& quad : quads) { | 1589 if (result.isEmpty() && !quads.isEmpty()) |
| 1590 if (result.isEmpty()) | 1590 return quads.first().boundingBox(); |
| 1591 result.uniteIfNonZero(quad.boundingBox()); | |
| 1592 else | |
| 1593 result.unite(quad.boundingBox()); // Skips empty rects. | |
| 1594 } | |
| 1595 | 1591 |
| 1596 return result; | 1592 return result; |
| 1597 } | 1593 } |
| 1598 | 1594 |
| 1599 DEFINE_TRACE(Range) | 1595 DEFINE_TRACE(Range) |
| 1600 { | 1596 { |
| 1601 visitor->trace(m_ownerDocument); | 1597 visitor->trace(m_ownerDocument); |
| 1602 visitor->trace(m_start); | 1598 visitor->trace(m_start); |
| 1603 visitor->trace(m_end); | 1599 visitor->trace(m_end); |
| 1604 } | 1600 } |
| 1605 | 1601 |
| 1606 } // namespace blink | 1602 } // namespace blink |
| 1607 | 1603 |
| 1608 #ifndef NDEBUG | 1604 #ifndef NDEBUG |
| 1609 | 1605 |
| 1610 void showTree(const blink::Range* range) | 1606 void showTree(const blink::Range* range) |
| 1611 { | 1607 { |
| 1612 if (range && range->boundaryPointsValid()) { | 1608 if (range && range->boundaryPointsValid()) { |
| 1613 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1609 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
| 1614 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1610 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
| 1615 } else { | 1611 } else { |
| 1616 fprintf(stderr, "Cannot show tree if range is null, or if boundary point
s are invalid.\n"); | 1612 fprintf(stderr, "Cannot show tree if range is null, or if boundary point
s are invalid.\n"); |
| 1617 } | 1613 } |
| 1618 } | 1614 } |
| 1619 | 1615 |
| 1620 #endif | 1616 #endif |
| OLD | NEW |