layout/style/crashtests/1017798-1.html
author Xianzhu Wang <wangxianzhu@chromium.org>
Tue, 05 Mar 2019 12:18:01 +0000
changeset 464575 4325ba7b38576495a78289c2a8f4dff391922e66
parent 448142 2c4f0bf2be1c6a47ca537ce552099bb9eefbe5be
permissions -rw-r--r--
Bug 1529059 [wpt PR 15420] - [BlinkGenPropertyTrees] Initiailize double_sided of synthetic effect, a=testonly Automatic update from web-platform-tests [BlinkGenPropertyTrees] Initiailize double_sided of synthetic effect Previously synthetic effects always had double_sided==false, causing the layer disappear when the backface was facing forward. Bug: 928190 Change-Id: I35534b40346d5c5918bc99c00a4ca6b4e3b68796 Reviewed-on: https://chromium-review.googlesource.com/c/1475815 Reviewed-by: Philip Rogers <pdr@chromium.org> Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> Cr-Commit-Position: refs/heads/master@{#632764} -- wpt-commits: a89467050deaf1dcbd9140a2f0670b1b85e518ee wpt-pr: 15420


<!DOCTYPE html>
<!--
This is a slightly minimised, modified and self-contained version of
gaia_switch/examples/index.html from the Gaia repository.
-->
<script>
'use strict';

(function(exports) {

  /**
   * ComponentUtils is a utility which allows us to use web components earlier
   * than we should be able to by polyfilling and fixing platform deficiencies.
   */
  var ComponentUtils = {

    /**
     * Injects a style.css into both the shadow root and outside the shadow
     * root so we can style projected content. Bug 992249.
     */
    style: function(baseUrl) {
      var style = document.createElement('style');
      style.setAttribute('scoped', '');
      var url = baseUrl + '1017798-1.css';
      style.innerHTML = '@import url(' + url + ');';

      this.appendChild(style);

      if (!this.shadowRoot) {
        return;
      }

      // The setTimeout is necessary to avoid missing @import styles
      // when appending two stylesheets. Bug 1003294.
      setTimeout(() => {
        this.shadowRoot.appendChild(style.cloneNode(true));
      });
    }

  };

  exports.ComponentUtils = ComponentUtils;

}(window));
</script>
<script>
'use strict';
/* global ComponentUtils */

window.GaiaSwitch = (function(win) {
  // Extend from the HTMLElement prototype
  class GaiaSwitch extends HTMLElement {
    connectedCallback() {
      var shadow = this.attachShadow({ mode: "open" });
      this._template = template.content.cloneNode(true);
      this._input = this._template.querySelector('input[type="checkbox"]');

      var checked = this.getAttribute('checked');
      if (checked !== null) {
        this._input.checked = true;
      }

      shadow.appendChild(this._template);

      ComponentUtils.style.call(this, '');
    }
  };


  /**
   * Proxy the checked property to the input element.
   */
  Object.defineProperty( GaiaSwitch.prototype, 'checked', {
    get: function() {
      return this._input.checked;
    },
    set: function(value) {
      this._input.checked = value;
    }
  });

  /**
   * Proxy the name property to the input element.
   */
  Object.defineProperty( GaiaSwitch.prototype, 'name', {
    get: function() {
      return this.getAttribute('name');
    },
    set: function(value) {
      this.setAttribute('name', value);
    }
  });

  // HACK: Create a <template> in memory at runtime.
  // When the custom-element is created we clone
  // this template and inject into the shadow-root.
  // Prior to this we would have had to copy/paste
  // the template into the <head> of every app that
  // wanted to use <gaia-switch>, this would make
  // markup changes complicated, and could lead to
  // things getting out of sync. This is a short-term
  // hack until we can import entire custom-elements
  // using HTML Imports (bug 877072).
  var template = document.createElement('template');
  template.innerHTML = '<label id="switch-label" class="pack-switch">' +
      '<input type="checkbox">' +
      '<span><slot></slot></span>' +
    '</label>';

  // Register and return the constructor
  win.customElements.define('gaia-switch', GaiaSwitch);
  return GaiaSwitch;
})(window);
</script>
<body>
<section>
  <gaia-switch>
    <label>With a label</label>
  </gaia-switch>
</section>
<script>
window.onload = function() {
  document.querySelector('gaia-switch').checked = true;
};
</script>