Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 31 #include "core/HTMLNames.h" | 31 #include "core/HTMLNames.h" |
| 32 #include "core/dom/Document.h" | 32 #include "core/dom/Document.h" |
| 33 #include "core/dom/NodeTraversal.h" | 33 #include "core/dom/NodeTraversal.h" |
| 34 #include "core/dom/shadow/ShadowRoot.h" | 34 #include "core/dom/shadow/ShadowRoot.h" |
| 35 #include "core/editing/VisiblePosition.h" | 35 #include "core/editing/VisiblePosition.h" |
| 36 #include "core/editing/VisibleUnits.h" | 36 #include "core/editing/VisibleUnits.h" |
| 37 #include "core/editing/htmlediting.h" | 37 #include "core/editing/htmlediting.h" |
| 38 #include "core/frame/FrameView.h" | 38 #include "core/frame/FrameView.h" |
| 39 #include "core/html/HTMLElement.h" | 39 #include "core/html/HTMLElement.h" |
| 40 #include "core/html/HTMLImageElement.h" | |
| 40 #include "core/html/HTMLTextFormControlElement.h" | 41 #include "core/html/HTMLTextFormControlElement.h" |
| 41 #include "core/rendering/InlineTextBox.h" | 42 #include "core/rendering/InlineTextBox.h" |
| 42 #include "core/rendering/RenderImage.h" | 43 #include "core/rendering/RenderImage.h" |
| 43 #include "core/rendering/RenderTableCell.h" | 44 #include "core/rendering/RenderTableCell.h" |
| 44 #include "core/rendering/RenderTableRow.h" | 45 #include "core/rendering/RenderTableRow.h" |
| 45 #include "core/rendering/RenderTextControl.h" | 46 #include "core/rendering/RenderTextControl.h" |
| 46 #include "core/rendering/RenderTextFragment.h" | 47 #include "core/rendering/RenderTextFragment.h" |
| 47 #include "platform/fonts/Character.h" | 48 #include "platform/fonts/Character.h" |
| 48 #include "platform/fonts/Font.h" | 49 #include "platform/fonts/Font.h" |
| 49 #include "platform/text/TextBoundaries.h" | 50 #include "platform/text/TextBoundaries.h" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 | 461 |
| 461 // Handle the current node according to its type. | 462 // Handle the current node according to its type. |
| 462 if (m_iterationProgress < HandledNode) { | 463 if (m_iterationProgress < HandledNode) { |
| 463 bool handledNode = false; | 464 bool handledNode = false; |
| 464 if (renderer->isText() && m_node->nodeType() == Node::TEXT_NODE) { // FIXME: What about CDATA_SECTION_NODE? | 465 if (renderer->isText() && m_node->nodeType() == Node::TEXT_NODE) { // FIXME: What about CDATA_SECTION_NODE? |
| 465 handledNode = handleTextNode(); | 466 handledNode = handleTextNode(); |
| 466 } else if (renderer && (renderer->isImage() || renderer->isWidge t() | 467 } else if (renderer && (renderer->isImage() || renderer->isWidge t() |
| 467 || (m_node && m_node->isHTMLElement() | 468 || (m_node && m_node->isHTMLElement() |
| 468 && (isHTMLFormControlElement(toHTMLElement(*m_node)) | 469 && (isHTMLFormControlElement(toHTMLElement(*m_node)) |
| 469 || isHTMLLegendElement(toHTMLElement(*m_node)) | 470 || isHTMLLegendElement(toHTMLElement(*m_node)) |
| 471 || isHTMLImageElement(toElement(*m_node)) | |
| 470 || isHTMLMeterElement(toHTMLElement(*m_node)) | 472 || isHTMLMeterElement(toHTMLElement(*m_node)) |
| 471 || isHTMLProgressElement(toHTMLElement(*m_node)))))) { | 473 || isHTMLProgressElement(toHTMLElement(*m_node)))))) { |
| 472 handledNode = handleReplacedElement(); | 474 handledNode = handleReplacedElement(); |
| 473 } else { | 475 } else { |
| 474 handledNode = handleNonTextNode(); | 476 handledNode = handleNonTextNode(); |
| 475 } | 477 } |
| 476 if (handledNode) | 478 if (handledNode) |
| 477 m_iterationProgress = HandledNode; | 479 m_iterationProgress = HandledNode; |
| 478 if (m_positionNode) | 480 if (m_positionNode) |
| 479 return; | 481 return; |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 emitCharacter(',', m_node->parentNode(), m_node, 0, 1); | 824 emitCharacter(',', m_node->parentNode(), m_node, 0, 1); |
| 823 return true; | 825 return true; |
| 824 } | 826 } |
| 825 | 827 |
| 826 m_positionNode = m_node->parentNode(); | 828 m_positionNode = m_node->parentNode(); |
| 827 m_positionOffsetBaseNode = m_node; | 829 m_positionOffsetBaseNode = m_node; |
| 828 m_positionStartOffset = 0; | 830 m_positionStartOffset = 0; |
| 829 m_positionEndOffset = 1; | 831 m_positionEndOffset = 1; |
| 830 m_singleCharacterBuffer = 0; | 832 m_singleCharacterBuffer = 0; |
| 831 | 833 |
| 832 if (m_emitsImageAltText && renderer->isImage() && renderer->isRenderImage()) { | 834 if (m_emitsImageAltText) { |
| 833 m_text = toRenderImage(renderer)->altText(); | 835 bool isTextModified = false; |
| 834 if (!m_text.isEmpty()) { | 836 if (isHTMLImageElement(toElement(*m_node))) { |
| 837 m_text = toHTMLImageElement(m_node)->altText(); | |
| 838 isTextModified = true; | |
| 839 } | |
| 840 | |
| 841 if (!m_text.isEmpty() && isTextModified) { | |
| 835 m_textLength = m_text.length(); | 842 m_textLength = m_text.length(); |
| 836 m_lastCharacter = m_text[m_textLength - 1]; | 843 m_lastCharacter = m_text[m_textLength - 1]; |
| 837 return true; | 844 return true; |
| 838 } | 845 } |
| 839 } | 846 } |
| 840 | 847 |
| 841 m_textLength = 0; | 848 m_textLength = 0; |
| 842 m_lastCharacter = 0; | 849 m_lastCharacter = 0; |
| 843 | 850 |
| 844 return true; | 851 return true; |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1306 m_textLength = 0; | 1313 m_textLength = 0; |
| 1307 | 1314 |
| 1308 while (m_node && !m_havePassedStartNode) { | 1315 while (m_node && !m_havePassedStartNode) { |
| 1309 // Don't handle node if we start iterating at [node, 0]. | 1316 // Don't handle node if we start iterating at [node, 0]. |
| 1310 if (!m_handledNode && !(m_node == m_endNode && !m_endOffset)) { | 1317 if (!m_handledNode && !(m_node == m_endNode && !m_endOffset)) { |
| 1311 RenderObject* renderer = m_node->renderer(); | 1318 RenderObject* renderer = m_node->renderer(); |
| 1312 if (renderer && renderer->isText() && m_node->nodeType() == Node::TE XT_NODE) { | 1319 if (renderer && renderer->isText() && m_node->nodeType() == Node::TE XT_NODE) { |
| 1313 // FIXME: What about CDATA_SECTION_NODE? | 1320 // FIXME: What about CDATA_SECTION_NODE? |
| 1314 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) | 1321 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) |
| 1315 m_handledNode = handleTextNode(); | 1322 m_handledNode = handleTextNode(); |
| 1316 } else if (renderer && (renderer->isImage() || renderer->isWidget()) ) { | 1323 } else if (renderer && (isHTMLImageElement(toElement(*m_node)) || re nderer->isWidget())) { |
|
esprehn
2014/09/05 00:47:50
I think this breaks image inputs, they're also Ren
rhogan
2014/09/08 19:52:41
Done
| |
| 1317 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) | 1324 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) |
| 1318 m_handledNode = handleReplacedElement(); | 1325 m_handledNode = handleReplacedElement(); |
| 1319 } else { | 1326 } else { |
| 1320 m_handledNode = handleNonTextNode(); | 1327 m_handledNode = handleNonTextNode(); |
| 1321 } | 1328 } |
| 1322 if (m_positionNode) | 1329 if (m_positionNode) |
| 1323 return; | 1330 return; |
| 1324 } | 1331 } |
| 1325 | 1332 |
| 1326 if (!m_handledChildren && m_node->hasChildren()) { | 1333 if (!m_handledChildren && m_node->hasChildren()) { |
| (...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2215 resultEnd = collapseTo; | 2222 resultEnd = collapseTo; |
| 2216 return; | 2223 return; |
| 2217 } | 2224 } |
| 2218 } | 2225 } |
| 2219 | 2226 |
| 2220 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo rFindPlainText); | 2227 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo rFindPlainText); |
| 2221 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re sultStart, resultEnd); | 2228 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re sultStart, resultEnd); |
| 2222 } | 2229 } |
| 2223 | 2230 |
| 2224 } | 2231 } |
| OLD | NEW |