Home | History | Annotate | Download | only in platform

Lines Matching full:scopename

1 n    'data': 'HTMLDataElement',\n    'dir': 'HTMLDirectoryElement',\n    'div': 'HTMLDivElement',\n    'embed': 'HTMLEmbedElement',\n    'fieldset': 'HTMLFieldSetElement',\n    'font': 'HTMLFontElement',\n    'form': 'HTMLFormElement',\n    'frame': 'HTMLFrameElement',\n    'frameset': 'HTMLFrameSetElement',\n    'hr': 'HTMLHRElement',\n    'head': 'HTMLHeadElement',\n    'h1': 'HTMLHeadingElement',\n    'html': 'HTMLHtmlElement',\n    'iframe': 'HTMLIFrameElement',\n    'input': 'HTMLInputElement',\n    'li': 'HTMLLIElement',\n    'label': 'HTMLLabelElement',\n    'legend': 'HTMLLegendElement',\n    'link': 'HTMLLinkElement',\n    'map': 'HTMLMapElement',\n    'marquee': 'HTMLMarqueeElement',\n    'menu': 'HTMLMenuElement',\n    'menuitem': 'HTMLMenuItemElement',\n    'meta': 'HTMLMetaElement',\n    'meter': 'HTMLMeterElement',\n    'del': 'HTMLModElement',\n    'ol': 'HTMLOListElement',\n    'object': 'HTMLObjectElement',\n    'optgroup': 'HTMLOptGroupElement',\n    'option': 'HTMLOptionElement',\n    'output': 'HTMLOutputElement',\n    'p': 'HTMLParagraphElement',\n    'param': 'HTMLParamElement',\n    'pre': 'HTMLPreElement',\n    'progress': 'HTMLProgressElement',\n    'q': 'HTMLQuoteElement',\n    'script': 'HTMLScriptElement',\n    'select': 'HTMLSelectElement',\n    'source': 'HTMLSourceElement',\n    'span': 'HTMLSpanElement',\n    'style': 'HTMLStyleElement',\n    'time': 'HTMLTimeElement',\n    'caption': 'HTMLTableCaptionElement',\n    // WebKit and Moz are wrong:\n    // https://bugs.webkit.org/show_bug.cgi?id=111469\n    // https://bugzilla.mozilla.org/show_bug.cgi?id=848096\n    // 'td': 'HTMLTableCellElement',\n    'col': 'HTMLTableColElement',\n    'table': 'HTMLTableElement',\n    'tr': 'HTMLTableRowElement',\n    'thead': 'HTMLTableSectionElement',\n    'tbody': 'HTMLTableSectionElement',\n    'textarea': 'HTMLTextAreaElement',\n    'track': 'HTMLTrackElement',\n    'title': 'HTMLTitleElement',\n    'ul': 'HTMLUListElement',\n    'video': 'HTMLVideoElement',\n  };\n\n  function overrideConstructor(tagName) {\n    var nativeConstructorName = elements[tagName];\n    var nativeConstructor = window[nativeConstructorName];\n    if (!nativeConstructor)\n      return;\n    var element = document.createElement(tagName);\n    var wrapperConstructor = element.constructor;\n    window[nativeConstructorName] = wrapperConstructor;\n  }\n\n  Object.keys(elements).forEach(overrideConstructor);\n\n  Object.getOwnPropertyNames(scope.wrappers).forEach(function(name) {\n    window[name] = scope.wrappers[name]\n  });\n\n  // Export for testing.\n  scope.knownElements = elements;\n\n})(window.ShadowDOMPolyfill);\n","/*\n * Copyright 2013 The Polymer Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\n(function() {\n\n  // convenient global\n  window.wrap = ShadowDOMPolyfill.wrapIfNeeded;\n  window.unwrap = ShadowDOMPolyfill.unwrapIfNeeded;\n\n  // users may want to customize other types\n  // TODO(sjmiles): 'button' is now supported by ShadowDOMPolyfill, but\n  // I've left this code here in case we need to temporarily patch another\n  // type\n  /*\n  (function() {\n    var elts = {HTMLButtonElement: 'button'};\n    for (var c in elts) {\n      window[c] = function() { throw 'Patched Constructor'; };\n      window[c].prototype = Object.getPrototypeOf(\n          document.createElement(elts[c]));\n    }\n  })();\n  */\n\n  // patch in prefixed name\n  Object.defineProperty(Element.prototype, 'webkitShadowRoot',\n      Object.getOwnPropertyDescriptor(Element.prototype, 'shadowRoot'));\n\n  var originalCreateShadowRoot = Element.prototype.createShadowRoot;\n  Element.prototype.createShadowRoot = function() {\n    var root = originalCreateShadowRoot.call(this);\n    CustomElements.watchShadow(this);\n    return root;\n  };\n\n  Element.prototype.webkitCreateShadowRoot = Element.prototype.createShadowRoot;\n})();\n","/*\n * Copyright 2012 The Polymer Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n/*\n  This is a limited shim for ShadowDOM css styling.\n  https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles\n  \n  The intention here is to support only the styling features which can be \n  relatively simply implemented. The goal is to allow users to avoid the \n  most obvious pitfalls and do so without compromising performance significantly. \n  For ShadowDOM styling that's not covered here, a set of best practices\n  can be provided that should allow users to accomplish more complex styling.\n\n  The following is a list of specific ShadowDOM styling features and a brief\n  discussion of the approach used to shim.\n\n  Shimmed features:\n\n  * @host: ShadowDOM allows styling of the shadowRoot's host element using the \n  @host rule. To shim this feature, the @host styles are reformatted and \n  prefixed with a given scope name and promoted to a document level stylesheet.\n  For example, given a scope name of .foo, a rule like this:\n  \n    @host {\n      * {\n        background: red;\n      }\n    }\n  \n  becomes:\n  \n    .foo {\n      background: red;\n    }\n  \n  * encapsultion: Styles defined within ShadowDOM, apply only to \n  dom inside the ShadowDOM. Polymer uses one of two techniques to imlement\n  this feature.\n  \n  By default, rules are prefixed with the host element tag name \n  as a descendant selector. This ensures styling does not leak out of the 'top'\n  of the element's ShadowDOM. For example,\n\n  div {\n      font-weight: bold;\n    }\n  \n  becomes:\n\n  x-foo div {\n      font-weight: bold;\n    }\n  \n  becomes:\n\n\n  Alternatively, if Platform.ShadowCSS.strictStyling is set to true then \n  selectors are scoped by adding an attribute selector suffix to each\n  simple selector that contains the host element tag name. Each element \n  in the element's ShadowDOM template is also given the scope attribute. \n  Thus, these rules match only elements that have the scope attribute.\n  For example, given a scope name of x-foo, a rule like this:\n  \n    div {\n      font-weight: bold;\n    }\n  \n  becomes:\n  \n    div[x-foo] {\n      font-weight: bold;\n    }\n\n  Note that elements that are dynamically added to a scope must have the scope\n  selector added to them manually.\n\n  * ::pseudo: These rules are converted to rules that take advantage of the\n  pseudo attribute. For example, a shadowRoot like this inside an x-foo\n\n    <div pseudo=\"x-special\">Special</div>\n\n  with a rule like this:\n\n    x-foo::x-special { ... }\n\n  becomes:\n\n    x-foo [pseudo=x-special] { ... }\n\n  * ::part(): These rules are converted to rules that take advantage of the\n  part attribute. For example, a shadowRoot like this inside an x-foo\n\n    <div part=\"special\">Special</div>\n\n  with a rule like this:\n\n    x-foo::part(special) { ... }\n\n  becomes:\n\n    x-foo [part=special] { ... }    \n  \n  Unaddressed ShadowDOM styling features:\n  \n  * upper/lower bound encapsulation: Styles which are defined outside a\n  shadowRoot should not cross the ShadowDOM boundary and should not apply\n  inside a shadowRoot.\n\n  This styling behavior is not emulated. Some possible ways to do this that \n  were rejected due to complexity and/or performance concerns include: (1) reset\n  every possible property for every possible selector for a given scope name;\n  (2) re-implement css in javascript.\n  \n  As an alternative, users should make sure to use selectors\n  specific to the scope in which they are working.\n  \n  * ::distributed: This behavior is not emulated. It's often not necessary\n  to style the contents of a specific insertion point and instead, descendants\n  of the host element can be styled selectively. Users can also create an \n  extra node around an insertion point and style that node's contents\n  via descendent selectors. For example, with a shadowRoot like this:\n  \n    <style>\n      content::-webkit-distributed(div) {\n        background: red;\n      }\n    </style>\n    <content></content>\n  \n  could become:\n  \n    <style>\n      / *@polyfill .content-container div * / \n      content::-webkit-distributed(div) {\n        background: red;\n      }\n    </style>\n    <div class=\"content-container\">\n      <content></content>\n    </div>\n  \n  Note the use of @polyfill in the comment above a ShadowDOM specific style\n  declaration. This is a directive to the styling shim to use the selector \n  in comments in lieu of the next selector when running under polyfill.\n*/\n(function(scope) {\n\nvar ShadowCSS = {\n  strictStyling: false,\n  registry: {},\n  // Shim styles for a given root associated with a name and extendsName\n  // 1. cache root styles by name\n  // 2. optionally tag root nodes with scope name\n  // 3. shim polyfill directives /* @polyfill */ and /* @polyfill-rule */\n  // 4. shim @host and scoping\n  shimStyling: function(root, name, extendsName) {\n    var typeExtension = this.isTypeExtension(extendsName);\n    // use caching to make working with styles nodes easier and to facilitate\n    // lookup of extendee\n    var def = this.registerDefinition(root, name, extendsName);\n    // find styles and apply shimming...\n    if (this.strictStyling) {\n      this.applyScopeToContent(root, name);\n    }\n    var cssText = this.stylesToShimmedCssText(def.rootStyles, def.scopeStyles,\n        name, typeExtension);\n    // provide shimmedStyle for user extensibility\n    def.shimmedStyle = cssTextToStyle(cssText);\n    if (root) {\n      root.shimmedStyle = def.shimmedStyle;\n    }\n    // remove existing style elements\n    for (var i=0, l=def.rootStyles.length, s; (i<l) && (s=def.rootStyles[i]); \n        i++) {\n      s.parentNode.removeChild(s);\n    }\n    // add style to document\n    addCssToDocument(cssText);\n  },\n  // apply @polyfill rules + @host and scope shimming\n  stylesToShimmedCssText: function(rootStyles, scopeStyles, name,\n      typeExtension) {\n    name = name || '';\n    // insert @polyfill and @polyfill-rule rules into style elements\n    // scoping process takes care of shimming these\n    this.insertPolyfillDirectives(rootStyles);\n    this.insertPolyfillRules(rootStyles);\n    var cssText = this.shimAtHost(scopeStyles, name, typeExtension) +\n        this.shimScoping(scopeStyles, name, typeExtension);\n    // note: we only need to do rootStyles since these are unscoped.\n    cssText += this.extractPolyfillUnscopedRules(rootStyles);\n    return cssText;\n  },\n  registerDefinition: function(root, name, extendsName) {\n    var def = this.registry[name] = {\n      root: root,\n      name: name,\n      extendsName: extendsName\n    }\n    var styles = root ? root.querySelectorAll('style') : [];\n    styles = styles ? Array.prototype.slice.call(styles, 0) : [];\n    def.rootStyles = styles;\n    def.scopeStyles = def.rootStyles;\n    var extendee = this.registry[def.extendsName];\n    if (extendee && (!root || root.querySelector('shadow'))) {\n      def.scopeStyles = extendee.scopeStyles.concat(def.scopeStyles);\n    }\n    return def;\n  },\n  isTypeExtension: function(extendsName) {\n    return extendsName && extendsName.indexOf('-') < 0;\n  },\n  applyScopeToContent: function(root, name) {\n    if (root) {\n      // add the name attribute to each node in root.\n      Array.prototype.forEach.call(root.querySelectorAll('*'),\n          function(node) {\n            node.setAttribute(name, '');\n          });\n      // and template contents too\n      Array.prototype.forEach.call(root.querySelectorAll('template'),\n          function(template) {\n            this.applyScopeToContent(template.content, name);\n          },\n          this);\n    }\n  },\n  /*\n   * Process styles to convert native ShadowDOM rules that will trip\n   * up the css parser; we rely on decorating the stylesheet with comments.\n   * \n   * For example, we convert this rule:\n   * \n   * (comment start) @polyfill :host menu-item (comment end)\n   * shadow::-webkit-distributed(menu-item) {\n   * \n   * to this:\n   * \n   * scopeName menu-item {\n   *\n  **/\n  insertPolyfillDirectives: function(styles) {\n    if (styles) {\n      Array.prototype.forEach.call(styles, function(s) {\n        s.textContent = this.insertPolyfillDirectivesInCssText(s.textContent);\n      }, this);\n    }\n  },\n  insertPolyfillDirectivesInCssText: function(cssText) {\n    return cssText.replace(cssPolyfillCommentRe, function(match, p1) {\n      // remove end comment delimiter and add block start\n      return p1.slice(0, -2) + '{';\n    });\n  },\n  /*\n   * Process styles to add rules which will only apply under the polyfill\n   * \n   * For example, we convert this rule:\n   * \n   * (comment start) @polyfill-rule :host menu-item { \n   * ... } (comment end)\n   * \n   * to this:\n   * \n   * scopeName menu-item {...}\n   *\n  **/\n  insertPolyfillRules: function(styles) {\n    if (styles) {\n      Array.prototype.forEach.call(styles, function(s) {\n        s.textContent = this.insertPolyfillRulesInCssText(s.textContent);\n      }, this);\n    }\n  },\n  insertPolyfillRulesInCssText: function(cssText) {\n    return cssText.replace(cssPolyfillRuleCommentRe, function(match, p1) {\n      // remove end comment delimiter\n      return p1.slice(0, -1);\n    });\n  },\n  /*\n   * Process styles to add rules which will only apply under the polyfill\n   * and do not process via CSSOM. (CSSOM is destructive to rules on rare \n   * occasions, e.g. -webkit-calc on Safari.)\n   * For example, we convert this rule:\n   * \n   * (comment start) @polyfill-unscoped-rule menu-item { \n   * ... } (comment end)\n   * \n   * to this:\n   * \n   * menu-item {...}\n   *\n  **/\n  extractPolyfillUnscopedRules: function(styles) {\n    var cssText = '';\n    if (styles) {\n      Array.prototype.forEach.call(styles, function(s) {\n        cssText += this.extractPolyfillUnscopedRulesFromCssText(\n            s.textContent) + '\\n\\n';\n      }, this);\n    }\n    return cssText;\n  },\n  extractPolyfillUnscopedRulesFromCssText: function(cssText) {\n    var r = '', matches;\n    while (matches = cssPolyfillUnscopedRuleCommentRe.exec(cssText)) {\n      r += matches[1].slice(0, -1) + '\\n\\n';\n    }\n    return r;\n  },\n  // form: @host { .foo { declarations } }\n  // becomes: scopeNamescopeName .foo { ... }\n  */\n  shimScoping: function(styles, name, typeExtension) {\n    if (styles) {\n      return this.convertScopedStyles(styles, name, typeExtension);\n    }\n  },\n  convertScopedStyles: function(styles, name, typeExtension) {\n    var cssText = stylesToCssText(styles).replace(hostRuleRe, '');\n    cssText = this.insertPolyfillHostInCssText(cssText);\n    cssText = this.convertColonHost(cssText);\n    cssText = this.convertPseudos(cssText);\n    cssText = this.convertParts(cssText);\n    cssText = this.convertCombinators(cssText);\n    var rules = cssToRules(cssText);\n    if (name) {\n      cssText = this.scopeRules(rules, name, typeExtension);\n    }\n    return cssText;\n  },\n  convertPseudos: function(cssText) {\n    return cssText.replace(cssPseudoRe, ' [pseudo=$1]');\n  },\n  convertParts: function(cssText) {\n    return cssText.replace(cssPartRe, ' [part=$1]');\n  },\n  /*\n   * convert a rule like :host(.foo) > .bar { }\n   *\n   * to\n   *\n   * scopeName.foo > .bar, .foo scopeName > .bar { }\n   * \n   * and\n   *\n   * :host(.foo:host) .bar { ... }\n   * \n   * to\n   * \n   * scopeNamerator: ' + op);\n\n      left = getFn(left);\n      right = getFn(right);\n\n      return function(values) {\n        return binaryOperators[op](left(values), right(values));\n      };\n    },\n\n    createConditionalExpression: function(test, consequent, alternate) {\n      test = getFn(test);\n      consequent = getFn(consequent);\n      alternate = getFn(alternate);\n\n      return function(values) {\n        return test(values) ? consequent(values) : alternate(values);\n      }\n    },\n\n    createIdentifier: function(name) {\n      var ident = new IdentPath(this, name);\n      ident.type = 'Identifier';\n      return ident;\n    },\n\n    createMemberExpression: function(accessor, object, property) {\n      if (object instanceof IdentPath) {\n        if (accessor == '.')\n          return new IdentPath(this, property.name, object);\n\n        if (property instanceof Literal && Path.get(property.value).valid)\n          return new IdentPath(this, property.value, object);\n      }\n\n      return new MemberExpression(getFn(object), getFn(property));\n    },\n\n    createLiteral: function(token) {\n      return new Literal(token.value);\n    },\n\n    createArrayExpression: function(elements) {\n      for (var i = 0; i < elements.length; i++)\n        elements[i] = getFn(elements[i]);\n\n      return function(values) {\n        var arr = []\n        for (var i = 0; i < elements.length; i++)\n          arr.push(elements[i](values));\n        return arr;\n      }\n    },\n\n    createProperty: function(kind, key, value) {\n      return {\n        key: key instanceof IdentPath ? key.name : key.value,\n        value: value\n      };\n    },\n\n    createObjectExpression: function(properties) {\n      for (var i = 0; i < properties.length; i++)\n        properties[i].value = getFn(properties[i].value);\n\n      return function(values) {\n        var obj = {};\n        for (var i = 0; i < properties.length; i++)\n          obj[properties[i].key] = properties[i].value(values);\n        return obj;\n      }\n    },\n\n    createFilter: function(name, args) {\n      this.filters.push(new Filter(name, args));\n    },\n\n    createAsExpression: function(expression, scopeIdent) {\n      this.expression = expression;\n      this.scopeIdent = scopeIdent;\n    },\n\n    createInExpression: function(scopeIdent, indexIdent, expression) {\n      this.expression = expression;\n      this.scopeIdent = scopeIdent;\n      this.indexIdent = indexIdent;\n    },\n\n    createTopLevel: function(expression) {\n      this.expression = expression;\n    },\n\n    createThisExpression: notImplemented\n  }\n\n  function Expression(delegate) {\n    this.scopeIdent = delegate.scopeIdent;\n    this.indexIdent = delegate.indexIdent;\n\n    if (!delegate.expression)\n      throw Error('No expression found.');\n\n    this.expression = delegate.expression;\n    getFn(this.expression); // forces enumeration of path dependencies\n\n    this.paths = delegate.depsList;\n    this.filters = delegate.filters;\n  }\n\n  Expression.prototype = {\n    getBinding: function(model, filterRegistry) {\n      var paths = this.paths;\n      if (!paths.length) {\n        // only literals in expression.\n        return { value: this.getValue(undefined, filterRegistry, model) };\n      }\n\n      var self = this;\n      function valueFn(values) {\n        return self.getValue(values, filterRegistry, model);\n      }\n\n      function setValueFn(newValue) {\n        var values;\n        if (self.paths.length == 1) {\n          // In the singular-dep case, a PathObserver is used and the callback\n          // is a scalar value.\n          values = self.paths[0].getValueFrom(model);\n        } else {\n          // Multiple-deps uses a CompoundPathObserver whose callback is an\n          // array of values.\n          values = [];\n          for (var i = 0; i < self.paths.length; i++) {\n            values[i] = self.paths[i].getValueFrom(model);\n          }\n        }\n\n        self.setValue(model, newValue, values, filterRegistry, model);\n      }\n\n      if (paths.length === 1) {\n        return new PathObserver(model, paths[0], undefined, undefined, valueFn,\n                                setValueFn);\n      }\n\n      var binding = new CompoundPathObserver(undefined, undefined, valueFn,\n                                             setValueFn);\n\n      for (var i = 0; i < paths.length; i++) {\n        binding.addPath(model, paths[i]);\n      }\n\n      binding.start();\n      return binding;\n    },\n\n    getValue: function(depsValues, filterRegistry, context) {\n      var value = getFn(this.expression)(depsValues);\n      for (var i = 0; i < this.filters.length; i++) {\n        value = this.filters[i].transform(value, depsValues, false,\n                                          filterRegistry,\n                                          context);\n      }\n\n      return value;\n    },\n\n    setValue: function(model, newValue, depsValues, filterRegistry, context) {\n      var count = this.filters ? this.filters.length : 0;\n      while (count-- > 0) {\n        newValue = this.filters[count].transform(newValue, depsValues, true,\n                                                 filterRegistry,\n                                                 context);\n      }\n\n      if (this.expression.setValue)\n        return this.expression.setValue(model, newValue, depsValues);\n    }\n  }\n\n  /**\n   * Converts a style property name to a css property name. For example:\n   * \"WebkitUserSelect\" to \"-webkit-user-select\"\n   */\n  function convertStylePropertyName(name) {\n    return String(name).replace(/[A-Z]/g, function(c) {\n      return '-' + c.toLowerCase();\n    });\n  }\n\n  function PolymerExpressions() {}\n\n  PolymerExpressions.prototype = {\n    // \"built-in\" filters\n    styleObject: function(value) {\n      var parts = [];\n      for (var key in value) {\n        parts.push(convertStylePropertyName(key) + ': ' + value[key]);\n      }\n      return parts.join('; ');\n    },\n\n    tokenList: function(value) {\n      var tokens = [];\n      for (var key in value) {\n        if (value[key])\n          tokens.push(key);\n      }\n      return tokens.join(' ');\n    },\n\n    // binding delegate API\n    prepareInstancePositionChanged: function(template) {\n      var indexIdent = template.polymerExpressionIndexIdent_;\n      if (!indexIdent)\n        return;\n\n      return function(templateInstance, index) {\n        templateInstance.model[indexIdent] = index;\n      };\n    },\n\n    prepareBinding: function(pathString, name, node) {\n      if (Path.get(pathString).valid)\n        return; // bail out early if pathString is simple path.\n\n      return prepareBinding(pathString, name, node, this);\n    },\n\n    prepareInstanceModel: function(template) {\n      var scopeName = template.polymerExpressionScopeIdent_;\n      if (!scopeName)\n        return;\n\n      var parentScope = template.templateInstance ?\n          template.templateInstance.model :\n          template.model;\n\n      return function(model) {\n        var scope = Object.create(parentScope);\n        scope[scopeName