| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
| 3 * Copyright (C) 2005 Alexey Proskuryakov. | 3 * Copyright (C) 2005 Alexey Proskuryakov. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/dom/Document.h" | 32 #include "core/dom/Document.h" |
| 33 #include "core/dom/FirstLetterPseudoElement.h" | 33 #include "core/dom/FirstLetterPseudoElement.h" |
| 34 #include "core/dom/Position.h" | 34 #include "core/dom/Position.h" |
| 35 #include "core/dom/shadow/ShadowRoot.h" | 35 #include "core/dom/shadow/ShadowRoot.h" |
| 36 #include "core/editing/VisiblePosition.h" | 36 #include "core/editing/VisiblePosition.h" |
| 37 #include "core/editing/VisibleUnits.h" | 37 #include "core/editing/VisibleUnits.h" |
| 38 #include "core/editing/htmlediting.h" | 38 #include "core/editing/htmlediting.h" |
| 39 #include "core/editing/iterators/CharacterIterator.h" | 39 #include "core/editing/iterators/CharacterIterator.h" |
| 40 #include "core/editing/iterators/WordAwareIterator.h" | 40 #include "core/editing/iterators/WordAwareIterator.h" |
| 41 #include "core/frame/FrameView.h" | 41 #include "core/frame/FrameView.h" |
| 42 #include "core/frame/UseCounter.h" |
| 42 #include "core/html/HTMLElement.h" | 43 #include "core/html/HTMLElement.h" |
| 43 #include "core/html/HTMLImageElement.h" | 44 #include "core/html/HTMLImageElement.h" |
| 44 #include "core/html/HTMLInputElement.h" | 45 #include "core/html/HTMLInputElement.h" |
| 45 #include "core/html/HTMLTextFormControlElement.h" | 46 #include "core/html/HTMLTextFormControlElement.h" |
| 46 #include "core/layout/LayoutTableCell.h" | 47 #include "core/layout/LayoutTableCell.h" |
| 47 #include "core/layout/LayoutTableRow.h" | 48 #include "core/layout/LayoutTableRow.h" |
| 48 #include "core/layout/LayoutTextControl.h" | 49 #include "core/layout/LayoutTextControl.h" |
| 49 #include "core/layout/LayoutTextFragment.h" | 50 #include "core/layout/LayoutTextFragment.h" |
| 50 #include "core/layout/line/InlineTextBox.h" | 51 #include "core/layout/line/InlineTextBox.h" |
| 51 #include "platform/fonts/Font.h" | 52 #include "platform/fonts/Font.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 , m_needsAnotherNewline(false) | 127 , m_needsAnotherNewline(false) |
| 127 , m_textBox(nullptr) | 128 , m_textBox(nullptr) |
| 128 , m_remainingTextBox(nullptr) | 129 , m_remainingTextBox(nullptr) |
| 129 , m_firstLetterText(nullptr) | 130 , m_firstLetterText(nullptr) |
| 130 , m_lastTextNode(nullptr) | 131 , m_lastTextNode(nullptr) |
| 131 , m_lastTextNodeEndedWithCollapsedSpace(false) | 132 , m_lastTextNodeEndedWithCollapsedSpace(false) |
| 132 , m_sortedTextBoxesPosition(0) | 133 , m_sortedTextBoxesPosition(0) |
| 133 , m_behavior(adjustBehaviorFlags<Strategy>(behavior)) | 134 , m_behavior(adjustBehaviorFlags<Strategy>(behavior)) |
| 134 , m_handledFirstLetter(false) | 135 , m_handledFirstLetter(false) |
| 135 , m_shouldStop(false) | 136 , m_shouldStop(false) |
| 137 , m_handleShadowRoot(false) |
| 136 // The call to emitsOriginalText() must occur after m_behavior is initialize
d. | 138 // The call to emitsOriginalText() must occur after m_behavior is initialize
d. |
| 137 , m_textState(emitsOriginalText()) | 139 , m_textState(emitsOriginalText()) |
| 138 { | 140 { |
| 139 ASSERT(start.isNotNull()); | 141 ASSERT(start.isNotNull()); |
| 140 ASSERT(end.isNotNull()); | 142 ASSERT(end.isNotNull()); |
| 141 if (start.compareTo(end) > 0) { | 143 if (start.compareTo(end) > 0) { |
| 142 initialize(end.containerNode(), end.computeOffsetInContainerNode(), star
t.containerNode(), start.computeOffsetInContainerNode()); | 144 initialize(end.containerNode(), end.computeOffsetInContainerNode(), star
t.containerNode(), start.computeOffsetInContainerNode()); |
| 143 return; | 145 return; |
| 144 } | 146 } |
| 145 initialize(start.containerNode(), start.computeOffsetInContainerNode(), end.
containerNode(), end.computeOffsetInContainerNode()); | 147 initialize(start.containerNode(), start.computeOffsetInContainerNode(), end.
containerNode(), end.computeOffsetInContainerNode()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // Calculate first out of bounds node. | 183 // Calculate first out of bounds node. |
| 182 m_pastEndNode = endContainer? pastLastNode<Strategy>(*endContainer, endOffse
t) : nullptr; | 184 m_pastEndNode = endContainer? pastLastNode<Strategy>(*endContainer, endOffse
t) : nullptr; |
| 183 | 185 |
| 184 // Identify the first run. | 186 // Identify the first run. |
| 185 advance(); | 187 advance(); |
| 186 } | 188 } |
| 187 | 189 |
| 188 template<typename Strategy> | 190 template<typename Strategy> |
| 189 TextIteratorAlgorithm<Strategy>::~TextIteratorAlgorithm() | 191 TextIteratorAlgorithm<Strategy>::~TextIteratorAlgorithm() |
| 190 { | 192 { |
| 193 if (!m_handleShadowRoot) |
| 194 return; |
| 195 Document* document = ownerDocument(); |
| 196 if (!document) |
| 197 return; |
| 198 if (m_behavior & TextIteratorForInnerText) |
| 199 UseCounter::count(document, UseCounter::InnerTextWithShadowTree); |
| 200 if (m_behavior & TextIteratorForSelectionToString) |
| 201 UseCounter::count(document, UseCounter::SelectionToStringWithShadowTree)
; |
| 202 if (m_behavior & TextIteratorForWindowFind) |
| 203 UseCounter::count(document, UseCounter::WindowFindWithShadowTree); |
| 191 } | 204 } |
| 192 | 205 |
| 193 template<typename Strategy> | 206 template<typename Strategy> |
| 194 bool TextIteratorAlgorithm<Strategy>::isInsideReplacedElement() const | 207 bool TextIteratorAlgorithm<Strategy>::isInsideReplacedElement() const |
| 195 { | 208 { |
| 196 if (atEnd() || length() != 1 || !m_node) | 209 if (atEnd() || length() != 1 || !m_node) |
| 197 return false; | 210 return false; |
| 198 | 211 |
| 199 LayoutObject* layoutObject = m_node->layoutObject(); | 212 LayoutObject* layoutObject = m_node->layoutObject(); |
| 200 return layoutObject && layoutObject->isReplaced(); | 213 return layoutObject && layoutObject->isReplaced(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 representNodeOffsetZero(); | 263 representNodeOffsetZero(); |
| 251 m_node = nullptr; | 264 m_node = nullptr; |
| 252 return; | 265 return; |
| 253 } | 266 } |
| 254 | 267 |
| 255 LayoutObject* layoutObject = m_node->layoutObject(); | 268 LayoutObject* layoutObject = m_node->layoutObject(); |
| 256 if (!layoutObject) { | 269 if (!layoutObject) { |
| 257 if (m_node->isShadowRoot()) { | 270 if (m_node->isShadowRoot()) { |
| 258 // A shadow root doesn't have a layoutObject, but we want to vis
it children anyway. | 271 // A shadow root doesn't have a layoutObject, but we want to vis
it children anyway. |
| 259 m_iterationProgress = m_iterationProgress < HandledNode ? Handle
dNode : m_iterationProgress; | 272 m_iterationProgress = m_iterationProgress < HandledNode ? Handle
dNode : m_iterationProgress; |
| 273 m_handleShadowRoot = true; |
| 260 } else { | 274 } else { |
| 261 m_iterationProgress = HandledChildren; | 275 m_iterationProgress = HandledChildren; |
| 262 } | 276 } |
| 263 } else { | 277 } else { |
| 264 // Enter author shadow roots, from youngest, if any and if necessary
. | 278 // Enter author shadow roots, from youngest, if any and if necessary
. |
| 265 if (m_iterationProgress < HandledOpenShadowRoots) { | 279 if (m_iterationProgress < HandledOpenShadowRoots) { |
| 266 if (entersOpenShadowRoots() && m_node->isElementNode() && toElem
ent(m_node)->hasOpenShadowRoot()) { | 280 if (entersOpenShadowRoots() && m_node->isElementNode() && toElem
ent(m_node)->hasOpenShadowRoot()) { |
| 267 ShadowRoot* youngestShadowRoot = toElement(m_node)->shadowRo
ot(); | 281 ShadowRoot* youngestShadowRoot = toElement(m_node)->shadowRo
ot(); |
| 268 ASSERT(youngestShadowRoot->type() == ShadowRoot::OpenShadowR
oot); | 282 ASSERT(youngestShadowRoot->type() == ShadowRoot::OpenShadowR
oot); |
| 269 m_node = youngestShadowRoot; | 283 m_node = youngestShadowRoot; |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 | 1110 |
| 1097 String plainText(const PositionInComposedTree& start, const PositionInComposedTr
ee& end, TextIteratorBehaviorFlags behavior) | 1111 String plainText(const PositionInComposedTree& start, const PositionInComposedTr
ee& end, TextIteratorBehaviorFlags behavior) |
| 1098 { | 1112 { |
| 1099 return createPlainText<EditingInComposedTreeStrategy>(start, end, behavior); | 1113 return createPlainText<EditingInComposedTreeStrategy>(start, end, behavior); |
| 1100 } | 1114 } |
| 1101 | 1115 |
| 1102 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; | 1116 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; |
| 1103 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInComposedTreeS
trategy>; | 1117 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInComposedTreeS
trategy>; |
| 1104 | 1118 |
| 1105 } // namespace blink | 1119 } // namespace blink |
| OLD | NEW |