| OLD | NEW |
| 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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 { | 791 { |
| 792 Node* node = m_domAgent->assertNode(errorString, nodeId); | 792 Node* node = m_domAgent->assertNode(errorString, nodeId); |
| 793 if (!node) | 793 if (!node) |
| 794 return; | 794 return; |
| 795 | 795 |
| 796 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSCompu
tedStyleDeclaration::create(node, true); | 796 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSCompu
tedStyleDeclaration::create(node, true); |
| 797 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(0
, computedStyleInfo, 0); | 797 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(0
, computedStyleInfo, 0); |
| 798 style = inspectorStyle->buildArrayForComputedStyle(); | 798 style = inspectorStyle->buildArrayForComputedStyle(); |
| 799 } | 799 } |
| 800 | 800 |
| 801 void InspectorCSSAgent::collectPlatformFontsForLayoutObject(LayoutText* layoutOb
ject, HashCountedSet<String>* fontStats) | 801 void InspectorCSSAgent::collectPlatformFontsForLayoutObject(LayoutObject* layout
Object, HashCountedSet<String>* fontStats) |
| 802 { | 802 { |
| 803 for (InlineTextBox* box = layoutObject->firstTextBox(); box; box = box->next
TextBox()) { | 803 if (!layoutObject->isText()) |
| 804 const ComputedStyle& style = layoutObject->styleRef(box->isFirstLineStyl
e()); | 804 return; |
| 805 LayoutText* layoutText = toLayoutText(layoutObject); |
| 806 for (InlineTextBox* box = layoutText->firstTextBox(); box; box = box->nextTe
xtBox()) { |
| 807 const ComputedStyle& style = layoutText->styleRef(box->isFirstLineStyle(
)); |
| 805 const Font& font = style.font(); | 808 const Font& font = style.font(); |
| 806 TextRun run = box->constructTextRunForInspector(style, font); | 809 TextRun run = box->constructTextRunForInspector(style, font); |
| 807 SimpleShaper shaper(&font, run); | 810 SimpleShaper shaper(&font, run); |
| 808 GlyphBuffer glyphBuffer; | 811 GlyphBuffer glyphBuffer; |
| 809 shaper.advance(run.length(), &glyphBuffer); | 812 shaper.advance(run.length(), &glyphBuffer); |
| 810 for (unsigned i = 0; i < glyphBuffer.size(); ++i) { | 813 for (unsigned i = 0; i < glyphBuffer.size(); ++i) { |
| 811 String familyName = glyphBuffer.fontDataAt(i)->platformData().fontFa
milyName(); | 814 String familyName = glyphBuffer.fontDataAt(i)->platformData().fontFa
milyName(); |
| 812 if (familyName.isNull()) | 815 if (familyName.isNull()) |
| 813 familyName = ""; | 816 familyName = ""; |
| 814 fontStats->add(familyName); | 817 fontStats->add(familyName); |
| 815 } | 818 } |
| 816 } | 819 } |
| 817 } | 820 } |
| 818 | 821 |
| 819 void InspectorCSSAgent::getPlatformFontsForNode(ErrorString* errorString, int no
deId, | 822 void InspectorCSSAgent::getPlatformFontsForNode(ErrorString* errorString, int no
deId, |
| 820 String* cssFamilyName, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PlatformF
ontUsage> >& platformFonts) | 823 String* cssFamilyName, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PlatformF
ontUsage> >& platformFonts) |
| 821 { | 824 { |
| 822 Node* node = m_domAgent->assertNode(errorString, nodeId); | 825 Node* node = m_domAgent->assertNode(errorString, nodeId); |
| 823 if (!node) | 826 if (!node) |
| 824 return; | 827 return; |
| 825 | 828 |
| 826 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSCompu
tedStyleDeclaration::create(node, true); | 829 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSCompu
tedStyleDeclaration::create(node, true); |
| 827 *cssFamilyName = computedStyleInfo->getPropertyValue(CSSPropertyFontFamily); | 830 *cssFamilyName = computedStyleInfo->getPropertyValue(CSSPropertyFontFamily); |
| 828 | 831 |
| 829 WillBeHeapVector<RawPtrWillBeMember<Text> > textNodes; | 832 HashCountedSet<String> fontStats; |
| 830 if (node->nodeType() == Node::TEXT_NODE) { | 833 LayoutObject* root = node->layoutObject(); |
| 831 if (node->layoutObject()) | 834 if (root) { |
| 832 textNodes.append(toText(node)); | 835 collectPlatformFontsForLayoutObject(root, &fontStats); |
| 833 } else { | 836 // Iterate upto two layers deep. |
| 834 for (Node* child = node->firstChild(); child; child = child->nextSibling
()) { | 837 for (LayoutObject* child = root->slowFirstChild(); child; child = child-
>nextSibling()) { |
| 835 if (child->nodeType() == Node::TEXT_NODE && child->layoutObject()) | 838 collectPlatformFontsForLayoutObject(child, &fontStats); |
| 836 textNodes.append(toText(child)); | 839 for (LayoutObject* child2 = child->slowFirstChild(); child2; child2
= child2->nextSibling()) |
| 840 collectPlatformFontsForLayoutObject(child2, &fontStats); |
| 837 } | 841 } |
| 838 } | 842 } |
| 839 | |
| 840 HashCountedSet<String> fontStats; | |
| 841 for (size_t i = 0; i < textNodes.size(); ++i) { | |
| 842 LayoutText* layoutObject = textNodes[i]->layoutObject(); | |
| 843 collectPlatformFontsForLayoutObject(layoutObject, &fontStats); | |
| 844 | |
| 845 if (!layoutObject->isTextFragment()) | |
| 846 continue; | |
| 847 | |
| 848 // If we're the remaining text from a first-letter then our previous | |
| 849 // sibling has to be the first-letter layoutObject. | |
| 850 LayoutObject* previous = layoutObject->previousSibling(); | |
| 851 if (!previous) | |
| 852 continue; | |
| 853 | |
| 854 if (!previous->isPseudoElement() || !previous->node()->isFirstLetterPseu
doElement()) | |
| 855 continue; | |
| 856 | |
| 857 // The first-letter pseudoElement only has one child, which is the | |
| 858 // first-letter layoutObject. | |
| 859 collectPlatformFontsForLayoutObject(toLayoutText(previous->slowFirstChil
d()), &fontStats); | |
| 860 } | |
| 861 | |
| 862 platformFonts = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>::cre
ate(); | 843 platformFonts = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>::cre
ate(); |
| 863 for (auto& font : fontStats) { | 844 for (auto& font : fontStats) { |
| 864 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder::
CSS::PlatformFontUsage::create() | 845 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder::
CSS::PlatformFontUsage::create() |
| 865 .setFamilyName(font.key) | 846 .setFamilyName(font.key) |
| 866 .setGlyphCount(font.value); | 847 .setGlyphCount(font.value); |
| 867 platformFonts->addItem(platformFont); | 848 platformFonts->addItem(platformFont); |
| 868 } | 849 } |
| 869 } | 850 } |
| 870 | 851 |
| 871 void InspectorCSSAgent::getStyleSheetText(ErrorString* errorString, const String
& styleSheetId, String* result) | 852 void InspectorCSSAgent::getStyleSheetText(ErrorString* errorString, const String
& styleSheetId, String* result) |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 visitor->trace(m_invalidatedDocuments); | 1539 visitor->trace(m_invalidatedDocuments); |
| 1559 visitor->trace(m_nodeToInspectorStyleSheet); | 1540 visitor->trace(m_nodeToInspectorStyleSheet); |
| 1560 visitor->trace(m_documentToViaInspectorStyleSheet); | 1541 visitor->trace(m_documentToViaInspectorStyleSheet); |
| 1561 #endif | 1542 #endif |
| 1562 visitor->trace(m_inspectorUserAgentStyleSheet); | 1543 visitor->trace(m_inspectorUserAgentStyleSheet); |
| 1563 InspectorBaseAgent::trace(visitor); | 1544 InspectorBaseAgent::trace(visitor); |
| 1564 } | 1545 } |
| 1565 | 1546 |
| 1566 } // namespace blink | 1547 } // namespace blink |
| 1567 | 1548 |
| OLD | NEW |