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

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

Issue 417953002: Oilpan: Prepare moving InspectorStyle to Oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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/inspector/InspectorStyleSheet.h ('k') | no next file » | 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 496
497 if (rule->type() == CSSRule::KEYFRAMES_RULE) 497 if (rule->type() == CSSRule::KEYFRAMES_RULE)
498 return toCSSKeyframesRule(rule)->cssRules(); 498 return toCSSKeyframesRule(rule)->cssRules();
499 499
500 if (rule->type() == CSSRule::SUPPORTS_RULE) 500 if (rule->type() == CSSRule::SUPPORTS_RULE)
501 return toCSSSupportsRule(rule)->cssRules(); 501 return toCSSSupportsRule(rule)->cssRules();
502 502
503 return nullptr; 503 return nullptr;
504 } 504 }
505 505
506 PassRefPtr<InspectorStyle> InspectorStyle::create(const InspectorCSSId& styleId, PassRefPtrWillBeRawPtr<CSSStyleDeclaration> style, InspectorStyleSheetBase* par entStyleSheet) 506 PassRefPtrWillBeRawPtr<InspectorStyle> InspectorStyle::create(const InspectorCSS Id& styleId, PassRefPtrWillBeRawPtr<CSSStyleDeclaration> style, InspectorStyleSh eetBase* parentStyleSheet)
507 { 507 {
508 return adoptRef(new InspectorStyle(styleId, style, parentStyleSheet)); 508 return adoptRefWillBeNoop(new InspectorStyle(styleId, style, parentStyleShee t));
509 } 509 }
510 510
511 InspectorStyle::InspectorStyle(const InspectorCSSId& styleId, PassRefPtrWillBeRa wPtr<CSSStyleDeclaration> style, InspectorStyleSheetBase* parentStyleSheet) 511 InspectorStyle::InspectorStyle(const InspectorCSSId& styleId, PassRefPtrWillBeRa wPtr<CSSStyleDeclaration> style, InspectorStyleSheetBase* parentStyleSheet)
512 : m_styleId(styleId) 512 : m_styleId(styleId)
513 , m_style(style) 513 , m_style(style)
514 , m_parentStyleSheet(parentStyleSheet) 514 , m_parentStyleSheet(parentStyleSheet)
515 , m_formatAcquired(false) 515 , m_formatAcquired(false)
516 { 516 {
517 ASSERT(m_style); 517 ASSERT(m_style);
518 } 518 }
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 m_format.first = formatLineFeed.toString(); 820 m_format.first = formatLineFeed.toString();
821 m_format.second = isFullPrefixScanned ? prefix.toString() : candidatePrefix; 821 m_format.second = isFullPrefixScanned ? prefix.toString() : candidatePrefix;
822 return m_format; 822 return m_format;
823 } 823 }
824 824
825 Document* InspectorStyle::ownerDocument() const 825 Document* InspectorStyle::ownerDocument() const
826 { 826 {
827 return m_parentStyleSheet->ownerDocument(); 827 return m_parentStyleSheet->ownerDocument();
828 } 828 }
829 829
830 void InspectorStyle::trace(Visitor* visitor)
831 {
832 visitor->trace(m_style);
833 visitor->trace(m_parentStyleSheet);
834 }
835
830 InspectorStyleSheetBase::InspectorStyleSheetBase(const String& id, Listener* lis tener) 836 InspectorStyleSheetBase::InspectorStyleSheetBase(const String& id, Listener* lis tener)
831 : m_id(id) 837 : m_id(id)
832 , m_listener(listener) 838 , m_listener(listener)
833 { 839 {
834 } 840 }
835 841
836 bool InspectorStyleSheetBase::setPropertyText(const InspectorCSSId& id, unsigned propertyIndex, const String& text, bool overwrite, ExceptionState& exceptionSta te) 842 bool InspectorStyleSheetBase::setPropertyText(const InspectorCSSId& id, unsigned propertyIndex, const String& text, bool overwrite, ExceptionState& exceptionSta te)
837 { 843 {
838 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); 844 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id);
839 if (!inspectorStyle) { 845 if (!inspectorStyle) {
840 exceptionState.throwDOMException(NotFoundError, "No property could be fo und for the given ID."); 846 exceptionState.throwDOMException(NotFoundError, "No property could be fo und for the given ID.");
841 return false; 847 return false;
842 } 848 }
843 return inspectorStyle->setPropertyText(propertyIndex, text, overwrite, excep tionState); 849 return inspectorStyle->setPropertyText(propertyIndex, text, overwrite, excep tionState);
844 } 850 }
845 851
846 bool InspectorStyleSheetBase::getStyleText(const InspectorCSSId& id, String* tex t) 852 bool InspectorStyleSheetBase::getStyleText(const InspectorCSSId& id, String* tex t)
847 { 853 {
848 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); 854 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id);
849 if (!inspectorStyle) 855 if (!inspectorStyle)
850 return false; 856 return false;
851 return inspectorStyle->styleText(text); 857 return inspectorStyle->styleText(text);
852 } 858 }
853 859
854 void InspectorStyleSheetBase::fireStyleSheetChanged() 860 void InspectorStyleSheetBase::fireStyleSheetChanged()
855 { 861 {
856 if (listener()) 862 if (listener())
857 listener()->styleSheetChanged(this); 863 listener()->styleSheetChanged(this);
858 } 864 }
859 865
860 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyleSheetBase::buildObjectForSt yle(CSSStyleDeclaration* style) 866 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyleSheetBase::buildObjectForSt yle(CSSStyleDeclaration* style)
861 { 867 {
862 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = nullptr; 868 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = nullptr;
863 if (ensureParsedDataReady()) 869 if (ensureParsedDataReady())
864 sourceData = ruleSourceDataAt(styleId(style).ordinal()); 870 sourceData = ruleSourceDataAt(styleId(style).ordinal());
865 871
866 InspectorCSSId id = styleId(style); 872 InspectorCSSId id = styleId(style);
867 if (id.isEmpty()) { 873 if (id.isEmpty()) {
868 // Any rule coming from User Agent and not from DefaultStyleSheet will n ot have id. 874 // Any rule coming from User Agent and not from DefaultStyleSheet will n ot have id.
869 // See InspectorCSSAgent::buildObjectForRule for details. 875 // See InspectorCSSAgent::buildObjectForRule for details.
870 RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(id, style , this); 876 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = InspectorStyle::crea te(id, style, this);
871 return inspectorStyle->buildObjectForStyle(); 877 return inspectorStyle->buildObjectForStyle();
872 } 878 }
873 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); 879 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id);
874 RefPtr<TypeBuilder::CSS::CSSStyle> result = inspectorStyle->buildObjectForSt yle(); 880 RefPtr<TypeBuilder::CSS::CSSStyle> result = inspectorStyle->buildObjectForSt yle();
875 881
876 // Style text cannot be retrieved without stylesheet, so set cssText here. 882 // Style text cannot be retrieved without stylesheet, so set cssText here.
877 if (sourceData) { 883 if (sourceData) {
878 String sheetText; 884 String sheetText;
879 bool success = getText(&sheetText); 885 bool success = getText(&sheetText);
880 if (success) { 886 if (success) {
881 const SourceRange& bodyRange = sourceData->ruleBodyRange; 887 const SourceRange& bodyRange = sourceData->ruleBodyRange;
882 result->setCssText(sheetText.substring(bodyRange.start, bodyRange.en d - bodyRange.start)); 888 result->setCssText(sheetText.substring(bodyRange.start, bodyRange.en d - bodyRange.start));
883 } 889 }
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 size_t index = m_flatRules.find(rule); 1289 size_t index = m_flatRules.find(rule);
1284 // FIXME(lusnikov): m_flatRules are not always aligned with the m_parsedStyl eSheet rule source 1290 // FIXME(lusnikov): m_flatRules are not always aligned with the m_parsedStyl eSheet rule source
1285 // datas due to the CSSOM operations that add/remove rules without changing source. 1291 // datas due to the CSSOM operations that add/remove rules without changing source.
1286 // This is a design issue. See crbug.com/178410 1292 // This is a design issue. See crbug.com/178410
1287 if (index == kNotFound || index >= m_parsedStyleSheet->ruleCount()) 1293 if (index == kNotFound || index >= m_parsedStyleSheet->ruleCount())
1288 return nullptr; 1294 return nullptr;
1289 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = m_parsedStyleSheet->ruleS ourceDataAt(static_cast<unsigned>(index)); 1295 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = m_parsedStyleSheet->ruleS ourceDataAt(static_cast<unsigned>(index));
1290 return buildSourceRangeObject(sourceData->ruleHeaderRange, lineEndings().get ()); 1296 return buildSourceRangeObject(sourceData->ruleHeaderRange, lineEndings().get ());
1291 } 1297 }
1292 1298
1293 PassRefPtr<InspectorStyle> InspectorStyleSheet::inspectorStyleForId(const Inspec torCSSId& id) 1299 PassRefPtrWillBeRawPtr<InspectorStyle> InspectorStyleSheet::inspectorStyleForId( const InspectorCSSId& id)
1294 { 1300 {
1295 CSSStyleDeclaration* style = styleForId(id); 1301 CSSStyleDeclaration* style = styleForId(id);
1296 if (!style) 1302 if (!style)
1297 return nullptr; 1303 return nullptr;
1298 1304
1299 return InspectorStyle::create(id, style, this); 1305 return InspectorStyle::create(id, style, this);
1300 } 1306 }
1301 1307
1302 unsigned InspectorStyleSheet::ruleCount() 1308 unsigned InspectorStyleSheet::ruleCount()
1303 { 1309 {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 1666
1661 bool success = !!m_ruleSourceData; 1667 bool success = !!m_ruleSourceData;
1662 if (!success) { 1668 if (!success) {
1663 m_ruleSourceData = CSSRuleSourceData::create(CSSRuleSourceData::STYLE_RU LE); 1669 m_ruleSourceData = CSSRuleSourceData::create(CSSRuleSourceData::STYLE_RU LE);
1664 return false; 1670 return false;
1665 } 1671 }
1666 1672
1667 return true; 1673 return true;
1668 } 1674 }
1669 1675
1670 PassRefPtr<InspectorStyle> InspectorStyleSheetForInlineStyle::inspectorStyleForI d(const InspectorCSSId& id) 1676 PassRefPtrWillBeRawPtr<InspectorStyle> InspectorStyleSheetForInlineStyle::inspec torStyleForId(const InspectorCSSId& id)
1671 { 1677 {
1672 ASSERT_UNUSED(id, !id.ordinal()); 1678 ASSERT_UNUSED(id, !id.ordinal());
1673 return m_inspectorStyle; 1679 return m_inspectorStyle;
1674 } 1680 }
1675 1681
1676 CSSStyleDeclaration* InspectorStyleSheetForInlineStyle::inlineStyle() const 1682 CSSStyleDeclaration* InspectorStyleSheetForInlineStyle::inlineStyle() const
1677 { 1683 {
1678 return m_element->style(); 1684 return m_element->style();
1679 } 1685 }
1680 1686
(...skipping 18 matching lines...) Expand all
1699 RuleSourceDataList ruleSourceDataResult; 1705 RuleSourceDataList ruleSourceDataResult;
1700 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do cument().elementSheet().contents(), &ruleSourceDataResult); 1706 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do cument().elementSheet().contents(), &ruleSourceDataResult);
1701 BisonCSSParser(parserContextForDocument(&m_element->document())).parseDeclar ation(tempDeclaration.get(), m_styleText, &handler, m_element->document().elemen tSheet().contents()); 1707 BisonCSSParser(parserContextForDocument(&m_element->document())).parseDeclar ation(tempDeclaration.get(), m_styleText, &handler, m_element->document().elemen tSheet().contents());
1702 return ruleSourceDataResult.first().release(); 1708 return ruleSourceDataResult.first().release();
1703 } 1709 }
1704 1710
1705 void InspectorStyleSheetForInlineStyle::trace(Visitor* visitor) 1711 void InspectorStyleSheetForInlineStyle::trace(Visitor* visitor)
1706 { 1712 {
1707 visitor->trace(m_element); 1713 visitor->trace(m_element);
1708 visitor->trace(m_ruleSourceData); 1714 visitor->trace(m_ruleSourceData);
1715 visitor->trace(m_inspectorStyle);
1709 InspectorStyleSheetBase::trace(visitor); 1716 InspectorStyleSheetBase::trace(visitor);
1710 } 1717 }
1711 1718
1712 } // namespace blink 1719 } // namespace blink
1713 1720
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorStyleSheet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698