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 12 matching lines...) Expand all Loading... | |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #include "core/inspector/InspectorCSSAgent.h" | 26 #include "core/inspector/InspectorCSSAgent.h" |
27 | 27 |
28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
30 #include "core/CSSPropertyNames.h" | 30 #include "core/CSSPropertyNames.h" |
31 #include "core/InspectorTypeBuilder.h" | 31 #include "core/InspectorTypeBuilder.h" |
32 #include "core/StylePropertyShorthand.h" | 32 #include "core/StylePropertyShorthand.h" |
33 #include "core/animation/Animation.h" | |
34 #include "core/animation/AnimationEffect.h" | |
35 #include "core/animation/AnimationNode.h" | |
36 #include "core/animation/AnimationPlayer.h" | |
37 #include "core/animation/ElementAnimation.h" | |
38 #include "core/animation/KeyframeEffectModel.h" | |
33 #include "core/css/CSSComputedStyleDeclaration.h" | 39 #include "core/css/CSSComputedStyleDeclaration.h" |
34 #include "core/css/CSSDefaultStyleSheets.h" | 40 #include "core/css/CSSDefaultStyleSheets.h" |
35 #include "core/css/CSSImportRule.h" | 41 #include "core/css/CSSImportRule.h" |
36 #include "core/css/CSSMediaRule.h" | 42 #include "core/css/CSSMediaRule.h" |
37 #include "core/css/CSSRule.h" | 43 #include "core/css/CSSRule.h" |
38 #include "core/css/CSSRuleList.h" | 44 #include "core/css/CSSRuleList.h" |
39 #include "core/css/CSSStyleRule.h" | 45 #include "core/css/CSSStyleRule.h" |
40 #include "core/css/CSSStyleSheet.h" | 46 #include "core/css/CSSStyleSheet.h" |
41 #include "core/css/MediaList.h" | 47 #include "core/css/MediaList.h" |
42 #include "core/css/MediaQuery.h" | 48 #include "core/css/MediaQuery.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
59 #include "core/inspector/InspectorResourceContentLoader.h" | 65 #include "core/inspector/InspectorResourceContentLoader.h" |
60 #include "core/inspector/InspectorState.h" | 66 #include "core/inspector/InspectorState.h" |
61 #include "core/inspector/InstrumentingAgents.h" | 67 #include "core/inspector/InstrumentingAgents.h" |
62 #include "core/loader/DocumentLoader.h" | 68 #include "core/loader/DocumentLoader.h" |
63 #include "core/page/Page.h" | 69 #include "core/page/Page.h" |
64 #include "core/rendering/InlineTextBox.h" | 70 #include "core/rendering/InlineTextBox.h" |
65 #include "core/rendering/RenderObject.h" | 71 #include "core/rendering/RenderObject.h" |
66 #include "core/rendering/RenderObjectInlines.h" | 72 #include "core/rendering/RenderObjectInlines.h" |
67 #include "core/rendering/RenderText.h" | 73 #include "core/rendering/RenderText.h" |
68 #include "core/rendering/RenderTextFragment.h" | 74 #include "core/rendering/RenderTextFragment.h" |
75 #include "platform/Decimal.h" | |
69 #include "platform/fonts/Font.h" | 76 #include "platform/fonts/Font.h" |
70 #include "platform/fonts/GlyphBuffer.h" | 77 #include "platform/fonts/GlyphBuffer.h" |
71 #include "platform/fonts/SimpleShaper.h" | 78 #include "platform/fonts/SimpleShaper.h" |
72 #include "platform/text/TextRun.h" | 79 #include "platform/text/TextRun.h" |
73 #include "wtf/CurrentTime.h" | 80 #include "wtf/CurrentTime.h" |
74 #include "wtf/text/CString.h" | 81 #include "wtf/text/CString.h" |
75 #include "wtf/text/StringConcatenate.h" | 82 #include "wtf/text/StringConcatenate.h" |
76 | 83 |
77 namespace CSSAgentState { | 84 namespace CSSAgentState { |
78 static const char cssAgentEnabled[] = "cssAgentEnabled"; | 85 static const char cssAgentEnabled[] = "cssAgentEnabled"; |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
825 if (!inspectorStyleSheet) { | 832 if (!inspectorStyleSheet) { |
826 *errorString = "Style sheet with id " + styleSheetId + " not found"; | 833 *errorString = "Style sheet with id " + styleSheetId + " not found"; |
827 return; | 834 return; |
828 } | 835 } |
829 | 836 |
830 TrackExceptionState exceptionState; | 837 TrackExceptionState exceptionState; |
831 m_domAgent->history()->perform(adoptRefWillBeNoop(new SetStyleSheetTextActio n(inspectorStyleSheet, text)), exceptionState); | 838 m_domAgent->history()->perform(adoptRefWillBeNoop(new SetStyleSheetTextActio n(inspectorStyleSheet, text)), exceptionState); |
832 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 839 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
833 } | 840 } |
834 | 841 |
842 void InspectorCSSAgent::getKeyframeStylesForNode(ErrorString* errorString, int s equenceNumber, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSRule> >& keyframeS tyles) | |
843 { | |
844 keyframeStyles = TypeBuilder::Array<TypeBuilder::CSS::CSSRule>::create(); | |
845 AnimationPlayer& player = *(m_domAgent->m_idToAnimationPlayer.get(sequenceNu mber)); | |
caseq
2014/10/02 09:48:01
You can't expect client to provide a valid id, ple
samli
2014/10/03 06:05:04
Done.
| |
846 ASSERT(player.source()); | |
847 // FIXME: Needs to consider AnimationGroup once added. | |
848 ASSERT(player.source()->isAnimation()); | |
849 const Animation& animation = *toAnimation(player.source()); | |
850 // FIXME: Needs to consider custom effects once added. | |
851 ASSERT(animation.effect()->isKeyframeEffectModel()); | |
852 const KeyframeEffectModelBase& effect = *toKeyframeEffectModelBase(animation .effect()); | |
853 WillBeHeapVector<RefPtrWillBeMember<Keyframe> > keyframes = KeyframeEffectMo delBase::normalizedKeyframes(effect.getFrames()); | |
854 | |
855 for (WillBeHeapVector<RefPtrWillBeMember<Keyframe> >::const_iterator i = key frames.begin(); i != keyframes.end(); ++i) { | |
856 if (i->get()->isStringKeyframe()) { | |
caseq
2014/10/02 09:48:01
nit: we prefer early bail-out, i.e:
if (!i->get()
samli
2014/10/03 06:05:04
Done.
| |
857 // Convert keyframe into CSSStyleRule | |
858 const StringKeyframe& stringKeyframe = *toStringKeyframe(i->get()); | |
859 RefPtr<StyleRule> styleRule = StyleRule::create(); | |
860 styleRule->setProperties(stringKeyframe.propertySet()); | |
861 if (!m_inspectorUserAgentStyleSheet) | |
862 m_inspectorUserAgentStyleSheet = CSSStyleSheet::create(CSSDefaul tStyleSheets::instance().defaultStyleSheet()); | |
863 RefPtr<CSSStyleRule> cssStyleRule = CSSStyleRule::create(styleRule.g et(), m_inspectorUserAgentStyleSheet.get()); | |
864 | |
865 // Convert offset | |
866 Decimal decimal = Decimal::fromDouble(stringKeyframe.offset() * 100) ; | |
867 String offset = decimal.toString(); | |
868 offset.append("%"); | |
caseq
2014/10/02 09:48:01
unused?
samli
2014/10/03 06:05:04
It's used below in the selector text. 873
This all
| |
869 | |
870 // Cannot set selector directly since isn't a valid selector and wil l be discarded | |
871 // Construct CSSRule from scratch | |
872 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectors = TypeBuilder::Array<TypeBuilder::CSS::Selector>::create(); | |
873 selectors->addItem(TypeBuilder::CSS::Selector::create().setValue(off set).release()); | |
874 RefPtr<TypeBuilder::CSS::SelectorList> selectorList = TypeBuilder::C SS::SelectorList::create() | |
875 .setSelectors(selectors) | |
876 .setText("") | |
877 .release(); | |
878 | |
879 RefPtr<TypeBuilder::CSS::CSSRule> cssRule = TypeBuilder::CSS::CSSRul e::create() | |
880 .setSelectorList(selectorList) | |
881 .setOrigin(TypeBuilder::CSS::StyleSheetOrigin::Inspector) | |
882 .setStyle(bindStyleSheet(cssStyleRule->parentStyleSheet())->buil dObjectForStyle(cssStyleRule->style())) | |
883 .release(); | |
884 | |
885 keyframeStyles->addItem(cssRule); | |
886 } | |
887 } | |
888 } | |
889 | |
835 static bool extractRangeComponent(ErrorString* errorString, const RefPtr<JSONObj ect>& range, const String& component, unsigned& result) | 890 static bool extractRangeComponent(ErrorString* errorString, const RefPtr<JSONObj ect>& range, const String& component, unsigned& result) |
836 { | 891 { |
837 int parsedValue = 0; | 892 int parsedValue = 0; |
838 if (!range->getNumber(component, &parsedValue) || parsedValue < 0) { | 893 if (!range->getNumber(component, &parsedValue) || parsedValue < 0) { |
839 *errorString = "range." + component + " must be a non-negative integer"; | 894 *errorString = "range." + component + " must be a non-negative integer"; |
840 return false; | 895 return false; |
841 } | 896 } |
842 result = parsedValue; | 897 result = parsedValue; |
843 return true; | 898 return true; |
844 } | 899 } |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1467 visitor->trace(m_invalidatedDocuments); | 1522 visitor->trace(m_invalidatedDocuments); |
1468 visitor->trace(m_nodeToInspectorStyleSheet); | 1523 visitor->trace(m_nodeToInspectorStyleSheet); |
1469 visitor->trace(m_documentToViaInspectorStyleSheet); | 1524 visitor->trace(m_documentToViaInspectorStyleSheet); |
1470 #endif | 1525 #endif |
1471 visitor->trace(m_inspectorUserAgentStyleSheet); | 1526 visitor->trace(m_inspectorUserAgentStyleSheet); |
1472 InspectorBaseAgent::trace(visitor); | 1527 InspectorBaseAgent::trace(visitor); |
1473 } | 1528 } |
1474 | 1529 |
1475 } // namespace blink | 1530 } // namespace blink |
1476 | 1531 |
OLD | NEW |