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

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

Issue 339553004: DevTools: [MediaQueryInspector] Compute media query length on backend (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 23 matching lines...) Expand all
34 #include "core/css/CSSComputedStyleDeclaration.h" 34 #include "core/css/CSSComputedStyleDeclaration.h"
35 #include "core/css/CSSDefaultStyleSheets.h" 35 #include "core/css/CSSDefaultStyleSheets.h"
36 #include "core/css/CSSImportRule.h" 36 #include "core/css/CSSImportRule.h"
37 #include "core/css/CSSMediaRule.h" 37 #include "core/css/CSSMediaRule.h"
38 #include "core/css/CSSRule.h" 38 #include "core/css/CSSRule.h"
39 #include "core/css/CSSRuleList.h" 39 #include "core/css/CSSRuleList.h"
40 #include "core/css/CSSStyleRule.h" 40 #include "core/css/CSSStyleRule.h"
41 #include "core/css/CSSStyleSheet.h" 41 #include "core/css/CSSStyleSheet.h"
42 #include "core/css/MediaList.h" 42 #include "core/css/MediaList.h"
43 #include "core/css/MediaQuery.h" 43 #include "core/css/MediaQuery.h"
44 #include "core/css/MediaValues.h"
44 #include "core/css/StylePropertySet.h" 45 #include "core/css/StylePropertySet.h"
45 #include "core/css/StyleRule.h" 46 #include "core/css/StyleRule.h"
46 #include "core/css/StyleSheet.h" 47 #include "core/css/StyleSheet.h"
47 #include "core/css/StyleSheetContents.h" 48 #include "core/css/StyleSheetContents.h"
48 #include "core/css/StyleSheetList.h" 49 #include "core/css/StyleSheetList.h"
49 #include "core/css/resolver/StyleResolver.h" 50 #include "core/css/resolver/StyleResolver.h"
50 #include "core/dom/Node.h" 51 #include "core/dom/Node.h"
51 #include "core/dom/NodeList.h" 52 #include "core/dom/NodeList.h"
52 #include "core/fetch/CSSStyleSheetResource.h" 53 #include "core/fetch/CSSStyleSheetResource.h"
53 #include "core/fetch/ResourceClient.h" 54 #include "core/fetch/ResourceClient.h"
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 for (size_t j = 0; j < expressions.size(); ++j) { 1018 for (size_t j = 0; j < expressions.size(); ++j) {
1018 MediaQueryExp* mediaQueryExp = expressions.at(j).get(); 1019 MediaQueryExp* mediaQueryExp = expressions.at(j).get();
1019 MediaQueryExpValue expValue = mediaQueryExp->expValue(); 1020 MediaQueryExpValue expValue = mediaQueryExp->expValue();
1020 if (!expValue.isValue) 1021 if (!expValue.isValue)
1021 continue; 1022 continue;
1022 const char* valueName = CSSPrimitiveValue::unitTypeToString(expValue .unit); 1023 const char* valueName = CSSPrimitiveValue::unitTypeToString(expValue .unit);
1023 RefPtr<TypeBuilder::CSS::MediaQueryExpression> mediaQueryExpression = TypeBuilder::CSS::MediaQueryExpression::create() 1024 RefPtr<TypeBuilder::CSS::MediaQueryExpression> mediaQueryExpression = TypeBuilder::CSS::MediaQueryExpression::create()
1024 .setValue(expValue.value) 1025 .setValue(expValue.value)
1025 .setUnit(String(valueName)) 1026 .setUnit(String(valueName))
1026 .setFeature(mediaQueryExp->mediaFeature()); 1027 .setFeature(mediaQueryExp->mediaFeature());
1028 RefPtr<MediaValues> mediaValues = MediaValues::createDynamicIfFrameE xists(parentStyleSheet->ownerDocument()->frame());
1029 int computedLength;
1030 if (mediaValues->computeLength(expValue.value, expValue.unit, comput edLength))
1031 mediaQueryExpression->setComputedLength(computedLength);
1032
1027 expressionArray->addItem(mediaQueryExpression); 1033 expressionArray->addItem(mediaQueryExpression);
1028 hasExpressionItems = true; 1034 hasExpressionItems = true;
1029 } 1035 }
1030 if (hasExpressionItems) { 1036 if (hasExpressionItems) {
1031 mediaListArray->addItem(expressionArray); 1037 mediaListArray->addItem(expressionArray);
1032 hasMediaQueryItems = true; 1038 hasMediaQueryItems = true;
1033 } 1039 }
1034 } 1040 }
1035 1041
1036 RefPtr<TypeBuilder::CSS::CSSMedia> mediaObject = TypeBuilder::CSS::CSSMedia: :create() 1042 RefPtr<TypeBuilder::CSS::CSSMedia> mediaObject = TypeBuilder::CSS::CSSMedia: :create()
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 documentsToChange.add(element->ownerDocument()); 1452 documentsToChange.add(element->ownerDocument());
1447 } 1453 }
1448 1454
1449 m_nodeIdToForcedPseudoState.clear(); 1455 m_nodeIdToForcedPseudoState.clear();
1450 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1456 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1451 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); 1457 (*it)->setNeedsStyleRecalc(SubtreeStyleChange);
1452 } 1458 }
1453 1459
1454 } // namespace WebCore 1460 } // namespace WebCore
1455 1461
OLDNEW
« no previous file with comments | « LayoutTests/inspector-protocol/css/css-get-media-queries-expected.txt ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698