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

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

Issue 414863002: Minimize RenderObject* casting to RenderText* (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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/editing/VisibleUnits.cpp ('k') | Source/core/page/TouchAdjustment.cpp » ('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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/css/MediaQuery.h" 42 #include "core/css/MediaQuery.h"
43 #include "core/css/MediaValues.h" 43 #include "core/css/MediaValues.h"
44 #include "core/css/StylePropertySet.h" 44 #include "core/css/StylePropertySet.h"
45 #include "core/css/StyleRule.h" 45 #include "core/css/StyleRule.h"
46 #include "core/css/StyleSheet.h" 46 #include "core/css/StyleSheet.h"
47 #include "core/css/StyleSheetContents.h" 47 #include "core/css/StyleSheetContents.h"
48 #include "core/css/StyleSheetList.h" 48 #include "core/css/StyleSheetList.h"
49 #include "core/css/resolver/StyleResolver.h" 49 #include "core/css/resolver/StyleResolver.h"
50 #include "core/dom/Node.h" 50 #include "core/dom/Node.h"
51 #include "core/dom/StyleEngine.h" 51 #include "core/dom/StyleEngine.h"
52 #include "core/dom/Text.h"
52 #include "core/frame/LocalFrame.h" 53 #include "core/frame/LocalFrame.h"
53 #include "core/html/HTMLHeadElement.h" 54 #include "core/html/HTMLHeadElement.h"
54 #include "core/html/VoidCallback.h" 55 #include "core/html/VoidCallback.h"
55 #include "core/inspector/InspectorHistory.h" 56 #include "core/inspector/InspectorHistory.h"
56 #include "core/inspector/InspectorPageAgent.h" 57 #include "core/inspector/InspectorPageAgent.h"
57 #include "core/inspector/InspectorResourceAgent.h" 58 #include "core/inspector/InspectorResourceAgent.h"
58 #include "core/inspector/InspectorResourceContentLoader.h" 59 #include "core/inspector/InspectorResourceContentLoader.h"
59 #include "core/inspector/InspectorState.h" 60 #include "core/inspector/InspectorState.h"
60 #include "core/inspector/InstrumentingAgents.h" 61 #include "core/inspector/InstrumentingAgents.h"
61 #include "core/loader/DocumentLoader.h" 62 #include "core/loader/DocumentLoader.h"
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 void InspectorCSSAgent::getPlatformFontsForNode(ErrorString* errorString, int no deId, 731 void InspectorCSSAgent::getPlatformFontsForNode(ErrorString* errorString, int no deId,
731 String* cssFamilyName, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PlatformF ontUsage> >& platformFonts) 732 String* cssFamilyName, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PlatformF ontUsage> >& platformFonts)
732 { 733 {
733 Node* node = m_domAgent->assertNode(errorString, nodeId); 734 Node* node = m_domAgent->assertNode(errorString, nodeId);
734 if (!node) 735 if (!node)
735 return; 736 return;
736 737
737 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSCompu tedStyleDeclaration::create(node, true); 738 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSCompu tedStyleDeclaration::create(node, true);
738 *cssFamilyName = computedStyleInfo->getPropertyValue(CSSPropertyFontFamily); 739 *cssFamilyName = computedStyleInfo->getPropertyValue(CSSPropertyFontFamily);
739 740
740 WillBeHeapVector<RawPtrWillBeMember<Node> > textNodes; 741 WillBeHeapVector<RawPtrWillBeMember<Text> > textNodes;
741 if (node->nodeType() == Node::TEXT_NODE) { 742 if (node->nodeType() == Node::TEXT_NODE) {
742 if (node->renderer()) 743 if (node->renderer())
743 textNodes.append(node); 744 textNodes.append(toText(node));
744 } else { 745 } else {
745 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) { 746 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) {
746 if (child->nodeType() == Node::TEXT_NODE && child->renderer()) 747 if (child->nodeType() == Node::TEXT_NODE && child->renderer())
747 textNodes.append(child); 748 textNodes.append(toText(child));
748 } 749 }
749 } 750 }
750 751
751 HashCountedSet<String> fontStats; 752 HashCountedSet<String> fontStats;
752 for (size_t i = 0; i < textNodes.size(); ++i) { 753 for (size_t i = 0; i < textNodes.size(); ++i) {
753 RenderText* renderer = toRenderText(textNodes[i]->renderer()); 754 RenderText* renderer = textNodes[i]->renderer();
754 collectPlatformFontsForRenderer(renderer, &fontStats); 755 collectPlatformFontsForRenderer(renderer, &fontStats);
755 if (renderer->isTextFragment()) { 756 if (renderer->isTextFragment()) {
756 RenderTextFragment* textFragment = toRenderTextFragment(renderer); 757 RenderTextFragment* textFragment = toRenderTextFragment(renderer);
757 if (textFragment->firstLetter()) { 758 if (textFragment->firstLetter()) {
758 RenderBoxModelObject* firstLetter = textFragment->firstLetter(); 759 RenderBoxModelObject* firstLetter = textFragment->firstLetter();
759 for (RenderObject* current = firstLetter->slowFirstChild(); curr ent; current = current->nextSibling()) { 760 for (RenderObject* current = firstLetter->slowFirstChild(); curr ent; current = current->nextSibling()) {
760 if (current->isText()) 761 if (current->isText())
761 collectPlatformFontsForRenderer(toRenderText(current), & fontStats); 762 collectPlatformFontsForRenderer(toRenderText(current), & fontStats);
762 } 763 }
763 } 764 }
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 visitor->trace(m_documentToCSSStyleSheets); 1419 visitor->trace(m_documentToCSSStyleSheets);
1419 visitor->trace(m_invalidatedDocuments); 1420 visitor->trace(m_invalidatedDocuments);
1420 visitor->trace(m_documentToViaInspectorStyleSheet); 1421 visitor->trace(m_documentToViaInspectorStyleSheet);
1421 #endif 1422 #endif
1422 visitor->trace(m_inspectorUserAgentStyleSheet); 1423 visitor->trace(m_inspectorUserAgentStyleSheet);
1423 InspectorBaseAgent::trace(visitor); 1424 InspectorBaseAgent::trace(visitor);
1424 } 1425 }
1425 1426
1426 } // namespace blink 1427 } // namespace blink
1427 1428
OLDNEW
« no previous file with comments | « Source/core/editing/VisibleUnits.cpp ('k') | Source/core/page/TouchAdjustment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698