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

Side by Side Diff: Source/core/inspector/InspectorCSSAgent.cpp

Issue 672953002: Convert first letter into a pseudo element. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
« no previous file with comments | « Source/core/editing/TextIterator.cpp ('k') | Source/core/rendering/HitTestResult.h » ('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) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) { 786 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) {
787 if (child->nodeType() == Node::TEXT_NODE && child->renderer()) 787 if (child->nodeType() == Node::TEXT_NODE && child->renderer())
788 textNodes.append(toText(child)); 788 textNodes.append(toText(child));
789 } 789 }
790 } 790 }
791 791
792 HashCountedSet<String> fontStats; 792 HashCountedSet<String> fontStats;
793 for (size_t i = 0; i < textNodes.size(); ++i) { 793 for (size_t i = 0; i < textNodes.size(); ++i) {
794 RenderText* renderer = textNodes[i]->renderer(); 794 RenderText* renderer = textNodes[i]->renderer();
795 collectPlatformFontsForRenderer(renderer, &fontStats); 795 collectPlatformFontsForRenderer(renderer, &fontStats);
796 if (renderer->isTextFragment()) { 796
797 RenderTextFragment* textFragment = toRenderTextFragment(renderer); 797 if (!renderer->isTextFragment())
798 if (textFragment->firstLetter()) { 798 continue;
799 RenderBoxModelObject* firstLetter = textFragment->firstLetter(); 799
800 for (RenderObject* current = firstLetter->slowFirstChild(); curr ent; current = current->nextSibling()) { 800 // If we're the remaining text from a first-letter then our previous
801 if (current->isText()) 801 // sibling has to be the first-letter renderer.
802 collectPlatformFontsForRenderer(toRenderText(current), & fontStats); 802 RenderObject* previous = renderer->previousSibling();
803 } 803 if (!previous)
804 } 804 continue;
805 } 805
806 if (!previous->isPseudoElement() || !previous->node()->isFirstLetterPseu doElement())
807 continue;
808
809 // The first-letter pseudoElement only has one child, which is the
810 // first-letter renderer.
811 collectPlatformFontsForRenderer(toRenderText(previous->slowFirstChild()) , &fontStats);
806 } 812 }
807 813
808 platformFonts = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>::cre ate(); 814 platformFonts = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>::cre ate();
809 for (HashCountedSet<String>::iterator it = fontStats.begin(), end = fontStat s.end(); it != end; ++it) { 815 for (HashCountedSet<String>::iterator it = fontStats.begin(), end = fontStat s.end(); it != end; ++it) {
810 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder:: CSS::PlatformFontUsage::create() 816 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder:: CSS::PlatformFontUsage::create()
811 .setFamilyName(it->key) 817 .setFamilyName(it->key)
812 .setGlyphCount(it->value); 818 .setGlyphCount(it->value);
813 platformFonts->addItem(platformFont); 819 platformFonts->addItem(platformFont);
814 } 820 }
815 } 821 }
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 visitor->trace(m_invalidatedDocuments); 1483 visitor->trace(m_invalidatedDocuments);
1478 visitor->trace(m_nodeToInspectorStyleSheet); 1484 visitor->trace(m_nodeToInspectorStyleSheet);
1479 visitor->trace(m_documentToViaInspectorStyleSheet); 1485 visitor->trace(m_documentToViaInspectorStyleSheet);
1480 #endif 1486 #endif
1481 visitor->trace(m_inspectorUserAgentStyleSheet); 1487 visitor->trace(m_inspectorUserAgentStyleSheet);
1482 InspectorBaseAgent::trace(visitor); 1488 InspectorBaseAgent::trace(visitor);
1483 } 1489 }
1484 1490
1485 } // namespace blink 1491 } // namespace blink
1486 1492
OLDNEW
« no previous file with comments | « Source/core/editing/TextIterator.cpp ('k') | Source/core/rendering/HitTestResult.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698