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

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

Issue 571603003: Convert first letter into a pseudo element. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase to master 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
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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) { 782 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) {
783 if (child->nodeType() == Node::TEXT_NODE && child->renderer()) 783 if (child->nodeType() == Node::TEXT_NODE && child->renderer())
784 textNodes.append(toText(child)); 784 textNodes.append(toText(child));
785 } 785 }
786 } 786 }
787 787
788 HashCountedSet<String> fontStats; 788 HashCountedSet<String> fontStats;
789 for (size_t i = 0; i < textNodes.size(); ++i) { 789 for (size_t i = 0; i < textNodes.size(); ++i) {
790 RenderText* renderer = textNodes[i]->renderer(); 790 RenderText* renderer = textNodes[i]->renderer();
791 collectPlatformFontsForRenderer(renderer, &fontStats); 791 collectPlatformFontsForRenderer(renderer, &fontStats);
792 if (renderer->isTextFragment()) { 792
793 RenderTextFragment* textFragment = toRenderTextFragment(renderer); 793 if (!renderer->isTextFragment())
794 if (textFragment->firstLetter()) { 794 continue;
795 RenderBoxModelObject* firstLetter = textFragment->firstLetter(); 795
796 for (RenderObject* current = firstLetter->slowFirstChild(); curr ent; current = current->nextSibling()) { 796 // If we're the remaining text from a first-letter then our previous
797 if (current->isText()) 797 // sibling has to be the first-letter renderer.
798 collectPlatformFontsForRenderer(toRenderText(current), & fontStats); 798 RenderObject* previous = renderer->previousSibling();
799 } 799 if (!previous)
800 } 800 continue;
801 } 801
802 if (!previous->isPseudoElement() || !previous->node()->isFirstLetterPseu doElement())
803 continue;
804
805 // The first-letter pseudoElement only has one child, which is the
806 // first-letter renderer.
807 RenderObject* firstLetterRenderer = previous->slowFirstChild();
808 ASSERT(firstLetterRenderer && firstLetterRenderer->isText());
Julien - ping for review 2014/10/09 18:24:48 toRenderText will also check for isText but in rel
dsinclair 2014/10/09 21:14:22 Done (removed the assert). So, in general, is: A
Julien - ping for review 2014/10/10 14:47:07 From my perspective yes because if ASSERT(firstLet
dsinclair 2014/10/10 18:06:53 Acknowledged.
809 collectPlatformFontsForRenderer(toRenderText(firstLetterRenderer), &font Stats);
802 } 810 }
803 811
804 platformFonts = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>::cre ate(); 812 platformFonts = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>::cre ate();
805 for (HashCountedSet<String>::iterator it = fontStats.begin(), end = fontStat s.end(); it != end; ++it) { 813 for (HashCountedSet<String>::iterator it = fontStats.begin(), end = fontStat s.end(); it != end; ++it) {
806 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder:: CSS::PlatformFontUsage::create() 814 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder:: CSS::PlatformFontUsage::create()
807 .setFamilyName(it->key) 815 .setFamilyName(it->key)
808 .setGlyphCount(it->value); 816 .setGlyphCount(it->value);
809 platformFonts->addItem(platformFont); 817 platformFonts->addItem(platformFont);
810 } 818 }
811 } 819 }
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 visitor->trace(m_invalidatedDocuments); 1480 visitor->trace(m_invalidatedDocuments);
1473 visitor->trace(m_nodeToInspectorStyleSheet); 1481 visitor->trace(m_nodeToInspectorStyleSheet);
1474 visitor->trace(m_documentToViaInspectorStyleSheet); 1482 visitor->trace(m_documentToViaInspectorStyleSheet);
1475 #endif 1483 #endif
1476 visitor->trace(m_inspectorUserAgentStyleSheet); 1484 visitor->trace(m_inspectorUserAgentStyleSheet);
1477 InspectorBaseAgent::trace(visitor); 1485 InspectorBaseAgent::trace(visitor);
1478 } 1486 }
1479 1487
1480 } // namespace blink 1488 } // namespace blink
1481 1489
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698