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

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

Issue 1187193005: DevTools: migrate from CSS.setPropertyText to CSS.setStyleText (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: for landing Created 5 years, 6 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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 579
580 PassRefPtrWillBeRawPtr<InspectorStyle> InspectorStyle::create(unsigned ruleIndex , PassRefPtrWillBeRawPtr<CSSStyleDeclaration> style, InspectorStyleSheetBase* pa rentStyleSheet) 580 PassRefPtrWillBeRawPtr<InspectorStyle> InspectorStyle::create(unsigned ruleIndex , PassRefPtrWillBeRawPtr<CSSStyleDeclaration> style, InspectorStyleSheetBase* pa rentStyleSheet)
581 { 581 {
582 return adoptRefWillBeNoop(new InspectorStyle(ruleIndex, style, parentStyleSh eet)); 582 return adoptRefWillBeNoop(new InspectorStyle(ruleIndex, style, parentStyleSh eet));
583 } 583 }
584 584
585 InspectorStyle::InspectorStyle(unsigned ruleIndex, PassRefPtrWillBeRawPtr<CSSSty leDeclaration> style, InspectorStyleSheetBase* parentStyleSheet) 585 InspectorStyle::InspectorStyle(unsigned ruleIndex, PassRefPtrWillBeRawPtr<CSSSty leDeclaration> style, InspectorStyleSheetBase* parentStyleSheet)
586 : m_ruleIndex(ruleIndex) 586 : m_ruleIndex(ruleIndex)
587 , m_style(style) 587 , m_style(style)
588 , m_parentStyleSheet(parentStyleSheet) 588 , m_parentStyleSheet(parentStyleSheet)
589 , m_formatAcquired(false)
590 { 589 {
591 ASSERT(m_style); 590 ASSERT(m_style);
592 } 591 }
593 592
594 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyle::buildObjectForStyle() con st 593 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyle::buildObjectForStyle() con st
595 { 594 {
596 RefPtr<TypeBuilder::CSS::CSSStyle> result = styleWithProperties(); 595 RefPtr<TypeBuilder::CSS::CSSStyle> result = styleWithProperties();
597 if (m_parentStyleSheet && !m_parentStyleSheet->id().isEmpty()) 596 if (m_parentStyleSheet && !m_parentStyleSheet->id().isEmpty())
598 result->setStyleSheetId(m_parentStyleSheet->id()); 597 result->setStyleSheetId(m_parentStyleSheet->id());
599 598
(...skipping 14 matching lines...) Expand all
614 const CSSPropertySourceData& propertyEntry = property.sourceData; 613 const CSSPropertySourceData& propertyEntry = property.sourceData;
615 RefPtr<TypeBuilder::CSS::CSSComputedStyleProperty> entry = TypeBuilder:: CSS::CSSComputedStyleProperty::create() 614 RefPtr<TypeBuilder::CSS::CSSComputedStyleProperty> entry = TypeBuilder:: CSS::CSSComputedStyleProperty::create()
616 .setName(propertyEntry.name) 615 .setName(propertyEntry.name)
617 .setValue(propertyEntry.value); 616 .setValue(propertyEntry.value);
618 result->addItem(entry); 617 result->addItem(entry);
619 } 618 }
620 619
621 return result.release(); 620 return result.release();
622 } 621 }
623 622
624 bool InspectorStyle::verifyPropertyText(const String& propertyText, bool canOmit Semicolon)
625 {
626 DEFINE_STATIC_LOCAL(String, bogusPropertyName, ("-webkit-boguz-propertee"));
627 RuleSourceDataList sourceData;
628 String declarationText = propertyText + (canOmitSemicolon ? ";" : " ") + bog usPropertyName + ": none";
629 StyleSheetHandler handler(declarationText, ownerDocument(), &sourceData);
630 CSSParser::parseDeclarationListForInspector(parserContextForDocument(ownerDo cument()), declarationText, handler);
631 WillBeHeapVector<CSSPropertySourceData>& propertyData = sourceData.first()-> styleSourceData->propertyData;
632 unsigned propertyCount = propertyData.size();
633
634 // At least one property + the bogus property added just above should be pre sent.
635 if (propertyCount < 2)
636 return false;
637
638 // Check for the proper propertyText termination (the parser could at least restore to the PROPERTY_NAME state).
639 if (propertyData.at(propertyCount - 1).name != bogusPropertyName)
640 return false;
641
642 return true;
643 }
644
645 bool InspectorStyle::setPropertyText(unsigned index, const String& propertyText, bool overwrite, ExceptionState& exceptionState)
646 {
647 ASSERT(m_parentStyleSheet);
648
649 if (m_ruleIndex == UINT_MAX) {
650 exceptionState.throwDOMException(NotFoundError, "The style is read-only. ");
651 return false;
652 }
653
654 if (!m_parentStyleSheet->ensureParsedDataReady()) {
655 exceptionState.throwDOMException(NotFoundError, "The parent style sheet' s data hasn't been processed.");
656 return false;
657 }
658
659 if (!propertyText.stripWhiteSpace().isEmpty()) {
660 if (!verifyPropertyText(propertyText, false) && !verifyPropertyText(prop ertyText, true)) {
661 exceptionState.throwDOMException(SyntaxError, "The property '" + pro pertyText + "' could not be set.");
662 return false;
663 }
664 }
665
666 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData();
667 if (!sourceData) {
668 exceptionState.throwDOMException(NotFoundError, "The property '" + prope rtyText + "' could not be set.");
669 return false;
670 }
671
672 String text;
673 bool success = styleText(&text);
674 if (!success) {
675 exceptionState.throwDOMException(NotFoundError, "The property '" + prope rtyText + "' could not be set.");
676 return false;
677 }
678
679 WillBeHeapVector<InspectorStyleProperty> allProperties;
680 populateAllProperties(allProperties);
681
682 InspectorStyleTextEditor editor(&allProperties, text, sourceData->ruleBodyRa nge, newLineAndWhitespaceDelimiters());
683 if (overwrite) {
684 if (index >= allProperties.size()) {
685 exceptionState.throwDOMException(IndexSizeError, "The index provided (" + String::number(index) + ") is greater than or equal to the maximum bound ( " + String::number(allProperties.size()) + ").");
686 return false;
687 }
688 editor.replaceProperty(index, propertyText);
689 } else {
690 editor.insertProperty(index, propertyText);
691 }
692
693 return m_parentStyleSheet->setStyleText(m_ruleIndex, editor.styleText());
694 }
695
696 bool InspectorStyle::styleText(String* result) const 623 bool InspectorStyle::styleText(String* result) const
697 { 624 {
698 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData(); 625 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData();
699 if (!sourceData) 626 if (!sourceData)
700 return false; 627 return false;
701 628
702 return textForRange(sourceData->ruleBodyRange, result); 629 return textForRange(sourceData->ruleBodyRange, result);
703 } 630 }
704 631
705 bool InspectorStyle::textForRange(const SourceRange& range, String* result) cons t 632 bool InspectorStyle::textForRange(const SourceRange& range, String* result) cons t
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 if (!builder.isEmpty()) 754 if (!builder.isEmpty())
828 builder.append(' '); 755 builder.append(' ');
829 builder.append(individualValue); 756 builder.append(individualValue);
830 } 757 }
831 758
832 return builder.toString(); 759 return builder.toString();
833 } 760 }
834 return value; 761 return value;
835 } 762 }
836 763
837 NewLineAndWhitespace& InspectorStyle::newLineAndWhitespaceDelimiters() const
838 {
839 DEFINE_STATIC_LOCAL(String, defaultPrefix, (" "));
840
841 if (m_formatAcquired)
842 return m_format;
843
844 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData();
845 WillBeHeapVector<CSSPropertySourceData>* sourcePropertyData = sourceData ? & (sourceData->styleSourceData->propertyData) : nullptr;
846 int propertyCount = sourcePropertyData ? sourcePropertyData->size() : 0;
847 if (!propertyCount) {
848 m_format.first = "\n";
849 m_format.second = defaultPrefix;
850 return m_format; // Do not remember the default formatting and attempt t o acquire it later.
851 }
852
853 String styleSheetText;
854 bool success = m_parentStyleSheet->getText(&styleSheetText);
855 ASSERT_UNUSED(success, success);
856
857 m_formatAcquired = true;
858
859 String candidatePrefix = defaultPrefix;
860 StringBuilder formatLineFeed;
861 StringBuilder prefix;
862 int scanStart = sourceData->ruleBodyRange.start;
863 int propertyIndex = 0;
864 bool isFullPrefixScanned = false;
865 bool lineFeedTerminated = false;
866 while (propertyIndex < propertyCount) {
867 const blink::CSSPropertySourceData& currentProperty = sourcePropertyData ->at(propertyIndex++);
868
869 bool processNextProperty = false;
870 int scanEnd = currentProperty.range.start;
871 for (int i = scanStart; i < scanEnd; ++i) {
872 UChar ch = styleSheetText[i];
873 bool isLineFeed = isHTMLLineBreak(ch);
874 if (isLineFeed) {
875 if (!lineFeedTerminated)
876 formatLineFeed.append(ch);
877 prefix.clear();
878 } else if (isHTMLSpace<UChar>(ch))
879 prefix.append(ch);
880 else {
881 candidatePrefix = prefix.toString();
882 prefix.clear();
883 scanStart = currentProperty.range.end;
884 ++propertyIndex;
885 processNextProperty = true;
886 break;
887 }
888 if (!isLineFeed && formatLineFeed.length())
889 lineFeedTerminated = true;
890 }
891 if (!processNextProperty) {
892 isFullPrefixScanned = true;
893 break;
894 }
895 }
896
897 m_format.first = formatLineFeed.toString();
898 m_format.second = isFullPrefixScanned ? prefix.toString() : candidatePrefix;
899 return m_format;
900 }
901
902 Document* InspectorStyle::ownerDocument() const 764 Document* InspectorStyle::ownerDocument() const
903 { 765 {
904 return m_parentStyleSheet->ownerDocument(); 766 return m_parentStyleSheet->ownerDocument();
905 } 767 }
906 768
907 DEFINE_TRACE(InspectorStyle) 769 DEFINE_TRACE(InspectorStyle)
908 { 770 {
909 visitor->trace(m_style); 771 visitor->trace(m_style);
910 visitor->trace(m_parentStyleSheet); 772 visitor->trace(m_parentStyleSheet);
911 } 773 }
912 774
913 InspectorStyleSheetBase::InspectorStyleSheetBase(const String& id, Listener* lis tener) 775 InspectorStyleSheetBase::InspectorStyleSheetBase(const String& id, Listener* lis tener)
914 : m_id(id) 776 : m_id(id)
915 , m_listener(listener) 777 , m_listener(listener)
916 , m_lineEndings(adoptPtr(new LineEndings())) 778 , m_lineEndings(adoptPtr(new LineEndings()))
917 { 779 {
918 } 780 }
919 781
920 bool InspectorStyleSheetBase::setPropertyText(unsigned ruleIndex, unsigned prope rtyIndex, const String& text, bool overwrite, ExceptionState& exceptionState)
921 {
922 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = inspectorStyleAt(ruleInd ex);
923 if (!inspectorStyle) {
924 exceptionState.throwDOMException(NotFoundError, "No property could be fo und for the given ID.");
925 return false;
926 }
927 return inspectorStyle->setPropertyText(propertyIndex, text, overwrite, excep tionState);
928 }
929
930 bool InspectorStyleSheetBase::getStyleText(unsigned ruleIndex, String* text)
931 {
932 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = inspectorStyleAt(ruleInd ex);
933 if (!inspectorStyle)
934 return false;
935 return inspectorStyle->styleText(text);
936 }
937
938 void InspectorStyleSheetBase::onStyleSheetTextChanged() 782 void InspectorStyleSheetBase::onStyleSheetTextChanged()
939 { 783 {
940 m_lineEndings = adoptPtr(new LineEndings()); 784 m_lineEndings = adoptPtr(new LineEndings());
941 if (listener()) 785 if (listener())
942 listener()->styleSheetChanged(this); 786 listener()->styleSheetChanged(this);
943 } 787 }
944 788
945 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyleSheetBase::buildObjectForSt yle(CSSStyleDeclaration* style) 789 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyleSheetBase::buildObjectForSt yle(CSSStyleDeclaration* style)
946 { 790 {
947 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = nullptr; 791 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = nullptr;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 if (lineNumber >= endings->size()) 831 if (lineNumber >= endings->size())
988 return false; 832 return false;
989 unsigned charactersInLine = lineNumber > 0 ? endings->at(lineNumber) - endin gs->at(lineNumber - 1) - 1 : endings->at(0); 833 unsigned charactersInLine = lineNumber > 0 ? endings->at(lineNumber) - endin gs->at(lineNumber - 1) - 1 : endings->at(0);
990 if (columnNumber > charactersInLine) 834 if (columnNumber > charactersInLine)
991 return false; 835 return false;
992 TextPosition position(OrdinalNumber::fromZeroBasedInt(lineNumber), OrdinalNu mber::fromZeroBasedInt(columnNumber)); 836 TextPosition position(OrdinalNumber::fromZeroBasedInt(lineNumber), OrdinalNu mber::fromZeroBasedInt(columnNumber));
993 *offset = position.toOffset(*endings).zeroBasedInt(); 837 *offset = position.toOffset(*endings).zeroBasedInt();
994 return true; 838 return true;
995 } 839 }
996 840
997 bool InspectorStyleSheetBase::findPropertyByRange(const SourceRange& sourceRange , unsigned* ruleIndex, unsigned* propertyIndex, bool* overwrite)
998 {
999 if (!ensureParsedDataReady())
1000 return false;
1001 for (size_t i = 0; i < ruleCount(); ++i) {
1002 RefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceData = ruleSourceDataAt( i);
1003 RefPtrWillBeRawPtr<CSSStyleSourceData> styleSourceData = ruleSourceData- >styleSourceData;
1004 if (!styleSourceData)
1005 continue;
1006 if (ruleSourceData->ruleBodyRange.end < sourceRange.start || sourceRange .end < ruleSourceData->ruleBodyRange.start)
1007 continue;
1008 WillBeHeapVector<CSSPropertySourceData>& propertyData = styleSourceData- >propertyData;
1009 for (size_t j = 0; j < propertyData.size(); ++j) {
1010 CSSPropertySourceData& property = propertyData.at(j);
1011 unsigned styleStart = ruleSourceData->ruleBodyRange.start;
1012 if (sourceRange.length() && property.range.start == sourceRange.star t && property.range.end == sourceRange.end) {
1013 *ruleIndex = i;
1014 *propertyIndex = j;
1015 *overwrite = true;
1016 return true;
1017 }
1018 if (!sourceRange.length() && styleStart <= sourceRange.start && sour ceRange.start <= property.range.start) {
1019 *ruleIndex = i;
1020 *propertyIndex = j;
1021 *overwrite = false;
1022 return true;
1023 }
1024 }
1025 if (!sourceRange.length() && ruleSourceData->ruleBodyRange.start <= sour ceRange.start && sourceRange.start <= ruleSourceData->ruleBodyRange.end) {
1026 *ruleIndex = i;
1027 *propertyIndex = propertyData.size();
1028 *overwrite = false;
1029 return true;
1030 }
1031 }
1032 return false;
1033 }
1034
1035 PassRefPtrWillBeRawPtr<InspectorStyleSheet> InspectorStyleSheet::create(Inspecto rResourceAgent* resourceAgent, const String& id, PassRefPtrWillBeRawPtr<CSSStyle Sheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const St ring& documentURL, InspectorCSSAgent* cssAgent) 841 PassRefPtrWillBeRawPtr<InspectorStyleSheet> InspectorStyleSheet::create(Inspecto rResourceAgent* resourceAgent, const String& id, PassRefPtrWillBeRawPtr<CSSStyle Sheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const St ring& documentURL, InspectorCSSAgent* cssAgent)
1036 { 842 {
1037 return adoptRefWillBeNoop(new InspectorStyleSheet(resourceAgent, id, pageSty leSheet, origin, documentURL, cssAgent)); 843 return adoptRefWillBeNoop(new InspectorStyleSheet(resourceAgent, id, pageSty leSheet, origin, documentURL, cssAgent));
1038 } 844 }
1039 845
1040 InspectorStyleSheet::InspectorStyleSheet(InspectorResourceAgent* resourceAgent, const String& id, PassRefPtrWillBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuil der::CSS::StyleSheetOrigin::Enum origin, const String& documentURL, InspectorCSS Agent* cssAgent) 846 InspectorStyleSheet::InspectorStyleSheet(InspectorResourceAgent* resourceAgent, const String& id, PassRefPtrWillBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuil der::CSS::StyleSheetOrigin::Enum origin, const String& documentURL, InspectorCSS Agent* cssAgent)
1041 : InspectorStyleSheetBase(id, cssAgent) 847 : InspectorStyleSheetBase(id, cssAgent)
1042 , m_cssAgent(cssAgent) 848 , m_cssAgent(cssAgent)
1043 , m_resourceAgent(resourceAgent) 849 , m_resourceAgent(resourceAgent)
1044 , m_pageStyleSheet(pageStyleSheet) 850 , m_pageStyleSheet(pageStyleSheet)
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 } 1533 }
1728 } 1534 }
1729 1535
1730 void InspectorStyleSheet::ensureFlatRules() const 1536 void InspectorStyleSheet::ensureFlatRules() const
1731 { 1537 {
1732 // We are fine with redoing this for empty stylesheets as this will run fast . 1538 // We are fine with redoing this for empty stylesheets as this will run fast .
1733 if (m_flatRules.isEmpty()) 1539 if (m_flatRules.isEmpty())
1734 collectFlatRules(pageStyleSheet(), &m_flatRules); 1540 collectFlatRules(pageStyleSheet(), &m_flatRules);
1735 } 1541 }
1736 1542
1737 bool InspectorStyleSheet::setStyleText(unsigned ruleIndex, const String& text)
1738 {
1739 CSSStyleDeclaration* style = styleAt(ruleIndex);
1740 if (!style)
1741 return false;
1742
1743 if (!ensureParsedDataReady())
1744 return false;
1745
1746 String patchedStyleSheetText;
1747 bool success = styleSheetTextWithChangedStyle(style, text, &patchedStyleShee tText);
1748 if (!success)
1749 return false;
1750
1751 TrackExceptionState exceptionState;
1752 style->setCSSText(text, exceptionState);
1753 if (!exceptionState.hadException()) {
1754 innerSetText(patchedStyleSheetText);
1755 onStyleSheetTextChanged();
1756 }
1757
1758 return !exceptionState.hadException();
1759 }
1760
1761 bool InspectorStyleSheet::styleSheetTextWithChangedStyle(CSSStyleDeclaration* st yle, const String& newStyleText, String* result)
1762 {
1763 if (!style)
1764 return false;
1765
1766 unsigned ruleIndex = indexOf(style);
1767 if (!ensureParsedDataReady() || ruleIndex == UINT_MAX)
1768 return false;
1769
1770 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = ruleSourceDataAt(ruleInde x);
1771 unsigned bodyStart = sourceData->ruleBodyRange.start;
1772 unsigned bodyEnd = sourceData->ruleBodyRange.end;
1773 ASSERT(bodyStart <= bodyEnd);
1774
1775 String text = m_parsedStyleSheet->text();
1776 ASSERT_WITH_SECURITY_IMPLICATION(bodyEnd <= text.length()); // bodyEnd is ex clusive
1777
1778 text.replace(bodyStart, bodyEnd - bodyStart, newStyleText);
1779 *result = text;
1780 return true;
1781 }
1782
1783 unsigned InspectorStyleSheet::indexOf(CSSStyleRule* rule) const 1543 unsigned InspectorStyleSheet::indexOf(CSSStyleRule* rule) const
1784 { 1544 {
1785 return indexOf(rule->style()); 1545 return indexOf(rule->style());
1786 } 1546 }
1787 1547
1788 bool InspectorStyleSheet::originalStyleSheetText(String* result) const 1548 bool InspectorStyleSheet::originalStyleSheetText(String* result) const
1789 { 1549 {
1790 bool success = inlineStyleSheetText(result); 1550 bool success = inlineStyleSheetText(result);
1791 if (!success) 1551 if (!success)
1792 success = resourceStyleSheetText(result); 1552 success = resourceStyleSheetText(result);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 m_ruleSourceData.clear(); 1617 m_ruleSourceData.clear();
1858 } 1618 }
1859 1619
1860 bool InspectorStyleSheetForInlineStyle::setText(const String& text, ExceptionSta te& exceptionState) 1620 bool InspectorStyleSheetForInlineStyle::setText(const String& text, ExceptionSta te& exceptionState)
1861 { 1621 {
1862 if (!verifyStyleText(ownerDocument(), text)) { 1622 if (!verifyStyleText(ownerDocument(), text)) {
1863 exceptionState.throwDOMException(SyntaxError, "Style text is not valid." ); 1623 exceptionState.throwDOMException(SyntaxError, "Style text is not valid." );
1864 return false; 1624 return false;
1865 } 1625 }
1866 1626
1867 bool success = setStyleText(0, text);
1868 if (!success)
1869 exceptionState.throwDOMException(SyntaxError, "Style sheet text is inval id.");
1870 return success;
1871 }
1872
1873 bool InspectorStyleSheetForInlineStyle::getText(String* result) const
1874 {
1875 if (!m_isStyleTextValid) {
1876 m_styleText = elementStyleText();
1877 m_isStyleTextValid = true;
1878 }
1879 *result = m_styleText;
1880 return true;
1881 }
1882
1883 bool InspectorStyleSheetForInlineStyle::setStyleText(unsigned ruleIndex, const S tring& text)
1884 {
1885 TrackExceptionState exceptionState;
1886 { 1627 {
1887 InspectorCSSAgent::InlineStyleOverrideScope overrideScope(m_element->own erDocument()); 1628 InspectorCSSAgent::InlineStyleOverrideScope overrideScope(m_element->own erDocument());
1888 m_element->setAttribute("style", AtomicString(text), exceptionState); 1629 m_element->setAttribute("style", AtomicString(text), exceptionState);
1889 } 1630 }
1890 if (!exceptionState.hadException()) { 1631 if (!exceptionState.hadException()) {
1891 m_styleText = text; 1632 m_styleText = text;
1892 m_isStyleTextValid = true; 1633 m_isStyleTextValid = true;
1893 m_ruleSourceData.clear(); 1634 m_ruleSourceData.clear();
1894 onStyleSheetTextChanged(); 1635 onStyleSheetTextChanged();
1895 } 1636 }
1896 return !exceptionState.hadException(); 1637 return !exceptionState.hadException();
1897 } 1638 }
1898 1639
1640 bool InspectorStyleSheetForInlineStyle::getText(String* result) const
1641 {
1642 if (!m_isStyleTextValid) {
1643 m_styleText = elementStyleText();
1644 m_isStyleTextValid = true;
1645 }
1646 *result = m_styleText;
1647 return true;
1648 }
1649
1899 Document* InspectorStyleSheetForInlineStyle::ownerDocument() const 1650 Document* InspectorStyleSheetForInlineStyle::ownerDocument() const
1900 { 1651 {
1901 return &m_element->document(); 1652 return &m_element->document();
1902 } 1653 }
1903 1654
1904 bool InspectorStyleSheetForInlineStyle::ensureParsedDataReady() 1655 bool InspectorStyleSheetForInlineStyle::ensureParsedDataReady()
1905 { 1656 {
1906 // The "style" property value can get changed indirectly, e.g. via element.s tyle.borderWidth = "2px". 1657 // The "style" property value can get changed indirectly, e.g. via element.s tyle.borderWidth = "2px".
1907 const String& currentStyleText = elementStyleText(); 1658 const String& currentStyleText = elementStyleText();
1908 if (m_styleText != currentStyleText) { 1659 if (m_styleText != currentStyleText) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 1712
1962 DEFINE_TRACE(InspectorStyleSheetForInlineStyle) 1713 DEFINE_TRACE(InspectorStyleSheetForInlineStyle)
1963 { 1714 {
1964 visitor->trace(m_element); 1715 visitor->trace(m_element);
1965 visitor->trace(m_ruleSourceData); 1716 visitor->trace(m_ruleSourceData);
1966 visitor->trace(m_inspectorStyle); 1717 visitor->trace(m_inspectorStyle);
1967 InspectorStyleSheetBase::trace(visitor); 1718 InspectorStyleSheetBase::trace(visitor);
1968 } 1719 }
1969 1720
1970 } // namespace blink 1721 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorStyleSheet.h ('k') | Source/core/inspector/InspectorStyleTextEditor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698