Skip to content

Commit

Permalink
Merge pull request #2751 from uProxy/jab-workarounds-all-the-way-down
Browse files Browse the repository at this point in the history
workaround for #2659, caused by #2743
  • Loading branch information
jab committed Sep 7, 2016
2 parents 8d12320 + ec508e6 commit 4486c18
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/cca/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<script src='../bower/webcomponentsjs/webcomponents.min.js'></script>

<script src='scripts/context.static.js'></script>
<script src='scripts/workarounds.js'></script>

<!-- The vulcanized code will be loaded asynchronously by context.static.js -->
<!-- <link rel='import' href='polymer/vulcanized.html'> -->
Expand Down Expand Up @@ -44,7 +45,7 @@
</head>

<body unresolved touch-action='auto'>
<!-- uproxy-root will be loaded after polymer is loaded -->
<!-- uproxy-root will be appended here after polymer is loaded (see src/cca/app/scripts/context.ts) -->
<!-- <uproxy-root></uproxy-root> -->
</body>

Expand Down
7 changes: 0 additions & 7 deletions src/cca/app/scripts/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,3 @@ chrome.runtime.getBackgroundPage((bgPage) => {
};
document.head.appendChild(link);
});

// Force a repaint every 300 ms.
// Extremely hacky workaround for https://crbug.com/612836
setInterval(function() {
window.top.dispatchEvent(new Event('resize'));
}, 300);

34 changes: 34 additions & 0 deletions src/cca/app/scripts/workarounds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// CCA-specific workarounds.

(function () {
// Force a repaint every 300 ms.
// Extremely hacky workaround for https://crbug.com/612836

let sendResize = true;

setInterval(function () {
if (sendResize) {
window.dispatchEvent(new Event('resize'));
} else {
console.debug('suppressed resize event');
}
}, 300);

// Workaround for janky inviteUserPanel transition,
// which is caused by the workaround above.
// https://github.com/uProxy/uproxy/issues/2659
document.addEventListener('uproxy-root-ready', function () {
// The 'uproxy-root-ready' event is dispatched in the `ready()` method of
// the uproxy root object instantiated in src/generic_ui/polymer/root.ts.
console.debug('got uproxy-root-ready');
let inviteButton = document.querySelector('uproxy-root /deep/ #inviteButton');
if (!inviteButton) {
console.error('#inviteButton missing:', inviteButton);
return;
}
inviteButton.addEventListener('tap', function () {
sendResize = false;
setTimeout(function () { sendResize = true; }, 2000);
});
});
})();
3 changes: 3 additions & 0 deletions src/generic_ui/polymer/root.html
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ <h3>{{ "SHARING_ENABLED_TITLE" | $$(model.globalSettings.language) }}</h3>
</div>
</div>
<!-- Elements (like the paper fab) that determine position based on proxying/error statuses, must come after the status elements above. Otherwise the positioning will be incorrect. -->
<!-- src/cca/app/polymer/workarounds.ts attaches an on-tap handler to
this #inviteButton element to work around #2659 (see PR #2751).
Make sure to keep the id etc. synced up if changing. -->
<paper-fab id="inviteButton"
mini src='../icons/plus_white.svg'
on-tap='{{ fireOpenInviteUserPanel }}'
Expand Down
4 changes: 4 additions & 0 deletions src/generic_ui/polymer/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ Polymer({
this.$.browserElementContainer.appendChild(browserCustomElement);
}
this.setDirectionality();
// Logic that depends on the uproxy-root element being ready
// (as in src/cca/app/polymer/workarounds.ts)
// can be scheduled appropriately by listening for this event:
document.dispatchEvent(new Event('uproxy-root-ready'));
},
tabSelected: function(e :Event) {
if (this.ui.isSharingDisabled &&
Expand Down

0 comments on commit 4486c18

Please sign in to comment.