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

Side by Side Diff: Source/core/html/shadow/PluginPlaceholderElement.js

Issue 740063002: Move creation of plugin placeholder DOM from JS to C++. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: oilpan Created 6 years, 1 month 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
« no previous file with comments | « Source/core/html/shadow/PluginPlaceholderElement.idl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 installClass('PluginPlaceholderElement', function(PluginPlaceholderElementProtot ype) { 7 installClass('PluginPlaceholderElement', function(PluginPlaceholderElementProtot ype) {
8 // FIXME: Load this from a .css file.
9 var styleSource =
10 '#plugin-placeholder {' +
11 ' all: initial;' +
12 ' width: 100%;' +
13 ' height: 100%;' +
14 ' overflow: hidden;' +
15 ' display: flex;' +
16 ' align-items: center;' +
17 ' background: gray;' +
18 ' font: 12px -webkit-control;' +
19 '}' +
20 '#plugin-placeholder-content {' +
21 ' text-align: center;' +
22 ' margin: auto;' +
23 '}';
24
25 PluginPlaceholderElementPrototype.createdCallback = function() {
26 this.id = 'plugin-placeholder';
27
28 var styleElement = document.createElement('style');
29 styleElement.textContent = styleSource;
30
31 var contentElement = document.createElement('div');
32 contentElement.id = 'plugin-placeholder-content';
33
34 var messageElement = document.createElement('div');
35 messageElement.id = 'plugin-placeholder-message';
36
37 // FIXME: UI polish, l10n, etc. for the close button.
38 var closeButton = document.createElement('button');
39 closeButton.id = 'plugin-placeholder-close-button';
40 closeButton.textContent = 'Close';
41 closeButton.style.display = 'none';
42 closeButton.addEventListener('click', function() {
43 // FIXME: Record UMA Plugin_Hide_Click.
44 this.hide();
45 }.bind(this));
46
47 contentElement.appendChild(messageElement);
48 contentElement.appendChild(closeButton);
49 this.appendChild(styleElement);
50 this.appendChild(contentElement);
51
52 this.messageElement = messageElement;
53 this.closeButton = closeButton;
54 };
55
56 PluginPlaceholderElementPrototype.hide = function() { 8 PluginPlaceholderElementPrototype.hide = function() {
57 var host = (this.parentNode instanceof ShadowRoot) ? this.parentNode.hos t : this; 9 var host = (this.parentNode instanceof ShadowRoot) ? this.parentNode.hos t : this;
58 host.style.display = 'none'; 10 host.style.display = 'none';
59 11
60 // If we have a width and height, search for a parent (often <div>) with the 12 // If we have a width and height, search for a parent (often <div>) with the
61 // same dimensions. If we find such a parent, hide that as well. 13 // same dimensions. If we find such a parent, hide that as well.
62 // This makes much more uncovered page content usable (including clickab le) 14 // This makes much more uncovered page content usable (including clickab le)
63 // as opposed to merely visible. 15 // as opposed to merely visible.
64 // TODO(cevans) -- it's a foul heuristic but we're going to tolerate it for 16 // TODO(cevans) -- it's a foul heuristic but we're going to tolerate it for
65 // now for these reasons: 17 // now for these reasons:
(...skipping 17 matching lines...) Expand all
83 return; 35 return;
84 36
85 var element = host; 37 var element = host;
86 while (element instanceof Element) { 38 while (element instanceof Element) {
87 if (element.style.width == width && element.style.height == heig ht) 39 if (element.style.width == width && element.style.height == heig ht)
88 element.style.display = 'none'; 40 element.style.display = 'none';
89 element = element.parentNode; 41 element = element.parentNode;
90 } 42 }
91 } 43 }
92 }; 44 };
93
94 Object.defineProperty(PluginPlaceholderElementPrototype, 'message', {
95 get: function() { return this.messageElement.textContent; },
96 set: function(message) { this.messageElement.textContent = message; },
97 });
98
99 Object.defineProperty(PluginPlaceholderElementPrototype, 'closeable', {
100 get: function() { return this.closeButton.style.display != 'none'; },
101 set: function(closeable) { this.closeButton.style.display = closeable ? '' : 'none'; },
102 });
103 }); 45 });
OLDNEW
« no previous file with comments | « Source/core/html/shadow/PluginPlaceholderElement.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698