Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: Source/core/editing/TextIterator.cpp

Issue 481753002: Use Shadow DOM to display fallback content for images (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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"
41 #include "core/html/HTMLInputElement.h"
40 #include "core/html/HTMLTextFormControlElement.h" 42 #include "core/html/HTMLTextFormControlElement.h"
41 #include "core/rendering/InlineTextBox.h" 43 #include "core/rendering/InlineTextBox.h"
42 #include "core/rendering/RenderImage.h" 44 #include "core/rendering/RenderImage.h"
43 #include "core/rendering/RenderTableCell.h" 45 #include "core/rendering/RenderTableCell.h"
44 #include "core/rendering/RenderTableRow.h" 46 #include "core/rendering/RenderTableRow.h"
45 #include "core/rendering/RenderTextControl.h" 47 #include "core/rendering/RenderTextControl.h"
46 #include "core/rendering/RenderTextFragment.h" 48 #include "core/rendering/RenderTextFragment.h"
47 #include "platform/fonts/Character.h" 49 #include "platform/fonts/Character.h"
48 #include "platform/fonts/Font.h" 50 #include "platform/fonts/Font.h"
49 #include "platform/text/TextBoundaries.h" 51 #include "platform/text/TextBoundaries.h"
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 464
463 // Handle the current node according to its type. 465 // Handle the current node according to its type.
464 if (m_iterationProgress < HandledNode) { 466 if (m_iterationProgress < HandledNode) {
465 bool handledNode = false; 467 bool handledNode = false;
466 if (renderer->isText() && m_node->nodeType() == Node::TEXT_NODE) { // FIXME: What about CDATA_SECTION_NODE? 468 if (renderer->isText() && m_node->nodeType() == Node::TEXT_NODE) { // FIXME: What about CDATA_SECTION_NODE?
467 handledNode = handleTextNode(); 469 handledNode = handleTextNode();
468 } else if (renderer && (renderer->isImage() || renderer->isRende rPart() 470 } else if (renderer && (renderer->isImage() || renderer->isRende rPart()
469 || (m_node && m_node->isHTMLElement() 471 || (m_node && m_node->isHTMLElement()
470 && (isHTMLFormControlElement(toHTMLElement(*m_node)) 472 && (isHTMLFormControlElement(toHTMLElement(*m_node))
471 || isHTMLLegendElement(toHTMLElement(*m_node)) 473 || isHTMLLegendElement(toHTMLElement(*m_node))
474 || isHTMLImageElement(toElement(*m_node))
472 || isHTMLMeterElement(toHTMLElement(*m_node)) 475 || isHTMLMeterElement(toHTMLElement(*m_node))
473 || isHTMLProgressElement(toHTMLElement(*m_node)))))) { 476 || isHTMLProgressElement(toHTMLElement(*m_node)))))) {
474 handledNode = handleReplacedElement(); 477 handledNode = handleReplacedElement();
475 } else { 478 } else {
476 handledNode = handleNonTextNode(); 479 handledNode = handleNonTextNode();
477 } 480 }
478 if (handledNode) 481 if (handledNode)
479 m_iterationProgress = HandledNode; 482 m_iterationProgress = HandledNode;
480 if (m_positionNode) 483 if (m_positionNode)
481 return; 484 return;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 emitCharacter(',', m_node->parentNode(), m_node, 0, 1); 827 emitCharacter(',', m_node->parentNode(), m_node, 0, 1);
825 return true; 828 return true;
826 } 829 }
827 830
828 m_positionNode = m_node->parentNode(); 831 m_positionNode = m_node->parentNode();
829 m_positionOffsetBaseNode = m_node; 832 m_positionOffsetBaseNode = m_node;
830 m_positionStartOffset = 0; 833 m_positionStartOffset = 0;
831 m_positionEndOffset = 1; 834 m_positionEndOffset = 1;
832 m_singleCharacterBuffer = 0; 835 m_singleCharacterBuffer = 0;
833 836
834 if (m_emitsImageAltText && renderer->isImage() && renderer->isRenderImage()) { 837 if (m_emitsImageAltText) {
835 m_text = toRenderImage(renderer)->altText(); 838 m_text = toHTMLElement(m_node)->altText();
836 if (!m_text.isEmpty()) { 839 if (!m_text.isEmpty()) {
837 m_textLength = m_text.length(); 840 m_textLength = m_text.length();
838 m_lastCharacter = m_text[m_textLength - 1]; 841 m_lastCharacter = m_text[m_textLength - 1];
839 return true; 842 return true;
840 } 843 }
841 } 844 }
842 845
843 m_textLength = 0; 846 m_textLength = 0;
844 m_lastCharacter = 0; 847 m_lastCharacter = 0;
845 848
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 m_textLength = 0; 1405 m_textLength = 0;
1403 1406
1404 while (m_node && !m_havePassedStartNode) { 1407 while (m_node && !m_havePassedStartNode) {
1405 // Don't handle node if we start iterating at [node, 0]. 1408 // Don't handle node if we start iterating at [node, 0].
1406 if (!m_handledNode && !(m_node == m_endNode && !m_endOffset)) { 1409 if (!m_handledNode && !(m_node == m_endNode && !m_endOffset)) {
1407 RenderObject* renderer = m_node->renderer(); 1410 RenderObject* renderer = m_node->renderer();
1408 if (renderer && renderer->isText() && m_node->nodeType() == Node::TE XT_NODE) { 1411 if (renderer && renderer->isText() && m_node->nodeType() == Node::TE XT_NODE) {
1409 // FIXME: What about CDATA_SECTION_NODE? 1412 // FIXME: What about CDATA_SECTION_NODE?
1410 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) 1413 if (renderer->style()->visibility() == VISIBLE && m_offset > 0)
1411 m_handledNode = handleTextNode(); 1414 m_handledNode = handleTextNode();
1412 } else if (renderer && (renderer->isImage() || renderer->isRenderPar t())) { 1415 } else if (renderer && (isHTMLImageElement(toElement(*m_node)) || is HTMLInputElement(toElement(*m_node)) || renderer->isRenderPart())) {
1413 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) 1416 if (renderer->style()->visibility() == VISIBLE && m_offset > 0)
1414 m_handledNode = handleReplacedElement(); 1417 m_handledNode = handleReplacedElement();
1415 } else { 1418 } else {
1416 m_handledNode = handleNonTextNode(); 1419 m_handledNode = handleNonTextNode();
1417 } 1420 }
1418 if (m_positionNode) 1421 if (m_positionNode)
1419 return; 1422 return;
1420 } 1423 }
1421 1424
1422 if (!m_handledChildren && m_node->hasChildren()) { 1425 if (!m_handledChildren && m_node->hasChildren()) {
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
2421 resultEnd = collapseTo; 2424 resultEnd = collapseTo;
2422 return; 2425 return;
2423 } 2426 }
2424 } 2427 }
2425 2428
2426 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo rFindPlainText); 2429 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo rFindPlainText);
2427 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re sultStart, resultEnd); 2430 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re sultStart, resultEnd);
2428 } 2431 }
2429 2432
2430 } 2433 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698