| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 static inline RenderObject* firstChildConsideringContinuation(RenderObject* rend
erer) | 104 static inline RenderObject* firstChildConsideringContinuation(RenderObject* rend
erer) |
| 105 { | 105 { |
| 106 RenderObject* firstChild = renderer->firstChild(); | 106 RenderObject* firstChild = renderer->firstChild(); |
| 107 | 107 |
| 108 if (!firstChild && isInlineWithContinuation(renderer)) | 108 if (!firstChild && isInlineWithContinuation(renderer)) |
| 109 firstChild = firstChildInContinuation(renderer); | 109 firstChild = firstChildInContinuation(renderer); |
| 110 | 110 |
| 111 return firstChild; | 111 return firstChild; |
| 112 } | 112 } |
| 113 | 113 |
| 114 | |
| 115 static inline RenderObject* lastChildConsideringContinuation(RenderObject* rende
rer) | |
| 116 { | |
| 117 RenderObject* lastChild = renderer->lastChild(); | |
| 118 RenderObject* prev; | |
| 119 RenderObject* cur = renderer; | |
| 120 | |
| 121 if (!cur->isRenderInline() && !cur->isRenderBlock()) | |
| 122 return renderer; | |
| 123 | |
| 124 while (cur) { | |
| 125 prev = cur; | |
| 126 | |
| 127 if (RenderObject* lc = cur->lastChild()) | |
| 128 lastChild = lc; | |
| 129 | |
| 130 if (cur->isRenderInline()) { | |
| 131 cur = toRenderInline(cur)->inlineElementContinuation(); | |
| 132 ASSERT_UNUSED(prev, cur || !toRenderInline(prev)->continuation()); | |
| 133 } else | |
| 134 cur = toRenderBlock(cur)->inlineElementContinuation(); | |
| 135 } | |
| 136 | |
| 137 return lastChild; | |
| 138 } | |
| 139 | |
| 140 static inline RenderInline* startOfContinuations(RenderObject* r) | 114 static inline RenderInline* startOfContinuations(RenderObject* r) |
| 141 { | 115 { |
| 142 if (r->isInlineElementContinuation()) { | 116 if (r->isInlineElementContinuation()) { |
| 143 return toRenderInline(r->node()->renderer()); | 117 return toRenderInline(r->node()->renderer()); |
| 144 } | 118 } |
| 145 | 119 |
| 146 // Blocks with a previous continuation always have a next continuation | 120 // Blocks with a previous continuation always have a next continuation |
| 147 if (r->isRenderBlock() && toRenderBlock(r)->inlineElementContinuation()) | 121 if (r->isRenderBlock() && toRenderBlock(r)->inlineElementContinuation()) |
| 148 return toRenderInline(toRenderBlock(r)->inlineElementContinuation()->nod
e()->renderer()); | 122 return toRenderInline(toRenderBlock(r)->inlineElementContinuation()->nod
e()->renderer()); |
| 149 | 123 |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 return 0; | 1501 return 0; |
| 1528 | 1502 |
| 1529 RenderObject* firstChild = firstChildConsideringContinuation(m_renderer); | 1503 RenderObject* firstChild = firstChildConsideringContinuation(m_renderer); |
| 1530 | 1504 |
| 1531 if (!firstChild) | 1505 if (!firstChild) |
| 1532 return 0; | 1506 return 0; |
| 1533 | 1507 |
| 1534 return axObjectCache()->getOrCreate(firstChild); | 1508 return axObjectCache()->getOrCreate(firstChild); |
| 1535 } | 1509 } |
| 1536 | 1510 |
| 1537 AccessibilityObject* AccessibilityRenderObject::lastChild() const | |
| 1538 { | |
| 1539 if (!m_renderer) | |
| 1540 return 0; | |
| 1541 | |
| 1542 RenderObject* lastChild = lastChildConsideringContinuation(m_renderer); | |
| 1543 | |
| 1544 if (!lastChild) | |
| 1545 return 0; | |
| 1546 | |
| 1547 return axObjectCache()->getOrCreate(lastChild); | |
| 1548 } | |
| 1549 | |
| 1550 AccessibilityObject* AccessibilityRenderObject::previousSibling() const | |
| 1551 { | |
| 1552 if (!m_renderer) | |
| 1553 return 0; | |
| 1554 | |
| 1555 RenderObject* previousSibling = 0; | |
| 1556 | |
| 1557 // Case 1: The node is a block and is an inline's continuation. In that case
, the inline's | |
| 1558 // last child is our previous sibling (or further back in the continuation c
hain) | |
| 1559 RenderInline* startOfConts; | |
| 1560 if (m_renderer->isRenderBlock() && (startOfConts = startOfContinuations(m_re
nderer))) | |
| 1561 previousSibling = childBeforeConsideringContinuations(startOfConts, m_re
nderer); | |
| 1562 | |
| 1563 // Case 2: Anonymous block parent of the end of a continuation - skip all th
e way to before | |
| 1564 // the parent of the start, since everything in between will be linked up vi
a the continuation. | |
| 1565 else if (m_renderer->isAnonymousBlock() && firstChildIsInlineContinuation(m_
renderer)) { | |
| 1566 RenderObject* firstParent = startOfContinuations(m_renderer->firstChild(
))->parent(); | |
| 1567 while (firstChildIsInlineContinuation(firstParent)) | |
| 1568 firstParent = startOfContinuations(firstParent->firstChild())->paren
t(); | |
| 1569 previousSibling = firstParent->previousSibling(); | |
| 1570 } | |
| 1571 | |
| 1572 // Case 3: The node has an actual previous sibling | |
| 1573 else if (RenderObject* ps = m_renderer->previousSibling()) | |
| 1574 previousSibling = ps; | |
| 1575 | |
| 1576 // Case 4: This node has no previous siblings, but its parent is an inline, | |
| 1577 // and is another node's inline continutation. Follow the continuation chain
. | |
| 1578 else if (m_renderer->parent()->isRenderInline() && (startOfConts = startOfCo
ntinuations(m_renderer->parent()))) | |
| 1579 previousSibling = childBeforeConsideringContinuations(startOfConts, m_re
nderer->parent()->firstChild()); | |
| 1580 | |
| 1581 if (!previousSibling) | |
| 1582 return 0; | |
| 1583 | |
| 1584 return axObjectCache()->getOrCreate(previousSibling); | |
| 1585 } | |
| 1586 | |
| 1587 AccessibilityObject* AccessibilityRenderObject::nextSibling() const | 1511 AccessibilityObject* AccessibilityRenderObject::nextSibling() const |
| 1588 { | 1512 { |
| 1589 if (!m_renderer) | 1513 if (!m_renderer) |
| 1590 return 0; | 1514 return 0; |
| 1591 | 1515 |
| 1592 RenderObject* nextSibling = 0; | 1516 RenderObject* nextSibling = 0; |
| 1593 | 1517 |
| 1594 // Case 1: node is a block and has an inline continuation. Next sibling is t
he inline continuation's | 1518 // Case 1: node is a block and has an inline continuation. Next sibling is t
he inline continuation's |
| 1595 // first child. | 1519 // first child. |
| 1596 RenderInline* inlineContinuation; | 1520 RenderInline* inlineContinuation; |
| (...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2680 if (label && label->renderer()) { | 2604 if (label && label->renderer()) { |
| 2681 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); | 2605 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); |
| 2682 result.unite(labelRect); | 2606 result.unite(labelRect); |
| 2683 } | 2607 } |
| 2684 } | 2608 } |
| 2685 | 2609 |
| 2686 return result; | 2610 return result; |
| 2687 } | 2611 } |
| 2688 | 2612 |
| 2689 } // namespace WebCore | 2613 } // namespace WebCore |
| OLD | NEW |