| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/dom/PositionIterator.h" | 27 #include "core/dom/PositionIterator.h" |
| 28 | 28 |
| 29 #include "HTMLNames.h" | 29 #include "HTMLNames.h" |
| 30 #include "core/dom/Node.h" | 30 #include "core/dom/Node.h" |
| 31 #include "core/editing/htmlediting.h" | 31 #include "core/editing/htmlediting.h" |
| 32 #include "core/html/HTMLHtmlElement.h" | 32 #include "core/html/HTMLHtmlElement.h" |
| 33 #include "core/rendering/RenderBlock.h" | 33 #include "core/rendering/RenderBlock.h" |
| 34 #include "core/rendering/RenderTextFragment.h" |
| 34 | 35 |
| 35 namespace WebCore { | 36 namespace WebCore { |
| 36 | 37 |
| 37 using namespace HTMLNames; | 38 using namespace HTMLNames; |
| 38 | 39 |
| 39 PositionIterator::operator Position() const | 40 PositionIterator::operator Position() const |
| 40 { | 41 { |
| 41 if (m_nodeAfterPositionInAnchor) { | 42 if (m_nodeAfterPositionInAnchor) { |
| 42 ASSERT(m_nodeAfterPositionInAnchor->parentNode() == m_anchorNode); | 43 ASSERT(m_nodeAfterPositionInAnchor->parentNode() == m_anchorNode); |
| 43 // FIXME: This check is inadaquete because any ancestor could be ignored
by editing | 44 // FIXME: This check is inadaquete because any ancestor could be ignored
by editing |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } else { | 97 } else { |
| 97 if (m_offsetInAnchor) | 98 if (m_offsetInAnchor) |
| 98 m_offsetInAnchor = Position::uncheckedPreviousOffset(m_anchorNode, m
_offsetInAnchor); | 99 m_offsetInAnchor = Position::uncheckedPreviousOffset(m_anchorNode, m
_offsetInAnchor); |
| 99 else { | 100 else { |
| 100 m_nodeAfterPositionInAnchor = m_anchorNode; | 101 m_nodeAfterPositionInAnchor = m_anchorNode; |
| 101 m_anchorNode = m_anchorNode->parentNode(); | 102 m_anchorNode = m_anchorNode->parentNode(); |
| 102 } | 103 } |
| 103 } | 104 } |
| 104 } | 105 } |
| 105 | 106 |
| 107 RenderObject* PositionIterator::renderer() const |
| 108 { |
| 109 if (!m_anchorNode) |
| 110 return 0; |
| 111 Position pos = *this; |
| 112 return pos.renderer(); |
| 113 } |
| 114 |
| 106 bool PositionIterator::atStart() const | 115 bool PositionIterator::atStart() const |
| 107 { | 116 { |
| 108 if (!m_anchorNode) | 117 if (!m_anchorNode) |
| 109 return true; | 118 return true; |
| 110 if (m_anchorNode->parentNode()) | 119 if (m_anchorNode->parentNode()) |
| 111 return false; | 120 return false; |
| 112 return (!m_anchorNode->hasChildNodes() && !m_offsetInAnchor) || (m_nodeAfter
PositionInAnchor && !m_nodeAfterPositionInAnchor->previousSibling()); | 121 return (!m_anchorNode->hasChildNodes() && !m_offsetInAnchor) || (m_nodeAfter
PositionInAnchor && !m_nodeAfterPositionInAnchor->previousSibling()); |
| 113 } | 122 } |
| 114 | 123 |
| 115 bool PositionIterator::atEnd() const | 124 bool PositionIterator::atEnd() const |
| (...skipping 21 matching lines...) Expand all Loading... |
| 137 if (m_nodeAfterPositionInAnchor) | 146 if (m_nodeAfterPositionInAnchor) |
| 138 return false; | 147 return false; |
| 139 return m_anchorNode->hasChildNodes() || m_offsetInAnchor >= lastOffsetForEdi
ting(m_anchorNode); | 148 return m_anchorNode->hasChildNodes() || m_offsetInAnchor >= lastOffsetForEdi
ting(m_anchorNode); |
| 140 } | 149 } |
| 141 | 150 |
| 142 bool PositionIterator::isCandidate() const | 151 bool PositionIterator::isCandidate() const |
| 143 { | 152 { |
| 144 if (!m_anchorNode) | 153 if (!m_anchorNode) |
| 145 return false; | 154 return false; |
| 146 | 155 |
| 147 RenderObject* renderer = m_anchorNode->renderer(); | 156 RenderObject* renderer = this->renderer(); |
| 148 if (!renderer) | 157 if (!renderer) |
| 149 return false; | 158 return false; |
| 150 | 159 |
| 151 if (renderer->style()->visibility() != VISIBLE) | 160 if (renderer->style()->visibility() != VISIBLE) |
| 152 return false; | 161 return false; |
| 153 | 162 |
| 154 if (renderer->isBR()) | 163 if (renderer->isBR()) |
| 155 return !m_offsetInAnchor && !Position::nodeIsUserSelectNone(m_anchorNode
->parentNode()); | 164 return !m_offsetInAnchor && !Position::nodeIsUserSelectNone(m_anchorNode
->parentNode()); |
| 156 | 165 |
| 157 if (renderer->isText()) | 166 if (renderer->isText()) |
| 158 return !Position::nodeIsUserSelectNone(m_anchorNode) && Position(*this).
inRenderedText(); | 167 return !Position::nodeIsUserSelectNone(m_anchorNode) && Position(*this).
inRenderedText(); |
| 159 | 168 |
| 160 if (isTableElement(m_anchorNode) || editingIgnoresContent(m_anchorNode)) | 169 if (isTableElement(m_anchorNode) || editingIgnoresContent(m_anchorNode)) |
| 161 return (atStartOfNode() || atEndOfNode()) && !Position::nodeIsUserSelect
None(m_anchorNode->parentNode()); | 170 return (atStartOfNode() || atEndOfNode()) && !Position::nodeIsUserSelect
None(m_anchorNode->parentNode()); |
| 162 | 171 |
| 163 if (!isHTMLHtmlElement(m_anchorNode) && renderer->isBlockFlow()) { | 172 if (!isHTMLHtmlElement(m_anchorNode) && renderer->isBlockFlow()) { |
| 164 if (toRenderBlock(renderer)->logicalHeight() || m_anchorNode->hasTagName
(bodyTag)) { | 173 if (toRenderBlock(renderer)->logicalHeight() || m_anchorNode->hasTagName
(bodyTag)) { |
| 165 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer
)) | 174 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer
)) |
| 166 return atStartOfNode() && !Position::nodeIsUserSelectNone(m_anch
orNode); | 175 return atStartOfNode() && !Position::nodeIsUserSelectNone(m_anch
orNode); |
| 167 return m_anchorNode->rendererIsEditable() && !Position::nodeIsUserSe
lectNone(m_anchorNode) && Position(*this).atEditingBoundary(); | 176 return m_anchorNode->rendererIsEditable() && !Position::nodeIsUserSe
lectNone(m_anchorNode) && Position(*this).atEditingBoundary(); |
| 168 } | 177 } |
| 169 } | 178 } |
| 170 | 179 |
| 171 return false; | 180 return false; |
| 172 } | 181 } |
| 173 | 182 |
| 174 } // namespace WebCore | 183 } // namespace WebCore |
| OLD | NEW |