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

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

Issue 22903030: DevTools: CSS.getPlatformFontsForNode to return a cssFamilyName as well (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed description Created 7 years, 4 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/inspector/InspectorCSSAgent.h ('k') | Source/devtools/protocol.json » ('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 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 it.advance(run.length(), &glyphBuffer); 1058 it.advance(run.length(), &glyphBuffer);
1059 for (int i = 0; i < glyphBuffer.size(); ++i) { 1059 for (int i = 0; i < glyphBuffer.size(); ++i) {
1060 String familyName = glyphBuffer.fontDataAt(i)->platformData().fontFa milyName(); 1060 String familyName = glyphBuffer.fontDataAt(i)->platformData().fontFa milyName();
1061 int value = fontStats->contains(familyName) ? fontStats->get(familyN ame) : 0; 1061 int value = fontStats->contains(familyName) ? fontStats->get(familyN ame) : 0;
1062 fontStats->set(familyName, value + 1); 1062 fontStats->set(familyName, value + 1);
1063 } 1063 }
1064 } 1064 }
1065 } 1065 }
1066 1066
1067 void InspectorCSSAgent::getPlatformFontsForNode(ErrorString* errorString, int no deId, 1067 void InspectorCSSAgent::getPlatformFontsForNode(ErrorString* errorString, int no deId,
1068 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage> >& platformFo ntUsage) 1068 String* cssFamilyName, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PlatformF ontUsage> >& platformFonts)
1069 { 1069 {
1070 Node* node = m_domAgent->assertNode(errorString, nodeId); 1070 Node* node = m_domAgent->assertNode(errorString, nodeId);
1071 if (!node) 1071 if (!node)
1072 return; 1072 return;
1073
1074 RefPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSComputedStyleDecl aration::create(node, true);
1075 *cssFamilyName = computedStyleInfo->getPropertyValue(CSSPropertyFontFamily);
1076
1073 Vector<Node*> textNodes; 1077 Vector<Node*> textNodes;
1074 if (node->nodeType() == Node::TEXT_NODE) { 1078 if (node->nodeType() == Node::TEXT_NODE) {
1075 if (node->renderer()) 1079 if (node->renderer())
1076 textNodes.append(node); 1080 textNodes.append(node);
1077 } else { 1081 } else {
1078 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) { 1082 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) {
1079 if (child->nodeType() == Node::TEXT_NODE && child->renderer()) 1083 if (child->nodeType() == Node::TEXT_NODE && child->renderer())
1080 textNodes.append(child); 1084 textNodes.append(child);
1081 } 1085 }
1082 } 1086 }
1083 1087
1084 HashMap<String, int> fontStats; 1088 HashMap<String, int> fontStats;
1085 for (size_t i = 0; i < textNodes.size(); ++i) { 1089 for (size_t i = 0; i < textNodes.size(); ++i) {
1086 RenderText* renderer = toRenderText(textNodes[i]->renderer()); 1090 RenderText* renderer = toRenderText(textNodes[i]->renderer());
1087 collectPlatformFontsForRenderer(renderer, &fontStats); 1091 collectPlatformFontsForRenderer(renderer, &fontStats);
1088 if (renderer->isTextFragment()) { 1092 if (renderer->isTextFragment()) {
1089 RenderTextFragment* textFragment = toRenderTextFragment(renderer); 1093 RenderTextFragment* textFragment = toRenderTextFragment(renderer);
1090 if (textFragment->firstLetter()) { 1094 if (textFragment->firstLetter()) {
1091 RenderObject* firstLetter = textFragment->firstLetter(); 1095 RenderObject* firstLetter = textFragment->firstLetter();
1092 for (RenderObject* current = firstLetter->firstChild(); current; current = current->nextSibling()) { 1096 for (RenderObject* current = firstLetter->firstChild(); current; current = current->nextSibling()) {
1093 if (current->isText()) 1097 if (current->isText())
1094 collectPlatformFontsForRenderer(toRenderText(current), & fontStats); 1098 collectPlatformFontsForRenderer(toRenderText(current), & fontStats);
1095 } 1099 }
1096 } 1100 }
1097 } 1101 }
1098 } 1102 }
1099 1103
1100 platformFontUsage = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>: :create(); 1104 platformFonts = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>::cre ate();
1101 for (HashMap<String, int>::iterator it = fontStats.begin(), end = fontStats. end(); it != end; ++it) { 1105 for (HashMap<String, int>::iterator it = fontStats.begin(), end = fontStats. end(); it != end; ++it) {
1102 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder:: CSS::PlatformFontUsage::create() 1106 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder:: CSS::PlatformFontUsage::create()
1103 .setFamilyName(it->key) 1107 .setFamilyName(it->key)
1104 .setGlyphCount(it->value); 1108 .setGlyphCount(it->value);
1105 platformFontUsage->addItem(platformFont); 1109 platformFonts->addItem(platformFont);
1106 } 1110 }
1107 } 1111 }
1108 1112
1109 void InspectorCSSAgent::getAllStyleSheets(ErrorString*, RefPtr<TypeBuilder::Arra y<TypeBuilder::CSS::CSSStyleSheetHeader> >& styleInfos) 1113 void InspectorCSSAgent::getAllStyleSheets(ErrorString*, RefPtr<TypeBuilder::Arra y<TypeBuilder::CSS::CSSStyleSheetHeader> >& styleInfos)
1110 { 1114 {
1111 styleInfos = TypeBuilder::Array<TypeBuilder::CSS::CSSStyleSheetHeader>::crea te(); 1115 styleInfos = TypeBuilder::Array<TypeBuilder::CSS::CSSStyleSheetHeader>::crea te();
1112 Vector<InspectorStyleSheet*> styleSheets; 1116 Vector<InspectorStyleSheet*> styleSheets;
1113 collectAllStyleSheets(styleSheets); 1117 collectAllStyleSheets(styleSheets);
1114 for (size_t i = 0; i < styleSheets.size(); ++i) 1118 for (size_t i = 0; i < styleSheets.size(); ++i)
1115 styleInfos->addItem(styleSheets.at(i)->buildObjectForStyleSheetInfo()); 1119 styleInfos->addItem(styleSheets.at(i)->buildObjectForStyleSheetInfo());
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 documentsToChange.add(element->ownerDocument()); 1777 documentsToChange.add(element->ownerDocument());
1774 } 1778 }
1775 1779
1776 m_nodeIdToForcedPseudoState.clear(); 1780 m_nodeIdToForcedPseudoState.clear();
1777 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1781 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1778 (*it)->setNeedsStyleRecalc(); 1782 (*it)->setNeedsStyleRecalc();
1779 } 1783 }
1780 1784
1781 } // namespace WebCore 1785 } // namespace WebCore
1782 1786
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.h ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698