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

Side by Side Diff: third_party/polymer/v1_0/components-chromium/iron-fit-behavior/iron-fit-behavior-extracted.js

Issue 2158913007: Roll Polymer from 1.5.0 -> 1.6.0 to pick up native CSS custom props (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 /** 1 /**
2 `Polymer.IronFitBehavior` fits an element in another element using `max-height` and `max-width`, and 2 `Polymer.IronFitBehavior` fits an element in another element using `max-height` and `max-width`, and
3 optionally centers it in the window or another element. 3 optionally centers it in the window or another element.
4 4
5 The element will only be sized and/or positioned if it has not already been size d and/or positioned 5 The element will only be sized and/or positioned if it has not already been size d and/or positioned
6 by CSS. 6 by CSS.
7 7
8 CSS properties | Action 8 CSS properties | Action
9 -----------------------------|------------------------------------------- 9 -----------------------------|-------------------------------------------
10 `position` set | Element is not centered horizontally or verticall y 10 `position` set | Element is not centered horizontally or verticall y
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } else { 215 } else {
216 this.fit(); 216 this.fit();
217 } 217 }
218 } 218 }
219 }, 219 },
220 220
221 /** 221 /**
222 * Positions and fits the element into the `fitInto` element. 222 * Positions and fits the element into the `fitInto` element.
223 */ 223 */
224 fit: function() { 224 fit: function() {
225 this._discoverInfo();
226 this.position(); 225 this.position();
227 this.constrain(); 226 this.constrain();
228 this.center(); 227 this.center();
229 }, 228 },
230 229
231 /** 230 /**
232 * Memoize information needed to position and size the target element. 231 * Memoize information needed to position and size the target element.
233 * @suppress {deprecated} 232 * @suppress {deprecated}
234 */ 233 */
235 _discoverInfo: function() { 234 _discoverInfo: function() {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 }, 316 },
318 317
319 /** 318 /**
320 * Positions the element according to `horizontalAlign, verticalAlign`. 319 * Positions the element according to `horizontalAlign, verticalAlign`.
321 */ 320 */
322 position: function() { 321 position: function() {
323 if (!this.horizontalAlign && !this.verticalAlign) { 322 if (!this.horizontalAlign && !this.verticalAlign) {
324 // needs to be centered, and it is done after constrain. 323 // needs to be centered, and it is done after constrain.
325 return; 324 return;
326 } 325 }
326 this._discoverInfo();
327 327
328 this.style.position = 'fixed'; 328 this.style.position = 'fixed';
329 // Need border-box for margin/padding. 329 // Need border-box for margin/padding.
330 this.sizingTarget.style.boxSizing = 'border-box'; 330 this.sizingTarget.style.boxSizing = 'border-box';
331 // Set to 0, 0 in order to discover any offset caused by parent stacking c ontexts. 331 // Set to 0, 0 in order to discover any offset caused by parent stacking c ontexts.
332 this.style.left = '0px'; 332 this.style.left = '0px';
333 this.style.top = '0px'; 333 this.style.top = '0px';
334 334
335 var rect = this.getBoundingClientRect(); 335 var rect = this.getBoundingClientRect();
336 var positionRect = this.__getNormalizedRect(this.positionTarget); 336 var positionRect = this.__getNormalizedRect(this.positionTarget);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 }, 377 },
378 378
379 /** 379 /**
380 * Constrains the size of the element to `fitInto` by setting `max-height` 380 * Constrains the size of the element to `fitInto` by setting `max-height`
381 * and/or `max-width`. 381 * and/or `max-width`.
382 */ 382 */
383 constrain: function() { 383 constrain: function() {
384 if (this.horizontalAlign || this.verticalAlign) { 384 if (this.horizontalAlign || this.verticalAlign) {
385 return; 385 return;
386 } 386 }
387 this._discoverInfo();
388
387 var info = this._fitInfo; 389 var info = this._fitInfo;
388 // position at (0px, 0px) if not already positioned, so we can measure the natural size. 390 // position at (0px, 0px) if not already positioned, so we can measure the natural size.
389 if (!info.positionedBy.vertically) { 391 if (!info.positionedBy.vertically) {
390 this.style.position = 'fixed'; 392 this.style.position = 'fixed';
391 this.style.top = '0px'; 393 this.style.top = '0px';
392 } 394 }
393 if (!info.positionedBy.horizontally) { 395 if (!info.positionedBy.horizontally) {
394 this.style.position = 'fixed'; 396 this.style.position = 'fixed';
395 this.style.left = '0px'; 397 this.style.left = '0px';
396 } 398 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 }, 433 },
432 434
433 /** 435 /**
434 * Centers horizontally and vertically if not already positioned. This also sets 436 * Centers horizontally and vertically if not already positioned. This also sets
435 * `position:fixed`. 437 * `position:fixed`.
436 */ 438 */
437 center: function() { 439 center: function() {
438 if (this.horizontalAlign || this.verticalAlign) { 440 if (this.horizontalAlign || this.verticalAlign) {
439 return; 441 return;
440 } 442 }
443 this._discoverInfo();
444
441 var positionedBy = this._fitInfo.positionedBy; 445 var positionedBy = this._fitInfo.positionedBy;
442 if (positionedBy.vertically && positionedBy.horizontally) { 446 if (positionedBy.vertically && positionedBy.horizontally) {
443 // Already positioned. 447 // Already positioned.
444 return; 448 return;
445 } 449 }
446 // Need position:fixed to center 450 // Need position:fixed to center
447 this.style.position = 'fixed'; 451 this.style.position = 'fixed';
448 // Take into account the offset caused by parents that create stacking 452 // Take into account the offset caused by parents that create stacking
449 // contexts (e.g. with transform: translate3d). Translate to 0,0 and 453 // contexts (e.g. with transform: translate3d). Translate to 0,0 and
450 // measure the bounding rect. 454 // measure the bounding rect.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 // ones overlapping vertically. 575 // ones overlapping vertically.
572 if (position.croppedArea === 0 && alignOk) { 576 if (position.croppedArea === 0 && alignOk) {
573 break; 577 break;
574 } 578 }
575 } 579 }
576 580
577 return position; 581 return position;
578 } 582 }
579 583
580 }; 584 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698