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

Unified Diff: lib/scoped_css.dart

Issue 19497002: Reducing the amount of code we generate in the compiler: We still continue (Closed) Base URL: git@github.com:dart-lang/web-ui.git@master
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: lib/scoped_css.dart
diff --git a/lib/scoped_css.dart b/lib/scoped_css.dart
new file mode 100644
index 0000000000000000000000000000000000000000..577dca7388f59f07d06780d8be436356825b39e5
--- /dev/null
+++ b/lib/scoped_css.dart
@@ -0,0 +1,43 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * This library contains support for scoped CSS that uses the compilation
+ * strategy of WebUI. This will likely become deprecated as we migrate over to
+ * use runtime mechanisms to enforce scoped css rules.
+ */
+library scoped_css;
+
+/**
+ * Maps CSS selectors (class and) to a mangled name and maps x-component name
+ * to [is='x-component'].
+ */
+class ScopedCssMapper {
+ final Map<String, String> _mapping;
+
+ ScopedCssMapper(this._mapping);
+
+ /** Returns mangled name of selector sans . or # character. */
+ String operator [](String selector) => _mapping[selector];
+
+ /** Returns mangled name of selector w/ . or # character. */
+ String getSelector(String selector) {
+ var prefixedName = this[selector];
+ var selectorType = selector[0];
+ if (selectorType == '.' || selectorType == '#') {
+ return '$selectorType${prefixedName}';
+ }
+
+ return prefixedName;
+ }
+}
+
+/** Any CSS selector (class, id or element) defined name to mangled name. */
+Map<String, ScopedCssMapper> _mappers = {};
+
+ScopedCssMapper getScopedCss(String componentName) => _mappers[componentName];
+
+void setScopedCss(String componentName, Map<String, String> mapping) {
+ _mappers.putIfAbsent(componentName, () => new ScopedCssMapper(mapping));
+}
« lib/polymer_element.dart ('K') | « lib/polymer_element.dart ('k') | lib/src/analyzer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698