litesoft
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.render; import org.litesoft.commonfoundation.typeutils.*; import org.litesoft.core.util.*; /** * Firefox Containers can lie / change their minds. Specifically: * * The decoration size appears to be able to adjust by 1 pixel under certain conditions (it appears after an explicit sizing). * * In addition, the size of a container may NOT be the sum of its TD sizes, there appears to be an opportunity for Firefox to * mis-calculate the Offsets such that there is an empty pixel between the TDs (this has only been observed when the Table is * explicitly sized larger then the natural summed size of the children). */ public abstract class MockContainer extends MockRenderableRect implements RenderableContainer { private int mDecorationSizeX = 0; private int mDecorationSizeY = 0; public MockContainer( String pName ) { super( insureName( pName, "MockContainer_" ) ); } public RenderHelperProcess setSizeX( int pRequestedSizeX ) { return super.setSizeX( pRequestedSizeX ); // For Debugging } public RenderHelperProcess setSizeY( int pRequestedSizeY ) { return super.setSizeY( pRequestedSizeY ); // For Debugging } public void renderingParticipationChanged() { RenderingParticipationChangedHelper.participationChanged( this, getChildren() ); } protected final void LLsetDecorationSizeX( int pDecorationSizeX ) { mDecorationSizeX = Integers.assertNonNegative( "DecorationSizeX", pDecorationSizeX ); changedPosOrSize(); } protected final void LLsetDecorationSizeY( int pDecorationSizeY ) { mDecorationSizeY = Integers.assertNonNegative( "DecorationSizeY", pDecorationSizeY ); changedPosOrSize(); } public final int getDecorationSizeX() { return mDecorationSizeX; } public final int getDecorationSizeY() { return mDecorationSizeY; } abstract public RenderContainerHelper getRenderContainerHelperX(); abstract public RenderContainerHelper getRenderContainerHelperY(); public final RenderHelper getRenderHelperX() { return getRenderContainerHelperX(); } public final RenderHelper getRenderHelperY() { return getRenderContainerHelperY(); } public boolean removeChild( MockNativeRect pNativeRect ) { if ( !isChild( pNativeRect ) ) { return false; } pNativeRect.setParent( null ); return true; } abstract public MockNativeRect[] getChildren(); /** * @return false if pNativeRect is null, otherwise True if it is currently a child of "this" */ public boolean isChild( MockNativeRect pNativeRect ) { MockNativeRect[] zChildren = getChildren(); for ( MockNativeRect zChild : zChildren ) { if ( pNativeRect == zChild ) { return true; } } return false; } /** * called by child to tell Container we just had our parent set */ protected void LLchildAdded( MockNativeRect pNativeRect ) { if ( !isChild( pNativeRect ) ) { throw notAchild( pNativeRect, "add", "probably via its' setParent method to" ); } if ( isAttached() ) { pNativeRect.justAttached(); } } /** * called by child to tell Container we just had our parent cleared */ protected void LLchildRemoved( MockNativeRect pNativeRect ) { if ( !isChild( pNativeRect ) ) { throw notAchild( pNativeRect, "remove", "but not currently a child of" ); } if ( isAttached() ) { pNativeRect.justDetached(); } getRenderContainerHelperX().childRemoved( pNativeRect ); getRenderContainerHelperY().childRemoved( pNativeRect ); LLremoveChild( pNativeRect ); } abstract protected void LLremoveChild( MockNativeRect pNativeRect ); protected void justAttached() { native_justAttached(); MockNativeRect[] zChildren = getChildren(); for ( MockNativeRect zChild : zChildren ) { zChild.justAttached(); } renderingParticipationChanged(); } protected void justDetached() { native_justDetached(); MockNativeRect[] zChildren = getChildren(); for ( MockNativeRect zChild : zChildren ) { zChild.justDetached(); } renderingParticipationChanged(); } public StringBuilder toStringBuilder( StringBuilder pSB, int pDepth ) { super.toStringBuilder( pSB, pDepth++ ); MockNativeRect[] zChildren = getChildren(); for ( MockNativeRect zChild : zChildren ) { LineIndentUtil.newLine( pSB, pDepth ); zChild.toStringBuilder( pSB, pDepth ); } return pSB; } protected void appendPostSize( StringBuilder pSB ) { if ( mDecorationSizeX != 0 || mDecorationSizeY != 0 ) { appendTo( pSB, "-(", mDecorationSizeX, mDecorationSizeX, mDecorationSizeY, mDecorationSizeY ); } } private IllegalStateException notAchild( MockNativeRect pNativeRect, String pWhat, String pWhy ) { StringBuilder sb = new StringBuilder().append( "Attempt to " ).append( pWhat ).append( " a child:" ); LineIndentUtil.newLine( sb, 2 ); if ( pNativeRect == null ) { sb.append( pNativeRect ); } else { pNativeRect.toStringBuilder( sb, 2 ); } LineIndentUtil.newLine( sb, 1 ); sb.append( pWhy ).append( ":" ); LineIndentUtil.newLine( sb, 2 ); toStringBuilder( sb, 2 ); return new IllegalStateException( sb.toString() ); } protected interface SizeCalculator { public int calculate( MockNativeRect[] pChildren, RenderDimensionAdapter pDimensionAdapter ); } protected static class Sum_SC implements SizeCalculator { public static final SizeCalculator INSTANCE = new Sum_SC(); private Sum_SC() { } public int calculate( MockNativeRect[] pChildren, RenderDimensionAdapter pDimensionAdapter ) { int rv = 0; for ( MockNativeRect zChild : pChildren ) { rv += pDimensionAdapter.getSize( zChild ); } return rv; } } protected static class Max_SC implements SizeCalculator { public static final SizeCalculator INSTANCE = new Max_SC(); private Max_SC() { } public int calculate( MockNativeRect[] pChildren, RenderDimensionAdapter pDimensionAdapter ) { int rv = 0; for ( MockNativeRect zChild : pChildren ) { rv = Math.max( rv, pDimensionAdapter.getSize( zChild ) ); } return rv; } } } |
Commits for litesoft/trunk/Java/core/jvm1.5/src/org/litesoft/render/MockContainer.java
Revision | Author | Commited | Message |
---|---|---|---|
947 Diff | GeorgeS | Fri 06 Jun, 2014 23:36:56 +0000 | Correct Spelling of package! |
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
821 Diff | GeorgeS | Sun 19 Aug, 2012 00:08:41 +0000 | |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |