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 20 matching lines...) Expand all Loading... |
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/FirstLetterPseudoElement.h" | 33 #include "core/dom/FirstLetterPseudoElement.h" |
34 #include "core/dom/NodeTraversal.h" | 34 #include "core/dom/NodeTraversal.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/frame/FrameView.h" | 39 #include "core/frame/FrameView.h" |
40 #include "core/html/HTMLElement.h" | 40 #include "core/html/HTMLElement.h" |
| 41 #include "core/html/HTMLImageElement.h" |
| 42 #include "core/html/HTMLInputElement.h" |
41 #include "core/html/HTMLTextFormControlElement.h" | 43 #include "core/html/HTMLTextFormControlElement.h" |
42 #include "core/rendering/InlineTextBox.h" | 44 #include "core/rendering/InlineTextBox.h" |
43 #include "core/rendering/RenderImage.h" | 45 #include "core/rendering/RenderImage.h" |
44 #include "core/rendering/RenderTableCell.h" | 46 #include "core/rendering/RenderTableCell.h" |
45 #include "core/rendering/RenderTableRow.h" | 47 #include "core/rendering/RenderTableRow.h" |
46 #include "core/rendering/RenderTextControl.h" | 48 #include "core/rendering/RenderTextControl.h" |
47 #include "core/rendering/RenderTextFragment.h" | 49 #include "core/rendering/RenderTextFragment.h" |
48 #include "platform/fonts/Character.h" | 50 #include "platform/fonts/Character.h" |
49 #include "platform/fonts/Font.h" | 51 #include "platform/fonts/Font.h" |
50 #include "platform/text/TextBoundaries.h" | 52 #include "platform/text/TextBoundaries.h" |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 465 |
464 // Handle the current node according to its type. | 466 // Handle the current node according to its type. |
465 if (m_iterationProgress < HandledNode) { | 467 if (m_iterationProgress < HandledNode) { |
466 bool handledNode = false; | 468 bool handledNode = false; |
467 if (renderer->isText() && m_node->nodeType() == Node::TEXT_NODE)
{ // FIXME: What about CDATA_SECTION_NODE? | 469 if (renderer->isText() && m_node->nodeType() == Node::TEXT_NODE)
{ // FIXME: What about CDATA_SECTION_NODE? |
468 handledNode = handleTextNode(); | 470 handledNode = handleTextNode(); |
469 } else if (renderer && (renderer->isImage() || renderer->isRende
rPart() | 471 } else if (renderer && (renderer->isImage() || renderer->isRende
rPart() |
470 || (m_node && m_node->isHTMLElement() | 472 || (m_node && m_node->isHTMLElement() |
471 && (isHTMLFormControlElement(toHTMLElement(*m_node)) | 473 && (isHTMLFormControlElement(toHTMLElement(*m_node)) |
472 || isHTMLLegendElement(toHTMLElement(*m_node)) | 474 || isHTMLLegendElement(toHTMLElement(*m_node)) |
| 475 || isHTMLImageElement(toElement(*m_node)) |
473 || isHTMLMeterElement(toHTMLElement(*m_node)) | 476 || isHTMLMeterElement(toHTMLElement(*m_node)) |
474 || isHTMLProgressElement(toHTMLElement(*m_node)))))) { | 477 || isHTMLProgressElement(toHTMLElement(*m_node)))))) { |
475 handledNode = handleReplacedElement(); | 478 handledNode = handleReplacedElement(); |
476 } else { | 479 } else { |
477 handledNode = handleNonTextNode(); | 480 handledNode = handleNonTextNode(); |
478 } | 481 } |
479 if (handledNode) | 482 if (handledNode) |
480 m_iterationProgress = HandledNode; | 483 m_iterationProgress = HandledNode; |
481 if (m_positionNode) | 484 if (m_positionNode) |
482 return; | 485 return; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 emitCharacter(',', m_node->parentNode(), m_node, 0, 1); | 825 emitCharacter(',', m_node->parentNode(), m_node, 0, 1); |
823 return true; | 826 return true; |
824 } | 827 } |
825 | 828 |
826 m_positionNode = m_node->parentNode(); | 829 m_positionNode = m_node->parentNode(); |
827 m_positionOffsetBaseNode = m_node; | 830 m_positionOffsetBaseNode = m_node; |
828 m_positionStartOffset = 0; | 831 m_positionStartOffset = 0; |
829 m_positionEndOffset = 1; | 832 m_positionEndOffset = 1; |
830 m_singleCharacterBuffer = 0; | 833 m_singleCharacterBuffer = 0; |
831 | 834 |
832 if (m_emitsImageAltText && renderer->isImage() && renderer->isRenderImage())
{ | 835 if (m_emitsImageAltText) { |
833 m_text = toRenderImage(renderer)->altText(); | 836 m_text = toHTMLElement(m_node)->altText(); |
834 if (!m_text.isEmpty()) { | 837 if (!m_text.isEmpty()) { |
835 m_textLength = m_text.length(); | 838 m_textLength = m_text.length(); |
836 m_lastCharacter = m_text[m_textLength - 1]; | 839 m_lastCharacter = m_text[m_textLength - 1]; |
837 return true; | 840 return true; |
838 } | 841 } |
839 } | 842 } |
840 | 843 |
841 m_textLength = 0; | 844 m_textLength = 0; |
842 m_lastCharacter = 0; | 845 m_lastCharacter = 0; |
843 | 846 |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 m_textLength = 0; | 1407 m_textLength = 0; |
1405 | 1408 |
1406 while (m_node && !m_havePassedStartNode) { | 1409 while (m_node && !m_havePassedStartNode) { |
1407 // Don't handle node if we start iterating at [node, 0]. | 1410 // Don't handle node if we start iterating at [node, 0]. |
1408 if (!m_handledNode && !(m_node == m_endNode && !m_endOffset)) { | 1411 if (!m_handledNode && !(m_node == m_endNode && !m_endOffset)) { |
1409 RenderObject* renderer = m_node->renderer(); | 1412 RenderObject* renderer = m_node->renderer(); |
1410 if (renderer && renderer->isText() && m_node->nodeType() == Node::TE
XT_NODE) { | 1413 if (renderer && renderer->isText() && m_node->nodeType() == Node::TE
XT_NODE) { |
1411 // FIXME: What about CDATA_SECTION_NODE? | 1414 // FIXME: What about CDATA_SECTION_NODE? |
1412 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) | 1415 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) |
1413 m_handledNode = handleTextNode(); | 1416 m_handledNode = handleTextNode(); |
1414 } else if (renderer && (renderer->isImage() || renderer->isRenderPar
t())) { | 1417 } else if (renderer && (isHTMLImageElement(toElement(*m_node)) || is
HTMLInputElement(toElement(*m_node)) || renderer->isRenderPart())) { |
1415 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) | 1418 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) |
1416 m_handledNode = handleReplacedElement(); | 1419 m_handledNode = handleReplacedElement(); |
1417 } else { | 1420 } else { |
1418 m_handledNode = handleNonTextNode(); | 1421 m_handledNode = handleNonTextNode(); |
1419 } | 1422 } |
1420 if (m_positionNode) | 1423 if (m_positionNode) |
1421 return; | 1424 return; |
1422 } | 1425 } |
1423 | 1426 |
1424 if (!m_handledChildren && m_node->hasChildren()) { | 1427 if (!m_handledChildren && m_node->hasChildren()) { |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2430 resultEnd = collapseTo; | 2433 resultEnd = collapseTo; |
2431 return; | 2434 return; |
2432 } | 2435 } |
2433 } | 2436 } |
2434 | 2437 |
2435 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo
rFindPlainText); | 2438 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo
rFindPlainText); |
2436 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re
sultStart, resultEnd); | 2439 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re
sultStart, resultEnd); |
2437 } | 2440 } |
2438 | 2441 |
2439 } | 2442 } |
OLD | NEW |