Skip to content

Commit

Permalink
Remove browsers from code that are not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
joehenry9498 committed Dec 8, 2023
1 parent df41cfa commit bc70d0a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export interface ChildWindow extends Window {
deltaWidth?: number;
/** Difference between height child window actually opened to as compared to expected */
deltaHeight?: number;
/** Current browser being used */
currentBrowser?: string;
/** If outer size should be used for calculations instead of inner size */
shouldUseOuterSized?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ export class InternalChildWindowManager implements FrameworkChildWindows {
if (childWindow.expectedHeight && childWindow.expectedWidth) {
childWindow.deltaWidth =
childWindow.expectedWidth -
(childWindow.currentBrowser === "chromium based edge"
(childWindow.shouldUseOuterSized
? childWindow.outerWidth
: childWindow.innerWidth);
childWindow.deltaHeight =
childWindow.expectedHeight -
(childWindow.currentBrowser === "chromium based edge"
(childWindow.shouldUseOuterSized
? childWindow.outerHeight
: childWindow.innerHeight);
}
Expand Down Expand Up @@ -271,25 +271,6 @@ export class InternalChildWindowManager implements FrameworkChildWindows {
return outLocation;
}

// This is needed due to the differences in how browsers calculate the
// inner vs outer width of windows. Calculations are different between
// browsers. We are starting with some of the mainly used browsers but can
// add more if issues arise with others.
private findBrowser(agent: string): string {
switch (true) {
case agent.indexOf("edge") > -1:
return "edge";
case agent.indexOf("firefox") > -1:
return "firefox";
case agent.indexOf("edg/") > -1:
return "chromium based edge";
case agent.indexOf("chrome") > -1:
return "chrome";
default:
return "other";
}
}

/**
* Open a new child window.
* @param childWindowId Id to assign to the newly created window.
Expand Down Expand Up @@ -327,9 +308,9 @@ export class InternalChildWindowManager implements FrameworkChildWindows {
childWindow.expectedHeight = location.height;
childWindow.expectedWidth = location.width;

childWindow.currentBrowser = this.findBrowser(
navigator.userAgent.toLowerCase()
);
// Edge needs to use outer size
childWindow.shouldUseOuterSized =
navigator.userAgent.toLowerCase().indexOf("edg/") > -1;

if (0 === url.length) {
childWindow.document.write(childHtml);
Expand Down
14 changes: 6 additions & 8 deletions ui/appui-react/src/appui-react/frontstage/FrontstageDef.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -914,14 +914,12 @@ export class FrontstageDef {
const widgetDef = this.findWidgetDef(tabId);
if (!widgetDef) return;

let width =
childWindow.currentBrowser === "chromium based edge"
? childWindow.outerWidth
: childWindow.innerWidth;
let height =
childWindow.currentBrowser === "chromium based edge"
? childWindow.outerHeight
: childWindow.innerHeight;
let width = childWindow.shouldUseOuterSized
? childWindow.outerWidth
: childWindow.innerWidth;
let height = childWindow.shouldUseOuterSized
? childWindow.outerHeight
: childWindow.innerHeight;
if (childWindow.deltaHeight) {
height = height + childWindow.deltaHeight;
if (height < 1) height = 100;
Expand Down

0 comments on commit bc70d0a

Please sign in to comment.