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

Unified Diff: Source/core/inspector/InspectorCSSAgent.cpp

Issue 1187073016: DevTools: generalize getPlatformFonts code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: do not dump cssFamilyFontName Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorCSSAgent.cpp
diff --git a/Source/core/inspector/InspectorCSSAgent.cpp b/Source/core/inspector/InspectorCSSAgent.cpp
index add99dd018b139cc675514dc7b515949873874f8..96b6d655c22acea4700dd88f0819a663f9526267 100644
--- a/Source/core/inspector/InspectorCSSAgent.cpp
+++ b/Source/core/inspector/InspectorCSSAgent.cpp
@@ -798,10 +798,13 @@ void InspectorCSSAgent::getComputedStyleForNode(ErrorString* errorString, int no
style = inspectorStyle->buildArrayForComputedStyle();
}
-void InspectorCSSAgent::collectPlatformFontsForLayoutObject(LayoutText* layoutObject, HashCountedSet<String>* fontStats)
+void InspectorCSSAgent::collectPlatformFontsForLayoutObject(LayoutObject* layoutObject, HashCountedSet<String>* fontStats)
{
- for (InlineTextBox* box = layoutObject->firstTextBox(); box; box = box->nextTextBox()) {
- const ComputedStyle& style = layoutObject->styleRef(box->isFirstLineStyle());
+ if (!layoutObject->isText())
+ return;
+ LayoutText* layoutText = toLayoutText(layoutObject);
+ for (InlineTextBox* box = layoutText->firstTextBox(); box; box = box->nextTextBox()) {
+ const ComputedStyle& style = layoutText->styleRef(box->isFirstLineStyle());
const Font& font = style.font();
TextRun run = box->constructTextRunForInspector(style, font);
SimpleShaper shaper(&font, run);
@@ -826,39 +829,17 @@ void InspectorCSSAgent::getPlatformFontsForNode(ErrorString* errorString, int no
RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSComputedStyleDeclaration::create(node, true);
*cssFamilyName = computedStyleInfo->getPropertyValue(CSSPropertyFontFamily);
- WillBeHeapVector<RawPtrWillBeMember<Text> > textNodes;
- if (node->nodeType() == Node::TEXT_NODE) {
- if (node->layoutObject())
- textNodes.append(toText(node));
- } else {
- for (Node* child = node->firstChild(); child; child = child->nextSibling()) {
- if (child->nodeType() == Node::TEXT_NODE && child->layoutObject())
- textNodes.append(toText(child));
- }
- }
-
HashCountedSet<String> fontStats;
- for (size_t i = 0; i < textNodes.size(); ++i) {
- LayoutText* layoutObject = textNodes[i]->layoutObject();
- collectPlatformFontsForLayoutObject(layoutObject, &fontStats);
-
- if (!layoutObject->isTextFragment())
- continue;
-
- // If we're the remaining text from a first-letter then our previous
- // sibling has to be the first-letter layoutObject.
- LayoutObject* previous = layoutObject->previousSibling();
- if (!previous)
- continue;
-
- if (!previous->isPseudoElement() || !previous->node()->isFirstLetterPseudoElement())
- continue;
-
- // The first-letter pseudoElement only has one child, which is the
- // first-letter layoutObject.
- collectPlatformFontsForLayoutObject(toLayoutText(previous->slowFirstChild()), &fontStats);
+ LayoutObject* root = node->layoutObject();
+ if (root) {
+ collectPlatformFontsForLayoutObject(root, &fontStats);
+ // Iterate upto two layers deep.
+ for (LayoutObject* child = root->slowFirstChild(); child; child = child->nextSibling()) {
+ collectPlatformFontsForLayoutObject(child, &fontStats);
+ for (LayoutObject* child2 = child->slowFirstChild(); child2; child2 = child2->nextSibling())
+ collectPlatformFontsForLayoutObject(child2, &fontStats);
+ }
}
-
platformFonts = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>::create();
for (auto& font : fontStats) {
RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder::CSS::PlatformFontUsage::create()
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698