1 21 package org.lobobrowser.html.renderer; 22 23 class FloatingViewportBounds implements FloatingBounds { 24 private final FloatingBounds prevBounds; 25 private final int alignment; 26 private final int y; 27 private final int width; 28 private final int height; 29 30 public FloatingViewportBounds(FloatingBounds prevBounds, int alignment, int y, int width, int height) { 31 this.prevBounds = prevBounds; 32 this.alignment = alignment; 33 this.y = y; 34 this.width = width; 35 this.height = height; 36 } 37 38 public int getLeft(int y) { 39 int left = 0; 40 FloatingBounds prev = this.prevBounds; 41 if(prev != null) { 42 left = prev.getLeft(y); 43 } 44 if(this.alignment < 0 && y >= this.y && y < this.y + height) { 45 left += this.width; 46 } 47 return left; 48 } 49 50 53 public int getRight(int y) { 54 int right = 0; 55 FloatingBounds prev = this.prevBounds; 56 if(prev != null) { 57 right = prev.getRight(y); 58 } 59 if(this.alignment > 0 && y >= this.y && y < this.y + this.height) { 60 right += this.width; 61 } 62 return right; 63 } 64 65 public int getClearY(int y) { 66 int cleary = Math.max(y, this.y + this.height); 67 FloatingBounds prev = this.prevBounds; 68 if(prev != null) { 69 int pcy = prev.getClearY(y); 70 if(pcy > cleary) { 71 cleary = pcy; 72 } 73 } 74 return cleary; 75 } 76 77 public boolean equals(Object other) { 78 if(!(other instanceof FloatingViewportBounds)) { 79 return false; 80 } 81 FloatingViewportBounds olm = (FloatingViewportBounds) other; 82 return olm.alignment == this.alignment && 83 olm.y == this.y && 84 olm.height == this.height && 85 olm.width == this.width && 86 org.lobobrowser.util.Objects.equals(olm.prevBounds, this.prevBounds); 87 } 88 } 89 | Popular Tags |