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

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

Issue 639863006: Revert of Convert first letter into a pseudo element. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months 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
« no previous file with comments | « Source/core/dom/RenderTreeBuilder.cpp ('k') | Source/core/inspector/InspectorCSSAgent.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 12 matching lines...) Expand all
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/editing/TextIterator.h" 28 #include "core/editing/TextIterator.h"
29 29
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/FirstLetterPseudoElement.h"
34 #include "core/dom/NodeTraversal.h" 33 #include "core/dom/NodeTraversal.h"
35 #include "core/dom/shadow/ShadowRoot.h" 34 #include "core/dom/shadow/ShadowRoot.h"
36 #include "core/editing/VisiblePosition.h" 35 #include "core/editing/VisiblePosition.h"
37 #include "core/editing/VisibleUnits.h" 36 #include "core/editing/VisibleUnits.h"
38 #include "core/editing/htmlediting.h" 37 #include "core/editing/htmlediting.h"
39 #include "core/frame/FrameView.h" 38 #include "core/frame/FrameView.h"
40 #include "core/html/HTMLElement.h" 39 #include "core/html/HTMLElement.h"
41 #include "core/html/HTMLTextFormControlElement.h" 40 #include "core/html/HTMLTextFormControlElement.h"
42 #include "core/rendering/InlineTextBox.h" 41 #include "core/rendering/InlineTextBox.h"
43 #include "core/rendering/RenderImage.h" 42 #include "core/rendering/RenderImage.h"
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 } 754 }
756 if (!m_textBox && m_remainingTextBox) { 755 if (!m_textBox && m_remainingTextBox) {
757 m_textBox = m_remainingTextBox; 756 m_textBox = m_remainingTextBox;
758 m_remainingTextBox = 0; 757 m_remainingTextBox = 0;
759 m_firstLetterText = nullptr; 758 m_firstLetterText = nullptr;
760 m_offset = 0; 759 m_offset = 0;
761 handleTextBox(); 760 handleTextBox();
762 } 761 }
763 } 762 }
764 763
764 static inline RenderText* firstRenderTextInFirstLetter(RenderBoxModelObject* fir stLetter)
765 {
766 if (!firstLetter)
767 return 0;
768
769 // FIXME: Should this check descendent objects?
770 for (RenderObject* current = firstLetter->slowFirstChild(); current; current = current->nextSibling()) {
771 if (current->isText())
772 return toRenderText(current);
773 }
774 return 0;
775 }
776
765 void TextIterator::handleTextNodeFirstLetter(RenderTextFragment* renderer) 777 void TextIterator::handleTextNodeFirstLetter(RenderTextFragment* renderer)
766 { 778 {
779 if (renderer->firstLetter()) {
780 RenderBoxModelObject* r = renderer->firstLetter();
781 if (r->style()->visibility() != VISIBLE && !m_ignoresStyleVisibility)
782 return;
783 if (RenderText* firstLetter = firstRenderTextInFirstLetter(r)) {
784 m_handledFirstLetter = true;
785 m_remainingTextBox = m_textBox;
786 m_textBox = firstLetter->firstTextBox();
787 m_sortedTextBoxes.clear();
788 m_firstLetterText = firstLetter;
789 }
790 }
767 m_handledFirstLetter = true; 791 m_handledFirstLetter = true;
768
769 if (!renderer->isRemainingTextRenderer())
770 return;
771
772 FirstLetterPseudoElement* firstLetterElement = renderer->firstLetterPseudoEl ement();
773 if (!firstLetterElement)
774 return;
775
776 RenderObject* pseudoRenderer = firstLetterElement->renderer();
777 if (pseudoRenderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisib ility)
778 return;
779
780 RenderObject* firstLetter = pseudoRenderer->slowFirstChild();
781 ASSERT(firstLetter);
782
783 m_remainingTextBox = m_textBox;
784 m_textBox = toRenderText(firstLetter)->firstTextBox();
785 m_sortedTextBoxes.clear();
786 m_firstLetterText = toRenderText(firstLetter);
787 } 792 }
788 793
789 bool TextIterator::handleReplacedElement() 794 bool TextIterator::handleReplacedElement()
790 { 795 {
791 if (m_fullyClippedStack.top()) 796 if (m_fullyClippedStack.top())
792 return false; 797 return false;
793 798
794 RenderObject* renderer = m_node->renderer(); 799 RenderObject* renderer = m_node->renderer();
795 if (renderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisibility) 800 if (renderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisibility)
796 return false; 801 return false;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 m_textLength = 0; 843 m_textLength = 0;
839 m_lastCharacter = 0; 844 m_lastCharacter = 0;
840 845
841 return true; 846 return true;
842 } 847 }
843 848
844 bool TextIterator::hasVisibleTextNode(RenderText* renderer) 849 bool TextIterator::hasVisibleTextNode(RenderText* renderer)
845 { 850 {
846 if (renderer->style()->visibility() == VISIBLE) 851 if (renderer->style()->visibility() == VISIBLE)
847 return true; 852 return true;
848 853 if (renderer->isTextFragment()) {
849 if (!renderer->isTextFragment()) 854 RenderTextFragment* fragment = toRenderTextFragment(renderer);
850 return false; 855 if (fragment->firstLetter() && fragment->firstLetter()->style()->visibil ity() == VISIBLE)
851 856 return true;
852 RenderTextFragment* fragment = toRenderTextFragment(renderer); 857 }
853 if (!fragment->isRemainingTextRenderer())
854 return false;
855
856 RenderObject* pseudoElementRenderer = fragment->firstLetterPseudoElement()-> renderer();
857 if (pseudoElementRenderer && pseudoElementRenderer->style()->visibility() == VISIBLE)
858 return true;
859
860 return false; 858 return false;
861 } 859 }
862 860
863 static bool shouldEmitTabBeforeNode(Node* node) 861 static bool shouldEmitTabBeforeNode(Node* node)
864 { 862 {
865 RenderObject* r = node->renderer(); 863 RenderObject* r = node->renderer();
866 864
867 // Table cells are delimited by tabs. 865 // Table cells are delimited by tabs.
868 if (!r || !isTableCell(node)) 866 if (!r || !isTableCell(node))
869 return false; 867 return false;
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 } 1521 }
1524 1522
1525 if (!m_shouldHandleFirstLetter && offsetAfterFirstLetter < m_offset) { 1523 if (!m_shouldHandleFirstLetter && offsetAfterFirstLetter < m_offset) {
1526 m_shouldHandleFirstLetter = true; 1524 m_shouldHandleFirstLetter = true;
1527 offsetInNode = offsetAfterFirstLetter; 1525 offsetInNode = offsetAfterFirstLetter;
1528 return renderer; 1526 return renderer;
1529 } 1527 }
1530 1528
1531 m_shouldHandleFirstLetter = false; 1529 m_shouldHandleFirstLetter = false;
1532 offsetInNode = 0; 1530 offsetInNode = 0;
1533 1531 RenderText* firstLetterRenderer = firstRenderTextInFirstLetter(fragment->fir stLetter());
1534 ASSERT(fragment->isRemainingTextRenderer());
1535 ASSERT(fragment->firstLetterPseudoElement());
1536
1537 RenderObject* pseudoElementRenderer = fragment->firstLetterPseudoElement()-> renderer();
1538 ASSERT(pseudoElementRenderer);
1539 ASSERT(pseudoElementRenderer->slowFirstChild());
1540 RenderText* firstLetterRenderer = toRenderText(pseudoElementRenderer->slowFi rstChild());
1541 1532
1542 m_offset = firstLetterRenderer->caretMaxOffset(); 1533 m_offset = firstLetterRenderer->caretMaxOffset();
1543 m_offset += collapsedSpaceLength(firstLetterRenderer, m_offset); 1534 m_offset += collapsedSpaceLength(firstLetterRenderer, m_offset);
1544 1535
1545 return firstLetterRenderer; 1536 return firstLetterRenderer;
1546 } 1537 }
1547 1538
1548 bool SimplifiedBackwardsTextIterator::handleReplacedElement() 1539 bool SimplifiedBackwardsTextIterator::handleReplacedElement()
1549 { 1540 {
1550 unsigned index = m_node->nodeIndex(); 1541 unsigned index = m_node->nodeIndex();
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 resultEnd = collapseTo; 2421 resultEnd = collapseTo;
2431 return; 2422 return;
2432 } 2423 }
2433 } 2424 }
2434 2425
2435 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo rFindPlainText); 2426 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo rFindPlainText);
2436 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re sultStart, resultEnd); 2427 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re sultStart, resultEnd);
2437 } 2428 }
2438 2429
2439 } 2430 }
OLDNEW
« no previous file with comments | « Source/core/dom/RenderTreeBuilder.cpp ('k') | Source/core/inspector/InspectorCSSAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698