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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "core/css/StyleRule.h" | 43 #include "core/css/StyleRule.h" |
44 #include "core/css/StyleSheetContents.h" | 44 #include "core/css/StyleSheetContents.h" |
45 #include "core/dom/Document.h" | 45 #include "core/dom/Document.h" |
46 #include "core/dom/Element.h" | 46 #include "core/dom/Element.h" |
47 #include "core/dom/Node.h" | 47 #include "core/dom/Node.h" |
48 #include "core/html/parser/HTMLParserIdioms.h" | 48 #include "core/html/parser/HTMLParserIdioms.h" |
49 #include "core/inspector/ContentSearchUtils.h" | 49 #include "core/inspector/ContentSearchUtils.h" |
50 #include "core/inspector/InspectorCSSAgent.h" | 50 #include "core/inspector/InspectorCSSAgent.h" |
51 #include "core/inspector/InspectorPageAgent.h" | 51 #include "core/inspector/InspectorPageAgent.h" |
52 #include "core/inspector/InspectorValues.h" | 52 #include "core/inspector/InspectorValues.h" |
| 53 #include "core/page/Page.h" |
| 54 #include "core/page/PageConsole.h" |
53 #include "core/platform/text/RegularExpression.h" | 55 #include "core/platform/text/RegularExpression.h" |
54 | 56 |
55 #include <wtf/OwnPtr.h> | 57 #include <wtf/OwnPtr.h> |
56 #include <wtf/PassOwnPtr.h> | 58 #include <wtf/PassOwnPtr.h> |
57 #include <wtf/text/StringBuilder.h> | 59 #include <wtf/text/StringBuilder.h> |
58 #include <wtf/Vector.h> | 60 #include <wtf/Vector.h> |
59 | 61 |
60 using WebCore::TypeBuilder::Array; | 62 using WebCore::TypeBuilder::Array; |
61 using WebCore::RuleSourceDataList; | 63 using WebCore::RuleSourceDataList; |
62 using WebCore::CSSRuleSourceData; | 64 using WebCore::CSSRuleSourceData; |
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 if (!m_sourceURL.isNull()) | 1473 if (!m_sourceURL.isNull()) |
1472 return m_sourceURL; | 1474 return m_sourceURL; |
1473 if (m_origin != TypeBuilder::CSS::StyleSheetOrigin::Regular) { | 1475 if (m_origin != TypeBuilder::CSS::StyleSheetOrigin::Regular) { |
1474 m_sourceURL = ""; | 1476 m_sourceURL = ""; |
1475 return m_sourceURL; | 1477 return m_sourceURL; |
1476 } | 1478 } |
1477 | 1479 |
1478 String styleSheetText; | 1480 String styleSheetText; |
1479 bool success = getText(&styleSheetText); | 1481 bool success = getText(&styleSheetText); |
1480 if (success) { | 1482 if (success) { |
1481 String commentValue = ContentSearchUtils::findSourceURL(styleSheetText,
ContentSearchUtils::CSSMagicComment); | 1483 bool deprecated; |
| 1484 String commentValue = ContentSearchUtils::findSourceURL(styleSheetText,
ContentSearchUtils::CSSMagicComment, &deprecated); |
1482 if (!commentValue.isEmpty()) { | 1485 if (!commentValue.isEmpty()) { |
| 1486 if (deprecated) |
| 1487 m_pageAgent->page()->console()->addMessage(NetworkMessageSource,
WarningMessageLevel, "\"/*@ sourceURL=\" source URL declaration is deprecated,
\"/*# sourceURL=\" declaration should be used instead.", finalURL(), 0); |
1483 m_sourceURL = commentValue; | 1488 m_sourceURL = commentValue; |
1484 return m_sourceURL; | 1489 return commentValue; |
1485 } | 1490 } |
1486 } | 1491 } |
1487 m_sourceURL = ""; | 1492 m_sourceURL = ""; |
1488 return m_sourceURL; | 1493 return m_sourceURL; |
1489 } | 1494 } |
1490 | 1495 |
1491 String InspectorStyleSheet::url() const | 1496 String InspectorStyleSheet::url() const |
1492 { | 1497 { |
1493 // "sourceURL" is present only for regular rules, otherwise "origin" should
be used in the frontend. | 1498 // "sourceURL" is present only for regular rules, otherwise "origin" should
be used in the frontend. |
1494 if (m_origin != TypeBuilder::CSS::StyleSheetOrigin::Regular) | 1499 if (m_origin != TypeBuilder::CSS::StyleSheetOrigin::Regular) |
(...skipping 21 matching lines...) Expand all Loading... |
1516 { | 1521 { |
1517 CSSStyleSheet* styleSheet = pageStyleSheet(); | 1522 CSSStyleSheet* styleSheet = pageStyleSheet(); |
1518 if (!styleSheet) | 1523 if (!styleSheet) |
1519 return true; | 1524 return true; |
1520 | 1525 |
1521 return styleSheet->startPositionInSource() == TextPosition::minimumPosition(
); | 1526 return styleSheet->startPositionInSource() == TextPosition::minimumPosition(
); |
1522 } | 1527 } |
1523 | 1528 |
1524 String InspectorStyleSheet::sourceMapURL() const | 1529 String InspectorStyleSheet::sourceMapURL() const |
1525 { | 1530 { |
1526 DEFINE_STATIC_LOCAL(String, sourceMapHttpHeader, (ASCIILiteral("X-SourceMap"
))); | |
1527 | |
1528 if (m_origin != TypeBuilder::CSS::StyleSheetOrigin::Regular) | 1531 if (m_origin != TypeBuilder::CSS::StyleSheetOrigin::Regular) |
1529 return String(); | 1532 return String(); |
1530 | 1533 |
1531 String styleSheetText; | 1534 String styleSheetText; |
1532 bool success = getText(&styleSheetText); | 1535 bool success = getText(&styleSheetText); |
1533 if (success) { | 1536 if (success) { |
1534 String commentValue = ContentSearchUtils::findSourceMapURL(styleSheetTex
t, ContentSearchUtils::CSSMagicComment); | 1537 bool deprecated; |
1535 if (!commentValue.isEmpty()) | 1538 String commentValue = ContentSearchUtils::findSourceMapURL(styleSheetTex
t, ContentSearchUtils::CSSMagicComment, &deprecated); |
| 1539 if (!commentValue.isEmpty()) { |
| 1540 if (deprecated) |
| 1541 m_pageAgent->page()->console()->addMessage(NetworkMessageSource,
WarningMessageLevel, "\"/*@ sourceMapURL=\" source mapping URL declaration is d
eprecated, \"/*# sourceMapURL=\" declaration should be used instead.", finalURL(
), 0); |
1536 return commentValue; | 1542 return commentValue; |
| 1543 } |
1537 } | 1544 } |
1538 | 1545 return m_pageAgent->resourceSourceMapURL(finalURL()); |
1539 if (finalURL().isEmpty()) | |
1540 return String(); | |
1541 | |
1542 CachedResource* resource = m_pageAgent->cachedResource(m_pageAgent->mainFram
e(), KURL(ParsedURLString, finalURL())); | |
1543 if (resource) | |
1544 return resource->response().httpHeaderField(sourceMapHttpHeader); | |
1545 return String(); | |
1546 } | 1546 } |
1547 | 1547 |
1548 InspectorCSSId InspectorStyleSheet::ruleOrStyleId(CSSStyleDeclaration* style) co
nst | 1548 InspectorCSSId InspectorStyleSheet::ruleOrStyleId(CSSStyleDeclaration* style) co
nst |
1549 { | 1549 { |
1550 unsigned index = ruleIndexByStyle(style); | 1550 unsigned index = ruleIndexByStyle(style); |
1551 if (index != UINT_MAX) | 1551 if (index != UINT_MAX) |
1552 return InspectorCSSId(id(), index); | 1552 return InspectorCSSId(id(), index); |
1553 return InspectorCSSId(); | 1553 return InspectorCSSId(); |
1554 } | 1554 } |
1555 | 1555 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1890 | 1890 |
1891 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); | 1891 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); |
1892 RuleSourceDataList ruleSourceDataResult; | 1892 RuleSourceDataList ruleSourceDataResult; |
1893 StyleSheetHandler handler(m_styleText, m_element->document(), m_element->doc
ument()->elementSheet()->contents(), &ruleSourceDataResult); | 1893 StyleSheetHandler handler(m_styleText, m_element->document(), m_element->doc
ument()->elementSheet()->contents(), &ruleSourceDataResult); |
1894 createCSSParser(m_element->document())->parseDeclaration(tempDeclaration.get
(), m_styleText, &handler, m_element->document()->elementSheet()->contents()); | 1894 createCSSParser(m_element->document())->parseDeclaration(tempDeclaration.get
(), m_styleText, &handler, m_element->document()->elementSheet()->contents()); |
1895 return ruleSourceDataResult.first().release(); | 1895 return ruleSourceDataResult.first().release(); |
1896 } | 1896 } |
1897 | 1897 |
1898 } // namespace WebCore | 1898 } // namespace WebCore |
1899 | 1899 |
OLD | NEW |