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

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

Issue 267393003: DevTools: Load document (html) content from disk cache in page agent enabling. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
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 28 matching lines...) Expand all
39 #include "core/css/StylePropertySet.h" 39 #include "core/css/StylePropertySet.h"
40 #include "core/css/StyleRule.h" 40 #include "core/css/StyleRule.h"
41 #include "core/css/StyleSheetContents.h" 41 #include "core/css/StyleSheetContents.h"
42 #include "core/dom/Document.h" 42 #include "core/dom/Document.h"
43 #include "core/dom/Element.h" 43 #include "core/dom/Element.h"
44 #include "core/html/HTMLStyleElement.h" 44 #include "core/html/HTMLStyleElement.h"
45 #include "core/html/parser/HTMLParserIdioms.h" 45 #include "core/html/parser/HTMLParserIdioms.h"
46 #include "core/inspector/ContentSearchUtils.h" 46 #include "core/inspector/ContentSearchUtils.h"
47 #include "core/inspector/InspectorCSSAgent.h" 47 #include "core/inspector/InspectorCSSAgent.h"
48 #include "core/inspector/InspectorPageAgent.h" 48 #include "core/inspector/InspectorPageAgent.h"
49 #include "core/inspector/InspectorResourceAgent.h"
50 #include "core/svg/SVGStyleElement.h" 49 #include "core/svg/SVGStyleElement.h"
51 #include "wtf/OwnPtr.h" 50 #include "wtf/OwnPtr.h"
52 #include "wtf/PassOwnPtr.h" 51 #include "wtf/PassOwnPtr.h"
53 #include "wtf/text/StringBuilder.h" 52 #include "wtf/text/StringBuilder.h"
54 #include "wtf/text/TextPosition.h" 53 #include "wtf/text/TextPosition.h"
55 54
56 using WebCore::TypeBuilder::Array; 55 using WebCore::TypeBuilder::Array;
57 using WebCore::RuleSourceDataList; 56 using WebCore::RuleSourceDataList;
58 using WebCore::CSSRuleSourceData; 57 using WebCore::CSSRuleSourceData;
59 using WebCore::CSSStyleSheet; 58 using WebCore::CSSStyleSheet;
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 if (!sourceRange.length() && ruleSourceData->ruleBodyRange.start <= sour ceRange.start && sourceRange.start <= ruleSourceData->ruleBodyRange.end) { 937 if (!sourceRange.length() && ruleSourceData->ruleBodyRange.start <= sour ceRange.start && sourceRange.start <= ruleSourceData->ruleBodyRange.end) {
939 *ruleId = InspectorCSSId(id(), i); 938 *ruleId = InspectorCSSId(id(), i);
940 *propertyIndex = propertyData.size(); 939 *propertyIndex = propertyData.size();
941 *overwrite = false; 940 *overwrite = false;
942 return true; 941 return true;
943 } 942 }
944 } 943 }
945 return false; 944 return false;
946 } 945 }
947 946
948 PassRefPtr<InspectorStyleSheet> InspectorStyleSheet::create(InspectorPageAgent* pageAgent, InspectorResourceAgent* resourceAgent, const String& id, PassRefPtrWi llBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::En um origin, const String& documentURL, Listener* listener) 947 PassRefPtr<InspectorStyleSheet> InspectorStyleSheet::create(InspectorPageAgent* pageAgent, const String& id, PassRefPtrWillBeRawPtr<CSSStyleSheet> pageStyleShee t, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const String& documentURL, L istener* listener)
949 { 948 {
950 return adoptRef(new InspectorStyleSheet(pageAgent, resourceAgent, id, pageSt yleSheet, origin, documentURL, listener)); 949 return adoptRef(new InspectorStyleSheet(pageAgent, id, pageStyleSheet, origi n, documentURL, listener));
951 } 950 }
952 951
953 InspectorStyleSheet::InspectorStyleSheet(InspectorPageAgent* pageAgent, Inspecto rResourceAgent* resourceAgent, const String& id, PassRefPtrWillBeRawPtr<CSSStyle Sheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const St ring& documentURL, Listener* listener) 952 InspectorStyleSheet::InspectorStyleSheet(InspectorPageAgent* pageAgent, const St ring& id, PassRefPtrWillBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS ::StyleSheetOrigin::Enum origin, const String& documentURL, Listener* listener)
954 : InspectorStyleSheetBase(id, listener) 953 : InspectorStyleSheetBase(id, listener)
955 , m_pageAgent(pageAgent) 954 , m_pageAgent(pageAgent)
956 , m_resourceAgent(resourceAgent)
957 , m_pageStyleSheet(pageStyleSheet) 955 , m_pageStyleSheet(pageStyleSheet)
958 , m_origin(origin) 956 , m_origin(origin)
959 , m_documentURL(documentURL) 957 , m_documentURL(documentURL)
960 { 958 {
961 m_parsedStyleSheet = adoptPtr(new ParsedStyleSheet(m_pageStyleSheet.get())); 959 m_parsedStyleSheet = adoptPtr(new ParsedStyleSheet(m_pageStyleSheet.get()));
962 } 960 }
963 961
964 InspectorStyleSheet::~InspectorStyleSheet() 962 InspectorStyleSheet::~InspectorStyleSheet()
965 { 963 {
966 } 964 }
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 } 1514 }
1517 1515
1518 bool InspectorStyleSheet::resourceStyleSheetText(String* result) const 1516 bool InspectorStyleSheet::resourceStyleSheetText(String* result) const
1519 { 1517 {
1520 if (m_origin == TypeBuilder::CSS::StyleSheetOrigin::User || m_origin == Type Builder::CSS::StyleSheetOrigin::User_agent) 1518 if (m_origin == TypeBuilder::CSS::StyleSheetOrigin::User || m_origin == Type Builder::CSS::StyleSheetOrigin::User_agent)
1521 return false; 1519 return false;
1522 1520
1523 if (!ownerDocument() || !ownerDocument()->frame()) 1521 if (!ownerDocument() || !ownerDocument()->frame())
1524 return false; 1522 return false;
1525 1523
1524 String error;
1526 bool base64Encoded; 1525 bool base64Encoded;
1527 bool success = m_resourceAgent->fetchResourceContent(ownerDocument()->frame( ), KURL(ParsedURLString, m_pageStyleSheet->href()), result, &base64Encoded) && ! base64Encoded; 1526 InspectorPageAgent::resourceContent(&error, ownerDocument()->frame(), KURL(P arsedURLString, m_pageStyleSheet->href()), result, &base64Encoded);
1528 return success; 1527 return error.isEmpty() && !base64Encoded;
1529 } 1528 }
1530 1529
1531 bool InspectorStyleSheet::inlineStyleSheetText(String* result) const 1530 bool InspectorStyleSheet::inlineStyleSheetText(String* result) const
1532 { 1531 {
1533 Node* ownerNode = m_pageStyleSheet->ownerNode(); 1532 Node* ownerNode = m_pageStyleSheet->ownerNode();
1534 if (!ownerNode || ownerNode->nodeType() != Node::ELEMENT_NODE) 1533 if (!ownerNode || ownerNode->nodeType() != Node::ELEMENT_NODE)
1535 return false; 1534 return false;
1536 Element& ownerElement = toElement(*ownerNode); 1535 Element& ownerElement = toElement(*ownerNode);
1537 1536
1538 if (!isHTMLStyleElement(ownerElement) && !isSVGStyleElement(ownerElement)) 1537 if (!isHTMLStyleElement(ownerElement) && !isSVGStyleElement(ownerElement))
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 1664
1666 RefPtrWillBeRawPtr<MutableStylePropertySet> tempDeclaration = MutableStylePr opertySet::create(); 1665 RefPtrWillBeRawPtr<MutableStylePropertySet> tempDeclaration = MutableStylePr opertySet::create();
1667 RuleSourceDataList ruleSourceDataResult; 1666 RuleSourceDataList ruleSourceDataResult;
1668 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do cument().elementSheet().contents(), &ruleSourceDataResult); 1667 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do cument().elementSheet().contents(), &ruleSourceDataResult);
1669 BisonCSSParser(parserContextForDocument(&m_element->document())).parseDeclar ation(tempDeclaration.get(), m_styleText, &handler, m_element->document().elemen tSheet().contents()); 1668 BisonCSSParser(parserContextForDocument(&m_element->document())).parseDeclar ation(tempDeclaration.get(), m_styleText, &handler, m_element->document().elemen tSheet().contents());
1670 return ruleSourceDataResult.first().release(); 1669 return ruleSourceDataResult.first().release();
1671 } 1670 }
1672 1671
1673 } // namespace WebCore 1672 } // namespace WebCore
1674 1673
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698