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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/SoftContextMenu.js

Issue 2644393002: [DevTools] Implement dock to left. (Closed)
Patch Set: Created 3 years, 11 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 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 this._glassPaneElement.addEventListener('mouseup', this._glassPaneMouseUp. bind(this), false); 75 this._glassPaneElement.addEventListener('mouseup', this._glassPaneMouseUp. bind(this), false);
76 this._glassPaneElement.appendChild(this.element); 76 this._glassPaneElement.appendChild(this.element);
77 document.body.appendChild(this._glassPaneElement); 77 document.body.appendChild(this._glassPaneElement);
78 this._discardMenuOnResizeListener = this._discardMenu.bind(this, true); 78 this._discardMenuOnResizeListener = this._discardMenu.bind(this, true);
79 document.defaultView.addEventListener('resize', this._discardMenuOnResizeL istener, false); 79 document.defaultView.addEventListener('resize', this._discardMenuOnResizeL istener, false);
80 } else { 80 } else {
81 this._parentMenu._parentGlassPaneElement().appendChild(this.element); 81 this._parentMenu._parentGlassPaneElement().appendChild(this.element);
82 } 82 }
83 83
84 // Re-position menu in case it does not fit. 84 // Re-position menu in case it does not fit.
85 if (document.body.offsetWidth < this.element.offsetLeft + this.element.offse tWidth) { 85 var hostLeft = UI.Dialog.modalHostView().element.totalOffsetLeft();
86 this.element.style.left = 86 var hostRight = hostLeft + UI.Dialog.modalHostView().element.offsetWidth;
87 Math.max( 87 if (hostRight < this.element.offsetLeft + this.element.offsetWidth) {
88 UI.Dialog.modalHostView().element.totalOffsetLeft(), this._parentM enu ? 88 var left = this._parentMenu ? this._parentMenu.element.offsetLeft - this.e lement.offsetWidth + subMenuOverlap :
89 this._parentMenu.element.offsetLeft - this.element.offsetWidth + subMenuOverlap : 89 hostRight - this.element.offsetWidth;
90 document.body.offsetWidth - this.element.offsetWidth) + 90 this.element.style.left = Math.max(hostLeft, left) + 'px';
91 'px';
92 } 91 }
93 92
94 // Move submenus upwards if it does not fit. 93 // Move submenus upwards if it does not fit.
95 if (this._parentMenu && document.body.offsetHeight < this.element.offsetTop + this.element.offsetHeight) { 94 if (this._parentMenu && document.body.offsetHeight < this.element.offsetTop + this.element.offsetHeight) {
96 y = Math.max( 95 y = Math.max(
97 UI.Dialog.modalHostView().element.totalOffsetTop(), document.body.offs etHeight - this.element.offsetHeight); 96 UI.Dialog.modalHostView().element.totalOffsetTop(), document.body.offs etHeight - this.element.offsetHeight);
98 this.element.style.top = y + 'px'; 97 this.element.style.top = y + 'px';
99 } 98 }
100 99
101 var maxHeight = UI.Dialog.modalHostView().element.offsetHeight; 100 var maxHeight = UI.Dialog.modalHostView().element.offsetHeight;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 384
386 _discardSubMenus() { 385 _discardSubMenus() {
387 if (this._subMenu) 386 if (this._subMenu)
388 this._subMenu._discardSubMenus(); 387 this._subMenu._discardSubMenus();
389 if (this.element) 388 if (this.element)
390 this.element.remove(); 389 this.element.remove();
391 if (this._parentMenu) 390 if (this._parentMenu)
392 delete this._parentMenu._subMenu; 391 delete this._parentMenu._subMenu;
393 } 392 }
394 }; 393 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698