Chromium Code Reviews| Index: Source/core/inspector/InspectorCSSAgent.cpp |
| diff --git a/Source/core/inspector/InspectorCSSAgent.cpp b/Source/core/inspector/InspectorCSSAgent.cpp |
| index 49d2abbf667634119a532fb1f7ca5ac81fdcc40c..45dd9e14788c288109291456f53d245dfd51ccb3 100644 |
| --- a/Source/core/inspector/InspectorCSSAgent.cpp |
| +++ b/Source/core/inspector/InspectorCSSAgent.cpp |
| @@ -820,10 +820,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); |
| @@ -848,39 +851,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. |
|
pfeldman
2015/06/18 06:48:09
Why not N levels?
lushnikov
2015/06/18 10:29:14
In order to preserve current behavior.
|
| + 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() |