Chromium Code Reviews| 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, const String& id, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSRule> >& keyframeSty les) | |
| 843 { | |
| 844 AnimationPlayer* player = m_domAgent->assertAnimationPlayer(errorString, id) ; | |
| 845 if (!player) | |
| 846 return; | |
| 847 | |
| 848 ASSERT(player->source()); | |
|
vsevik
2014/10/06 16:00:54
Why do you ASSERT that source is not null? Looks l
samli
2014/10/07 05:25:43
Done.
| |
| 849 // FIXME: Needs to consider AnimationGroup once added. | |
| 850 ASSERT(player->source()->isAnimation()); | |
| 851 const Animation& animation = *toAnimation(player->source()); | |
| 852 // FIXME: Needs to consider custom effects once added. | |
| 853 ASSERT(animation.effect()->isKeyframeEffectModel()); | |
| 854 const KeyframeEffectModelBase& effect = *toKeyframeEffectModelBase(animation .effect()); | |
| 855 WillBeHeapVector<RefPtrWillBeMember<Keyframe> > keyframes = KeyframeEffectMo delBase::normalizedKeyframes(effect.getFrames()); | |
| 856 keyframeStyles = TypeBuilder::Array<TypeBuilder::CSS::CSSRule>::create(); | |
|
vsevik
2014/10/06 16:00:54
This seems wrong. Not only you are abusing CSSRule
samli
2014/10/07 05:25:43
These keyframe styles are only shown for JS instan
| |
| 857 | |
| 858 for (WillBeHeapVector<RefPtrWillBeMember<Keyframe> >::const_iterator i = key frames.begin(); i != keyframes.end(); ++i) { | |
| 859 if (!i->get()->isStringKeyframe()) | |
| 860 continue; | |
| 861 | |
| 862 // Convert keyframe into CSSStyleRule | |
| 863 const StringKeyframe& stringKeyframe = *toStringKeyframe(i->get()); | |
| 864 RefPtr<StyleRule> styleRule = StyleRule::create(); | |
| 865 styleRule->setProperties(stringKeyframe.propertySet()); | |
| 866 if (!m_inspectorUserAgentStyleSheet) | |
| 867 m_inspectorUserAgentStyleSheet = CSSStyleSheet::create(CSSDefaultSty leSheets::instance().defaultStyleSheet()); | |
| 868 RefPtr<CSSStyleRule> cssStyleRule = CSSStyleRule::create(styleRule.get() , m_inspectorUserAgentStyleSheet.get()); | |
| 869 | |
| 870 // Convert offset | |
| 871 Decimal decimal = Decimal::fromDouble(stringKeyframe.offset() * 100); | |
| 872 String offset = decimal.toString(); | |
| 873 offset.append("%"); | |
| 874 | |
| 875 // Cannot set selector text directly since keyframe offset is not a vali d | |
| 876 // selector and will be discarded. Instead, construct CSSRule from scrat ch | |
| 877 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectors = Type Builder::Array<TypeBuilder::CSS::Selector>::create(); | |
| 878 selectors->addItem(TypeBuilder::CSS::Selector::create().setValue(offset) .release()); | |
| 879 RefPtr<TypeBuilder::CSS::SelectorList> selectorList = TypeBuilder::CSS:: SelectorList::create() | |
| 880 .setSelectors(selectors) | |
| 881 .setText("") | |
| 882 .release(); | |
| 883 | |
| 884 RefPtr<TypeBuilder::CSS::CSSRule> cssRule = TypeBuilder::CSS::CSSRule::c reate() | |
| 885 .setSelectorList(selectorList) | |
| 886 .setOrigin(TypeBuilder::CSS::StyleSheetOrigin::Inspector) | |
| 887 .setStyle(bindStyleSheet(cssStyleRule->parentStyleSheet())->buildObj ectForStyle(cssStyleRule->style())) | |
| 888 .release(); | |
| 889 | |
| 890 keyframeStyles->addItem(cssRule); | |
| 891 } | |
| 892 } | |
| 893 | |
| 835 static bool extractRangeComponent(ErrorString* errorString, const RefPtr<JSONObj ect>& range, const String& component, unsigned& result) | 894 static bool extractRangeComponent(ErrorString* errorString, const RefPtr<JSONObj ect>& range, const String& component, unsigned& result) |
| 836 { | 895 { |
| 837 int parsedValue = 0; | 896 int parsedValue = 0; |
| 838 if (!range->getNumber(component, &parsedValue) || parsedValue < 0) { | 897 if (!range->getNumber(component, &parsedValue) || parsedValue < 0) { |
| 839 *errorString = "range." + component + " must be a non-negative integer"; | 898 *errorString = "range." + component + " must be a non-negative integer"; |
| 840 return false; | 899 return false; |
| 841 } | 900 } |
| 842 result = parsedValue; | 901 result = parsedValue; |
| 843 return true; | 902 return true; |
| 844 } | 903 } |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1467 visitor->trace(m_invalidatedDocuments); | 1526 visitor->trace(m_invalidatedDocuments); |
| 1468 visitor->trace(m_nodeToInspectorStyleSheet); | 1527 visitor->trace(m_nodeToInspectorStyleSheet); |
| 1469 visitor->trace(m_documentToViaInspectorStyleSheet); | 1528 visitor->trace(m_documentToViaInspectorStyleSheet); |
| 1470 #endif | 1529 #endif |
| 1471 visitor->trace(m_inspectorUserAgentStyleSheet); | 1530 visitor->trace(m_inspectorUserAgentStyleSheet); |
| 1472 InspectorBaseAgent::trace(visitor); | 1531 InspectorBaseAgent::trace(visitor); |
| 1473 } | 1532 } |
| 1474 | 1533 |
| 1475 } // namespace blink | 1534 } // namespace blink |
| 1476 | 1535 |
| OLD | NEW |