49
|
1 |
/*
|
|
2 |
* Copyright (c) 2000 - 2002 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "nw_lmgr_boxi.h"
|
|
19 |
#include "nw_lmgr_rootbox.h"
|
|
20 |
#include "nw_lmgr_marqueebox.h"
|
|
21 |
#include "nw_lmgr_statictablerowbox.h"
|
|
22 |
#include "nw_lmgr_statictablecellbox.h"
|
|
23 |
#include "nw_lmgr_bidiflowbox.h"
|
|
24 |
#include "nw_lmgr_textbox.h"
|
|
25 |
#include "nw_lmgr_simplepropertylist.h"
|
|
26 |
#include "nw_text_ucs2.h"
|
|
27 |
#include "nwx_string.h"
|
|
28 |
#include "nwx_logger.h"
|
|
29 |
#include "nwx_math.h"
|
|
30 |
#include "nw_gdi_utils.h"
|
|
31 |
#include "nw_lmgr_activecontainerbox.h"
|
|
32 |
#include "nw_lmgr_imgcontainerbox.h"
|
|
33 |
#include "nw_lmgr_posflowbox.h"
|
|
34 |
#include "nw_lmgr_verticaltablebox.h"
|
|
35 |
#include "nw_lmgr_verticaltablerowbox.h"
|
|
36 |
#include "nw_lmgr_verticaltablecellbox.h"
|
|
37 |
#include "urlloader_urlloaderint.h"
|
|
38 |
#include "nwx_settings.h"
|
|
39 |
#include "GDIDeviceContext.h"
|
|
40 |
|
|
41 |
#include "nw_lmgr_imgcontainerbox.h"
|
|
42 |
#include "LMgrMarkerImage.h"
|
|
43 |
#include "LMgrMarkerText.h"
|
|
44 |
#include "BrsrStatusCodes.h"
|
|
45 |
#include "LMgrAnonBlock.h"
|
|
46 |
#include "nw_css_tokentoint.h"
|
|
47 |
#include <bitdev.h>
|
|
48 |
#include <aknutils.h>
|
|
49 |
#include "LMgrObjectBoxOOC.h"
|
|
50 |
|
|
51 |
/* ------------------------------------------------------------------------- *
|
|
52 |
private final methods
|
|
53 |
* ------------------------------------------------------------------------- */
|
|
54 |
|
|
55 |
/* ------------------------------------------------------------------------- *
|
|
56 |
* Function: NW_LMgr_Box_ResolveAbsoluteLength
|
|
57 |
* Description: Resolves a relative length (Cm, Mm, In, Pt, Pc).
|
|
58 |
* Returns: KBrsrSuccess.
|
|
59 |
*/
|
|
60 |
|
|
61 |
static
|
|
62 |
TBrowserStatusCode
|
|
63 |
NW_LMgr_Box_ResolveAbsoluteLength(NW_LMgr_Box_t* box,
|
|
64 |
NW_LMgr_PropertyName_t propertyName,
|
|
65 |
NW_LMgr_Property_t *property)
|
|
66 |
{
|
|
67 |
NW_Float32 val = property->value.decimal;
|
|
68 |
|
|
69 |
NW_REQUIRED_PARAM(box);
|
|
70 |
NW_REQUIRED_PARAM(propertyName);
|
|
71 |
|
|
72 |
switch(property->type & NW_CSS_ValueType_Mask)
|
|
73 |
{
|
|
74 |
case NW_CSS_ValueType_Pc:
|
|
75 |
// A pica is equivalent to 12 points
|
|
76 |
val = val * 12;
|
|
77 |
|
|
78 |
break;
|
|
79 |
|
|
80 |
case NW_CSS_ValueType_Cm:
|
|
81 |
// A centimeter is 28.34 points
|
|
82 |
val = val * (NW_Float32)28.34;
|
|
83 |
|
|
84 |
break;
|
|
85 |
|
|
86 |
case NW_CSS_ValueType_Mm:
|
|
87 |
// A millimeter is 2.83 points
|
|
88 |
val = val * (NW_Float32)2.83;
|
|
89 |
|
|
90 |
break;
|
|
91 |
|
|
92 |
case NW_CSS_ValueType_In:
|
|
93 |
// A inch is 72 points
|
|
94 |
val = val * 72;
|
|
95 |
|
|
96 |
break;
|
|
97 |
|
|
98 |
case NW_CSS_ValueType_Pt:
|
|
99 |
default:
|
|
100 |
break;
|
|
101 |
}
|
|
102 |
|
|
103 |
property->type = NW_CSS_ValueType_Pt;
|
|
104 |
property->value.decimal = val;
|
|
105 |
|
|
106 |
return KBrsrSuccess;
|
|
107 |
}
|
|
108 |
|
|
109 |
/* ------------------------------------------------------------------------- *
|
|
110 |
* Function: NW_LMgr_Box_ResolveRelativeLength
|
|
111 |
* Description: Resolves a relative length (Em, Ex).
|
|
112 |
* Returns: KBrsrSuccess.
|
|
113 |
*/
|
|
114 |
|
|
115 |
static
|
|
116 |
TBrowserStatusCode
|
|
117 |
NW_LMgr_Box_ResolveRelativeLength(NW_LMgr_Box_t* box,
|
|
118 |
NW_LMgr_PropertyName_t propertyName,
|
|
119 |
NW_LMgr_Property_t *property)
|
|
120 |
{
|
|
121 |
NW_LMgr_Box_t *baseBox;
|
|
122 |
NW_Int32 val;
|
|
123 |
|
|
124 |
(void) propertyName;
|
|
125 |
|
|
126 |
// Fontsize uses the parent's em
|
|
127 |
if (propertyName == NW_CSS_Prop_fontSize)
|
|
128 |
{
|
|
129 |
baseBox = (NW_LMgr_Box_t*)NW_LMgr_Box_GetParent(box);
|
|
130 |
|
|
131 |
// This assert is only going to be triggered in the case when
|
|
132 |
// there are percentage properties applied to the RootBox.
|
|
133 |
// That is an error condition because the RootBox should have
|
|
134 |
// no properties.
|
|
135 |
NW_ASSERT(baseBox != NULL);
|
|
136 |
}
|
|
137 |
else
|
|
138 |
{
|
|
139 |
baseBox = box;
|
|
140 |
}
|
|
141 |
|
|
142 |
// set the absolute font-size
|
|
143 |
if (property->type == NW_CSS_ValueType_Em)
|
|
144 |
{
|
|
145 |
val = (NW_Int32)(property->value.decimal * NW_LMgr_Box_GetEm(baseBox));
|
|
146 |
}
|
|
147 |
else
|
|
148 |
{
|
|
149 |
val = (NW_Int32)(property->value.decimal * NW_LMgr_Box_GetEx(baseBox));
|
|
150 |
}
|
|
151 |
|
|
152 |
if (propertyName == NW_CSS_Prop_fontSize)
|
|
153 |
{
|
|
154 |
// we can't use pixels here because in NW_LMgr_Box_ApplyFontProps(),
|
|
155 |
// pixel will be adjusted to bigger value
|
|
156 |
CEikonEnv* eikEnv = CEikonEnv::Static();
|
|
157 |
CWsScreenDevice& screenDev = *eikEnv->ScreenDevice();
|
|
158 |
NW_Float32 valPt = FontUtils::PointsFromTwips(screenDev.VerticalPixelsToTwips(val));
|
|
159 |
|
|
160 |
property->type = NW_CSS_ValueType_Pt;
|
|
161 |
property->value.decimal = valPt;
|
|
162 |
}
|
|
163 |
else
|
|
164 |
{
|
|
165 |
property->type = NW_CSS_ValueType_Px;
|
|
166 |
property->value.integer = val;
|
|
167 |
}
|
|
168 |
|
|
169 |
return KBrsrSuccess;
|
|
170 |
}
|
|
171 |
|
|
172 |
/* ------------------------------------------------------------------------- *
|
|
173 |
* Function: NW_LMgr_Box_ResolvePercent
|
|
174 |
* Description: Resolves a relative property (percentage).
|
|
175 |
* Returns: KBrsrSuccess.
|
|
176 |
*/
|
|
177 |
|
|
178 |
static
|
|
179 |
TBrowserStatusCode
|
|
180 |
NW_LMgr_Box_ResolvePercent(NW_LMgr_Box_t* box,
|
|
181 |
NW_LMgr_PropertyName_t propertyName,
|
|
182 |
NW_LMgr_Property_t *property)
|
|
183 |
|
|
184 |
|
|
185 |
{
|
|
186 |
NW_LMgr_Box_t* parentBox;
|
|
187 |
NW_GDI_Rectangle_t bounds;
|
|
188 |
NW_Float32 val = 0;
|
|
189 |
NW_Int32 px = 0;
|
|
190 |
NW_LMgr_Property_t parentProp;
|
|
191 |
NW_GDI_Dimension2D_t size;
|
|
192 |
NW_GDI_Dimension3D_t imgSize;
|
|
193 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
194 |
NW_Image_AbstractImage_t *image = NULL;
|
|
195 |
|
|
196 |
NW_Int32 fontSizeI = 0;
|
|
197 |
NW_Float32 fontSizeD = 0.0;
|
|
198 |
|
|
199 |
NW_LMgr_PropertyValue_t backgroundPropValue;
|
|
200 |
|
|
201 |
val = property->value.decimal;
|
|
202 |
|
|
203 |
switch(propertyName)
|
|
204 |
{
|
|
205 |
// This property calculate its percentage with respect to the
|
|
206 |
// value of the same property of their parent box
|
|
207 |
case NW_CSS_Prop_fontSize:
|
|
208 |
{
|
|
209 |
// First we need to see if the box is a body box, if so, we need
|
|
210 |
// to find what the default CSS font size is.
|
|
211 |
NW_LMgr_RootBox_t* rootBox = NW_LMgr_Box_GetRootBox( box );
|
|
212 |
|
|
213 |
// check for body box
|
|
214 |
if( NW_LMgr_RootBox_GetBody( rootBox ) == box)
|
|
215 |
{
|
|
216 |
// TODO query the CSS table for the default font size
|
|
217 |
// We know it is 6.5 points
|
|
218 |
fontSizeD = (NW_Float32)(val * 6) / 100;
|
|
219 |
|
|
220 |
property->type = NW_CSS_ValueType_Pt;
|
|
221 |
property->value.decimal = fontSizeD;
|
|
222 |
|
|
223 |
(void) NW_LMgr_Box_SetProperty (box, NW_CSS_Prop_fontSize, property);
|
|
224 |
}
|
|
225 |
else
|
|
226 |
{
|
|
227 |
// calculate the percentage of the parent box's font size
|
|
228 |
parentBox = (NW_LMgr_Box_t*)NW_LMgr_Box_GetParent(box);
|
|
229 |
|
|
230 |
NW_LMgr_Box_GetProperty(NW_LMgr_BoxOf (parentBox),
|
|
231 |
NW_CSS_Prop_fontSize, &parentProp);
|
|
232 |
|
|
233 |
switch(parentProp.type)
|
|
234 |
{
|
|
235 |
case NW_CSS_ValueType_Em:
|
|
236 |
case NW_CSS_ValueType_Ex:
|
|
237 |
case NW_CSS_ValueType_In:
|
|
238 |
case NW_CSS_ValueType_Cm:
|
|
239 |
case NW_CSS_ValueType_Mm:
|
|
240 |
case NW_CSS_ValueType_Pt:
|
|
241 |
case NW_CSS_ValueType_Pc:
|
|
242 |
fontSizeD = (val * parentProp.value.decimal) / 100;
|
|
243 |
|
|
244 |
property->type = parentProp.type;
|
|
245 |
property->value.decimal = fontSizeD;
|
|
246 |
|
|
247 |
(void) NW_LMgr_Box_SetProperty (box, NW_CSS_Prop_fontSize, property);
|
|
248 |
break;
|
|
249 |
|
|
250 |
case NW_CSS_ValueType_Px:
|
|
251 |
default:
|
|
252 |
fontSizeI = (NW_Int32) ((val * parentProp.value.integer) / 100);
|
|
253 |
|
|
254 |
property->type = parentProp.type;
|
|
255 |
property->value.integer = fontSizeI;
|
|
256 |
|
|
257 |
(void) NW_LMgr_Box_SetProperty (box, NW_CSS_Prop_fontSize, property);
|
|
258 |
break;
|
|
259 |
}
|
|
260 |
}
|
|
261 |
return status;
|
|
262 |
}
|
|
263 |
|
|
264 |
/* These properties calculate their percentage with repect to the
|
|
265 |
value of the same property of the surrounding flow */
|
|
266 |
case NW_CSS_Prop_backgroundPosition_x:
|
|
267 |
case NW_CSS_Prop_backgroundPosition_y:
|
|
268 |
{
|
|
269 |
parentBox = box;
|
|
270 |
bounds = NW_LMgr_Box_GetFormatBounds(parentBox);
|
|
271 |
/* check if background-image is defined */
|
|
272 |
backgroundPropValue.object = NULL;
|
|
273 |
NW_LMgr_FrameInfo_t borderWidthInfo;
|
|
274 |
NW_LMgr_Box_GetBorderWidth(parentBox, &borderWidthInfo, ELMgrFrameAll );
|
|
275 |
(void)NW_LMgr_Box_GetPropertyValue(box, NW_CSS_Prop_backgroundImage, NW_CSS_ValueType_Image, &backgroundPropValue);
|
|
276 |
if (backgroundPropValue.object == NULL )
|
|
277 |
{
|
|
278 |
return KBrsrSuccess;
|
|
279 |
}
|
|
280 |
|
|
281 |
/* check if image is opened */
|
|
282 |
image = (NW_Image_AbstractImage_t*)backgroundPropValue.object;
|
|
283 |
(void) NW_Image_AbstractImage_GetSize(image, &imgSize);
|
|
284 |
if (imgSize.width == 0 || imgSize.height == 0)
|
|
285 |
{
|
|
286 |
return KBrsrSuccess;
|
|
287 |
}
|
|
288 |
|
|
289 |
if(propertyName == NW_CSS_Prop_backgroundPosition_x)
|
|
290 |
{
|
|
291 |
px = (NW_Int32)(val * (bounds.dimension.width - imgSize.width- borderWidthInfo.right
|
|
292 |
- borderWidthInfo.left) / 100);
|
|
293 |
}
|
|
294 |
else //propertyName == NW_CSS_Prop_backgroundPosition_y)
|
|
295 |
{
|
|
296 |
px = (NW_Int32)(val * (bounds.dimension.height - imgSize.height
|
|
297 |
|
|
298 |
- borderWidthInfo.top - borderWidthInfo.bottom ) / 100);
|
|
299 |
}
|
|
300 |
break;
|
|
301 |
}
|
|
302 |
case NW_CSS_Prop_width:
|
|
303 |
case NW_CSS_Prop_height:
|
|
304 |
case NW_CSS_Prop_padding:
|
|
305 |
case NW_CSS_Prop_leftPadding:
|
|
306 |
case NW_CSS_Prop_rightPadding:
|
|
307 |
case NW_CSS_Prop_topPadding:
|
|
308 |
case NW_CSS_Prop_bottomPadding:
|
|
309 |
case NW_CSS_Prop_margin:
|
|
310 |
case NW_CSS_Prop_leftMargin:
|
|
311 |
case NW_CSS_Prop_rightMargin:
|
|
312 |
case NW_CSS_Prop_topMargin:
|
|
313 |
case NW_CSS_Prop_bottomMargin:
|
|
314 |
case NW_CSS_Prop_border:
|
|
315 |
case NW_CSS_Prop_leftBorderWidth:
|
|
316 |
case NW_CSS_Prop_rightBorderWidth:
|
|
317 |
case NW_CSS_Prop_topBorderWidth:
|
|
318 |
case NW_CSS_Prop_bottomBorderWidth:
|
|
319 |
case NW_CSS_Prop_textIndent:
|
|
320 |
case NW_CSS_Prop_marqueeAmount:
|
|
321 |
/* First find the enclosing flow */
|
|
322 |
do
|
|
323 |
{
|
|
324 |
parentBox = (NW_LMgr_Box_t*)NW_LMgr_Box_GetParent(box);
|
|
325 |
|
|
326 |
/* This assert is only going to be triggered in the case when
|
|
327 |
* there are percentage properties applied to the RootBox.
|
|
328 |
* That is an error condition because the RootBox should have
|
|
329 |
* no properties.
|
|
330 |
*/
|
|
331 |
NW_ASSERT(parentBox != NULL);
|
|
332 |
|
|
333 |
/* Move one level up */
|
|
334 |
box = parentBox;
|
|
335 |
|
|
336 |
} while (!NW_Object_IsInstanceOf(parentBox, &NW_LMgr_FlowBox_Class));
|
|
337 |
if ((propertyName == NW_CSS_Prop_height || propertyName == NW_CSS_Prop_width) &&
|
|
338 |
NW_Object_IsInstanceOf(parentBox, &NW_LMgr_PosFlowBox_Class))
|
|
339 |
{
|
|
340 |
NW_LMgr_RootBox_t* rootBox = NW_LMgr_Box_GetRootBox(box);
|
|
341 |
CGDIDeviceContext* deviceContext = NW_LMgr_RootBox_GetDeviceContext (rootBox);
|
|
342 |
// The width of a positioned box depends on the containing block
|
|
343 |
// If the positioned box is nested, the containing box is
|
|
344 |
// the parent positioned box, otherwise it is the screen size
|
|
345 |
NW_LMgr_PosFlowBox_t* posParent = (NW_LMgr_PosFlowBox_t*)parentBox;
|
|
346 |
if (posParent->iContainingBlock == NULL)
|
|
347 |
{
|
|
348 |
bounds = (*deviceContext->DisplayBounds());
|
|
349 |
}
|
|
350 |
else
|
|
351 |
{
|
|
352 |
bounds = NW_LMgr_Box_GetFormatBounds(posParent->iContainingBlock);
|
|
353 |
}
|
|
354 |
if (propertyName == NW_CSS_Prop_width)
|
|
355 |
{
|
|
356 |
NW_LMgr_FrameInfo_t paddingInfo;
|
|
357 |
NW_LMgr_FrameInfo_t borderWidthInfo;
|
|
358 |
|
|
359 |
NW_LMgr_Box_GetPadding(parentBox, &paddingInfo, ELMgrFrameAll );
|
|
360 |
NW_LMgr_Box_GetBorderWidth(parentBox, &borderWidthInfo, ELMgrFrameAll );
|
|
361 |
NW_GDI_Metric_t containingWidth = (NW_GDI_Metric_t)
|
|
362 |
(bounds.dimension.width -
|
|
363 |
paddingInfo.left - paddingInfo.right -
|
|
364 |
borderWidthInfo.left - borderWidthInfo.right);
|
|
365 |
|
|
366 |
px = (NW_Int32)((val * containingWidth) / 100);
|
|
367 |
}
|
|
368 |
else // propertyName == NW_CSS_Prop_height
|
|
369 |
{
|
|
370 |
|
|
371 |
px = (NW_Int32)((val * bounds.dimension.height) / 100);
|
|
372 |
|
|
373 |
}
|
|
374 |
}
|
|
375 |
else
|
|
376 |
{
|
|
377 |
if (propertyName != NW_CSS_Prop_height)
|
|
378 |
{
|
|
379 |
bounds = NW_LMgr_Box_GetFormatBounds(parentBox); // width
|
|
380 |
|
|
381 |
|
|
382 |
// S60 bug fix <PHEN-64EEW3>
|
|
383 |
// If the box needs to have x% of parent box's width,
|
|
384 |
// deduct border, padding width from parent box's width first
|
|
385 |
// then calculate the x% of the remaining width
|
|
386 |
if (propertyName == NW_CSS_Prop_width)
|
|
387 |
{
|
|
388 |
NW_LMgr_FrameInfo_t paddingInfo;
|
|
389 |
NW_LMgr_FrameInfo_t borderWidthInfo;
|
|
390 |
|
|
391 |
NW_LMgr_Box_GetPadding(parentBox, &paddingInfo, ELMgrFrameAll );
|
|
392 |
NW_LMgr_Box_GetBorderWidth(parentBox, &borderWidthInfo, ELMgrFrameAll );
|
|
393 |
NW_GDI_Metric_t containingWidth = (NW_GDI_Metric_t)
|
|
394 |
(bounds.dimension.width -
|
|
395 |
paddingInfo.left - paddingInfo.right -
|
|
396 |
borderWidthInfo.left - borderWidthInfo.right);
|
|
397 |
|
|
398 |
px = (NW_Int32)((val * containingWidth) / 100);
|
|
399 |
}
|
|
400 |
else
|
|
401 |
{
|
|
402 |
px = (NW_Int32)((val * bounds.dimension.width) / 100);
|
|
403 |
}
|
|
404 |
}
|
|
405 |
else // propertyName == NW_CSS_Prop_height
|
|
406 |
|
|
407 |
{
|
|
408 |
if (!NW_Object_IsClass(parentBox, &NW_LMgr_StaticTableCellBox_Class) &&
|
|
409 |
!NW_Object_IsClass(parentBox, &NW_LMgr_VerticalTableCellBox_Class))
|
|
410 |
{
|
|
411 |
NW_LMgr_RootBox_t* rootBox = NW_LMgr_Box_GetRootBox(box);
|
|
412 |
CGDIDeviceContext* deviceContext = NW_LMgr_RootBox_GetDeviceContext (rootBox);
|
|
413 |
bounds = (*deviceContext->DisplayBounds());
|
|
414 |
NW_LMgr_FrameInfo_t paddingInfo;
|
|
415 |
NW_LMgr_FrameInfo_t borderWidthInfo;
|
|
416 |
|
|
417 |
NW_LMgr_Box_GetPadding(parentBox, &paddingInfo, ELMgrFrameAll );
|
|
418 |
NW_LMgr_Box_GetBorderWidth(parentBox, &borderWidthInfo, ELMgrFrameAll );
|
|
419 |
NW_GDI_Metric_t containingHeight = (NW_GDI_Metric_t)
|
|
420 |
(bounds.dimension.height -
|
|
421 |
paddingInfo.top - paddingInfo.bottom -
|
|
422 |
borderWidthInfo.top - borderWidthInfo.bottom);
|
|
423 |
px = (NW_Int32)((val * containingHeight) / 100);
|
|
424 |
|
|
425 |
}
|
|
426 |
else
|
|
427 |
{
|
|
428 |
|
|
429 |
|
|
430 |
status = NW_LMgr_Box_GetSizeProperties(parentBox, &size);
|
|
431 |
if (status != KBrsrSuccess)
|
|
432 |
{
|
|
433 |
return status;
|
|
434 |
}
|
|
435 |
|
|
436 |
if (size.height != -1)
|
|
437 |
{
|
|
438 |
px = (NW_Int32) ((val * size.height) / 100);
|
|
439 |
}
|
|
440 |
else
|
|
441 |
{
|
|
442 |
return KBrsrNotFound;
|
|
443 |
}
|
|
444 |
}
|
|
445 |
|
|
446 |
}
|
|
447 |
}
|
|
448 |
break;
|
|
449 |
|
|
450 |
default:
|
|
451 |
/* In all other cases return the percentage as is (this useful for v-align) */
|
|
452 |
return KBrsrSuccess;
|
|
453 |
}
|
|
454 |
|
|
455 |
property->type = NW_CSS_ValueType_Px;
|
|
456 |
property->value.integer = px;
|
|
457 |
|
|
458 |
return status;
|
|
459 |
}
|
|
460 |
|
|
461 |
/* ------------------------------------------------------------------------- *
|
|
462 |
* Function: NW_LMgr_Box_ResolveRelativeProperty
|
|
463 |
* Description: Resolves a relative property (percentage, em, ex,).
|
|
464 |
* Returns: KBrsrSuccess.
|
|
465 |
*/
|
|
466 |
|
|
467 |
static
|
|
468 |
TBrowserStatusCode
|
|
469 |
NW_LMgr_Box_ResolveRelativeProperty(NW_LMgr_Box_t* box,
|
|
470 |
NW_LMgr_PropertyName_t propertyName,
|
|
471 |
NW_LMgr_Property_t *property)
|
|
472 |
{
|
|
473 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
474 |
|
|
475 |
NW_ASSERT (box);
|
|
476 |
NW_ASSERT (property);
|
|
477 |
|
|
478 |
// Remove bit flag so it works for default/variable properties as well
|
|
479 |
// as normal ones.
|
|
480 |
switch (property->type & NW_CSS_ValueType_Mask)
|
|
481 |
{
|
|
482 |
case NW_CSS_ValueType_Percentage:
|
|
483 |
status = NW_LMgr_Box_ResolvePercent (box, propertyName, property);
|
|
484 |
break;
|
|
485 |
|
|
486 |
case NW_CSS_ValueType_Em:
|
|
487 |
case NW_CSS_ValueType_Ex:
|
|
488 |
status = NW_LMgr_Box_ResolveRelativeLength (box, propertyName, property);
|
|
489 |
break;
|
|
490 |
|
|
491 |
case NW_CSS_ValueType_In:
|
|
492 |
case NW_CSS_ValueType_Cm:
|
|
493 |
case NW_CSS_ValueType_Mm:
|
|
494 |
case NW_CSS_ValueType_Pt:
|
|
495 |
case NW_CSS_ValueType_Pc:
|
|
496 |
status = NW_LMgr_Box_ResolveAbsoluteLength (box, propertyName, property);
|
|
497 |
break;
|
|
498 |
|
|
499 |
default:
|
|
500 |
break;
|
|
501 |
}
|
|
502 |
|
|
503 |
return status;
|
|
504 |
}
|
|
505 |
|
|
506 |
/* ------------------------------------------------------------------------- *
|
|
507 |
* Function: NW_LMgr_Box_ConvertBorderStyle
|
|
508 |
* Description: Converts border style to GDIContext value
|
|
509 |
* Returns: Converted border style
|
|
510 |
*/
|
|
511 |
|
|
512 |
static
|
|
513 |
NW_GDI_Pattern_t
|
|
514 |
NW_LMgr_Box_ConvertBorderStyle(NW_LMgr_PropertyValueToken_t style)
|
|
515 |
{
|
|
516 |
NW_GDI_Pattern_t gdiStyle;
|
|
517 |
switch (style)
|
|
518 |
{
|
|
519 |
case NW_CSS_PropValue_solid:
|
|
520 |
gdiStyle = NW_GDI_Pattern_Solid;
|
|
521 |
break;
|
|
522 |
|
|
523 |
case NW_CSS_PropValue_dashed:
|
|
524 |
gdiStyle = NW_GDI_Pattern_Dashed;
|
|
525 |
break;
|
|
526 |
|
|
527 |
case NW_CSS_PropValue_dotted:
|
|
528 |
gdiStyle = NW_GDI_Pattern_Dotted;
|
|
529 |
break;
|
|
530 |
|
|
531 |
default:
|
|
532 |
gdiStyle = NW_GDI_Pattern_None;
|
|
533 |
break;
|
|
534 |
}
|
|
535 |
return gdiStyle;
|
|
536 |
}
|
|
537 |
|
|
538 |
/* ------------------------------------------------------------------------- *
|
|
539 |
static data
|
|
540 |
* ------------------------------------------------------------------------- */
|
|
541 |
|
|
542 |
const
|
|
543 |
NW_LMgr_Box_Class_t NW_LMgr_Box_Class = {
|
|
544 |
{ /* NW_Object_Core */
|
|
545 |
/* super */ &NW_Object_Dynamic_Class,
|
|
546 |
/* queryInterface */ _NW_Object_Base_QueryInterface
|
|
547 |
},
|
|
548 |
{ /* NW_Object_Base */
|
|
549 |
/* interfaceList */ NULL
|
|
550 |
},
|
|
551 |
{ /* NW_Object_Dynamic */
|
|
552 |
/* instanceSize */ sizeof (NW_LMgr_Box_t),
|
|
553 |
/* construct */ _NW_LMgr_Box_Construct,
|
|
554 |
/* destruct */ _NW_LMgr_Box_Destruct
|
|
555 |
},
|
|
556 |
{ /* NW_LMgr_Box */
|
|
557 |
/* split */ _NW_LMgr_Box_Split,
|
|
558 |
/* resize */ _NW_LMgr_Box_Resize,
|
|
559 |
/* postResize */ _NW_LMgr_Box_PostResize,
|
|
560 |
/* getMinimumContentSize */ _NW_LMgr_Box_GetMinimumContentSize,
|
|
561 |
/* hasFixedContentSize */ _NW_LMgr_Box_HasFixedContentSize,
|
|
562 |
/* constrain */ _NW_LMgr_Box_Constrain,
|
|
563 |
/* draw */ _NW_LMgr_Box_Draw,
|
|
564 |
/* render */ _NW_LMgr_Box_Render,
|
|
565 |
/* getBaseline */ _NW_LMgr_Box_GetBaseline,
|
|
566 |
/* shift */ _NW_LMgr_Box_Shift,
|
|
567 |
/* clone */ _NW_LMgr_Box_Clone
|
|
568 |
}
|
|
569 |
};
|
|
570 |
|
|
571 |
/* ------------------------------------------------------------------------- *
|
|
572 |
virtual methods
|
|
573 |
* ------------------------------------------------------------------------- */
|
|
574 |
|
|
575 |
/* ------------------------------------------------------------------------- *
|
|
576 |
* Function: NW_LMgr_Box_Construct
|
|
577 |
* Description: The constructor.
|
|
578 |
* Returns: KBrsrSuccess, KBrsrOutOfMemory.
|
|
579 |
*/
|
|
580 |
|
|
581 |
TBrowserStatusCode
|
|
582 |
_NW_LMgr_Box_Construct (NW_Object_Dynamic_t* dynamicObject,
|
|
583 |
va_list* argp)
|
|
584 |
{
|
|
585 |
NW_TRY (status)
|
|
586 |
{
|
|
587 |
NW_LMgr_Box_t* box;
|
|
588 |
NW_ADT_Vector_Metric_t initPropCount;
|
|
589 |
|
|
590 |
NW_ASSERT(dynamicObject != NULL);
|
|
591 |
|
|
592 |
/* for convenience */
|
|
593 |
box = NW_LMgr_BoxOf (dynamicObject);
|
|
594 |
|
|
595 |
/* initialize the member variables */
|
|
596 |
initPropCount = (NW_ADT_Vector_Metric_t) va_arg (*argp, NW_Uint32);
|
|
597 |
if (initPropCount != 0)
|
|
598 |
{
|
|
599 |
box->propList = (NW_LMgr_PropertyList_t*)
|
|
600 |
NW_LMgr_SimplePropertyList_New (initPropCount, 2);
|
|
601 |
NW_THROW_OOM_ON_NULL (box->propList, status);
|
|
602 |
}
|
|
603 |
else
|
|
604 |
{
|
|
605 |
box->propList = NULL;
|
|
606 |
}
|
|
607 |
|
|
608 |
box->hasFocus = NW_FALSE;
|
|
609 |
box->rootBox = NULL;
|
|
610 |
}
|
|
611 |
NW_CATCH (status)
|
|
612 |
{
|
|
613 |
}
|
|
614 |
NW_FINALLY
|
|
615 |
{
|
|
616 |
return status;
|
|
617 |
} NW_END_TRY
|
|
618 |
}
|
|
619 |
|
|
620 |
/* ------------------------------------------------------------------------- *
|
|
621 |
* Function: NW_LMgr_Box_Destruct
|
|
622 |
* Description: The destructor.
|
|
623 |
* Returns: void
|
|
624 |
*/
|
|
625 |
|
|
626 |
void
|
|
627 |
_NW_LMgr_Box_Destruct (NW_Object_Dynamic_t* dynamicObject)
|
|
628 |
{
|
|
629 |
NW_LMgr_Box_t* box;
|
|
630 |
|
|
631 |
NW_ASSERT(dynamicObject != NULL);
|
|
632 |
|
|
633 |
/* for convenience */
|
|
634 |
box = NW_LMgr_BoxOf (dynamicObject);
|
|
635 |
|
|
636 |
/* before deleting the object, we must make sure that it is removed from the
|
|
637 |
parent */
|
|
638 |
TBrowserStatusCode status = NW_LMgr_Box_Detach(box);
|
|
639 |
NW_ASSERT(status == KBrsrSuccess);
|
|
640 |
/* To fix TI compiler warning */
|
|
641 |
(void) status;
|
|
642 |
|
|
643 |
/* delete the properties */
|
|
644 |
if (box->propList != NULL) {
|
|
645 |
NW_Object_Delete (box->propList);
|
|
646 |
}
|
|
647 |
}
|
|
648 |
|
|
649 |
/* ------------------------------------------------------------------------- *
|
|
650 |
* Function: NW_LMgr_Box_Split
|
|
651 |
* Description: Splits the box, storing the split box in splitBox.
|
|
652 |
* By default, boxes can't split. If there is enough space for the box,
|
|
653 |
* or if we're at the new line, we return success. Otherwise
|
|
654 |
* split fails.
|
|
655 |
* Returns: KBrsrLmgrSplitOk, KBrsrLmgrNoSplit
|
|
656 |
*/
|
|
657 |
|
|
658 |
TBrowserStatusCode
|
|
659 |
_NW_LMgr_Box_Split(NW_LMgr_Box_t* box,
|
|
660 |
NW_GDI_Metric_t space,
|
|
661 |
NW_LMgr_Box_t* *splitBox,
|
|
662 |
NW_Uint8 flags)
|
|
663 |
{
|
|
664 |
NW_ASSERT(box != NULL);
|
|
665 |
|
|
666 |
if (flags & NW_LMgr_Box_SplitFlags_Nowrap) {
|
|
667 |
*splitBox = NULL;
|
|
668 |
return KBrsrSuccess;
|
|
669 |
}
|
|
670 |
|
|
671 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetFormatBounds( box );
|
|
672 |
|
|
673 |
if((boxBounds.dimension.width <= space)
|
|
674 |
|| (flags & NW_LMgr_Box_SplitFlags_AtNewLine)) {
|
|
675 |
*splitBox = NULL;
|
|
676 |
return KBrsrSuccess;
|
|
677 |
}
|
|
678 |
else {
|
|
679 |
*splitBox = NULL;
|
|
680 |
return KBrsrLmgrNoSplit;
|
|
681 |
}
|
|
682 |
}
|
|
683 |
|
|
684 |
/* ------------------------------------------------------------------------- *
|
|
685 |
* Function: NW_LMgr_Box_Resize
|
|
686 |
* Description: Resizes the box. By default, boxes resize themselves to match
|
|
687 |
any CSS size properties. Otherwise they get the default minimum size.
|
|
688 |
* Returns: void
|
|
689 |
*/
|
|
690 |
|
|
691 |
TBrowserStatusCode
|
|
692 |
_NW_LMgr_Box_Resize (NW_LMgr_Box_t* box, NW_LMgr_FormatContext_t* context)
|
|
693 |
{
|
|
694 |
NW_REQUIRED_PARAM(context);
|
|
695 |
NW_TRY (status) {
|
|
696 |
NW_GDI_Dimension2D_t size;
|
|
697 |
|
|
698 |
NW_ASSERT(box != NULL);
|
|
699 |
|
|
700 |
status = NW_LMgr_Box_GetMinimumSize (box, &size);
|
|
701 |
_NW_THROW_ON_ERROR (status);
|
|
702 |
|
|
703 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetFormatBounds( box );
|
|
704 |
|
|
705 |
boxBounds.dimension.width = size.width;
|
|
706 |
boxBounds.dimension.height = size.height;
|
|
707 |
NW_LMgr_Box_SetFormatBounds( box, boxBounds );
|
|
708 |
|
|
709 |
} NW_CATCH (status) {
|
|
710 |
} NW_FINALLY {
|
|
711 |
return status;
|
|
712 |
} NW_END_TRY
|
|
713 |
}
|
|
714 |
|
|
715 |
TBrowserStatusCode
|
|
716 |
_NW_LMgr_Box_PostResize (NW_LMgr_Box_t* box)
|
|
717 |
{
|
|
718 |
NW_REQUIRED_PARAM(box);
|
|
719 |
|
|
720 |
return KBrsrSuccess;
|
|
721 |
}
|
|
722 |
|
|
723 |
/* ------------------------------------------------------------------------- *
|
|
724 |
* Function: NW_LMgr_Box_Constrain
|
|
725 |
* Description This method sets an initial size for a box depending on an external
|
|
726 |
* constraint. This is different from resize which knows about box
|
|
727 |
* content size, box size properties, and box minimum size. For
|
|
728 |
* container boxes, resize involves laying out children with size
|
|
729 |
* constrained in one dimension: this method is called before resizing
|
|
730 |
* the box to set the constraint. For other box types, this method
|
|
731 |
* does nothing and returns KBrsrLmgrNotConstrained, indicating
|
|
732 |
* that the box has a fixed size and cannot be arbitrarily
|
|
733 |
* constrained. This method can be called to discover whether a box
|
|
734 |
* obeys constraint arguments or has a fixed size.
|
|
735 |
* Returns: KBrsrLmgrNotConstrained
|
|
736 |
*/
|
|
737 |
|
|
738 |
TBrowserStatusCode
|
|
739 |
_NW_LMgr_Box_Constrain(NW_LMgr_Box_t *box,
|
|
740 |
NW_GDI_Metric_t constraint) {
|
|
741 |
|
|
742 |
NW_REQUIRED_PARAM(box);
|
|
743 |
NW_REQUIRED_PARAM(constraint);
|
|
744 |
|
|
745 |
return KBrsrLmgrNotConstrained;
|
|
746 |
}
|
|
747 |
|
|
748 |
|
|
749 |
/* ------------------------------------------------------------------------- *
|
|
750 |
* Function: NW_LMgr_Box_GetMinimumContentSize
|
|
751 |
* Description: This virtual method returns the minimum content size for the
|
|
752 |
* box. If the WIDTH property is set on the box, this is assumed
|
|
753 |
* to be the minimum size for the box. Otherwise, the box returns
|
|
754 |
* the default values (8,8).
|
|
755 |
* Returns: KBrsrSuccess
|
|
756 |
*/
|
|
757 |
|
|
758 |
TBrowserStatusCode
|
|
759 |
_NW_LMgr_Box_GetMinimumContentSize(NW_LMgr_Box_t *box,
|
|
760 |
NW_GDI_Dimension2D_t *size){
|
|
761 |
NW_LMgr_PropertyValue_t sizeVal;
|
|
762 |
|
|
763 |
NW_REQUIRED_PARAM(box);
|
|
764 |
NW_ASSERT(size != NULL);
|
|
765 |
|
|
766 |
/* If the box has its Width/Height properties set, use that for sizing;
|
|
767 |
* otherwise return default values (8 by 8).
|
|
768 |
*/
|
|
769 |
NW_LMgr_RootBox_t* rootBox = NW_LMgr_Box_GetRootBox( box );
|
|
770 |
|
|
771 |
if( NW_LMgr_RootBox_GetSmallScreenOn( rootBox ) )
|
|
772 |
{
|
|
773 |
NW_LMgr_PropertyValue_t visibilityVal;
|
|
774 |
TBrowserStatusCode status ;
|
|
775 |
visibilityVal.token = NW_CSS_PropValue_visible;
|
|
776 |
status = NW_LMgr_Box_GetPropertyValue (box, NW_CSS_Prop_visibility,
|
|
777 |
NW_CSS_ValueType_Token, &visibilityVal);
|
|
778 |
if (status == KBrsrSuccess && visibilityVal.token == NW_CSS_PropValue_hidden)
|
|
779 |
{
|
|
780 |
size->width = 0 ;
|
|
781 |
size->height = 0;
|
|
782 |
return KBrsrSuccess;
|
|
783 |
}
|
|
784 |
}
|
|
785 |
|
|
786 |
if(NW_LMgr_Box_GetPropertyValue(box, NW_CSS_Prop_width, NW_CSS_ValueType_Px, &sizeVal) == KBrsrSuccess){
|
|
787 |
size->width = (NW_GDI_Metric_t)sizeVal.integer;
|
|
788 |
}
|
|
789 |
else {
|
|
790 |
size->width = NW_LMGR_BOX_MIN_WIDTH;
|
|
791 |
}
|
|
792 |
|
|
793 |
if(NW_LMgr_Box_GetPropertyValue(box, NW_CSS_Prop_height, NW_CSS_ValueType_Px, &sizeVal) == KBrsrSuccess){
|
|
794 |
size->height = (NW_GDI_Metric_t)sizeVal.integer;
|
|
795 |
}
|
|
796 |
else {
|
|
797 |
size->height = NW_LMGR_BOX_MIN_HEIGHT;
|
|
798 |
}
|
|
799 |
|
|
800 |
return KBrsrSuccess;
|
|
801 |
}
|
|
802 |
|
|
803 |
/* ------------------------------------------------------------------------- *
|
|
804 |
* Function: NW_LMgr_Box_HasFixedContentSize
|
|
805 |
* Description: Determines whether the content of the box has fixed size or not.
|
|
806 |
* By default, boxes don't have a fixed content size: i.e. they can
|
|
807 |
* be arbitrarily resized by applying a constraint.
|
|
808 |
* Returns: NW_FALSE
|
|
809 |
*/
|
|
810 |
|
|
811 |
NW_Bool
|
|
812 |
_NW_LMgr_Box_HasFixedContentSize(NW_LMgr_Box_t *box){
|
|
813 |
NW_REQUIRED_PARAM(box);
|
|
814 |
return NW_FALSE;
|
|
815 |
}
|
|
816 |
|
|
817 |
/**
|
|
818 |
* Function: NW_LMgr_Box_Predraw
|
|
819 |
* Description: draw the background for the box, including background color and
|
|
820 |
* background image.
|
|
821 |
* The latter one includes background-image, background-repeat,
|
|
822 |
* background-attachment and background-position.
|
|
823 |
* Parameters: box -- The box for which the background is to be handled.
|
|
824 |
* deviceContext -- The device context object.
|
|
825 |
* hasFocus -- has the focus or not.
|
|
826 |
*
|
|
827 |
* Returns: KBrsrSuccess, KBrsrOutOfMemory
|
|
828 |
*/
|
|
829 |
|
|
830 |
TBrowserStatusCode
|
|
831 |
NW_LMgr_Box_Predraw (NW_LMgr_Box_t* box,
|
|
832 |
CGDIDeviceContext* deviceContext,
|
|
833 |
NW_Uint8 hasFocus)
|
|
834 |
{
|
|
835 |
NW_GDI_Color_t initialColor;
|
|
836 |
NW_GDI_Color_t initialBackgroundColor;
|
|
837 |
NW_GDI_Color_t highlightColor;
|
|
838 |
|
|
839 |
|
|
840 |
/* parameter assertion block */
|
|
841 |
NW_ASSERT (box != NULL);
|
|
842 |
NW_ASSERT (NW_Object_IsInstanceOf (box, &NW_LMgr_Box_Class));
|
|
843 |
|
|
844 |
initialColor = deviceContext->ForegroundColor();
|
|
845 |
initialBackgroundColor = deviceContext->BackgroundColor();
|
|
846 |
|
|
847 |
NW_TRY (status)
|
|
848 |
{
|
|
849 |
NW_LMgr_Property_t backgroundProp;
|
|
850 |
NW_LMgr_Property_t backgroundPropX, backgroundPropY;
|
|
851 |
NW_LMgr_PropertyValue_t backgroundPropValue;
|
|
852 |
NW_Image_AbstractImage_t *image = NULL;
|
|
853 |
NW_GDI_Rectangle_t rect; /* box rectangle */
|
|
854 |
NW_GDI_Rectangle_t viewBounds; /* view rectangle */
|
|
855 |
NW_GDI_Point2D_t startDraw; /* start point for drawing the background image */
|
|
856 |
NW_GDI_Point2D_t viewOffset; /* view offset caused by scrolling */
|
|
857 |
NW_GDI_Dimension3D_t size; /* size of image */
|
|
858 |
NW_Bool isFixed = NW_FALSE; /* if the background-attachment is set to fixed */
|
|
859 |
NW_LMgr_RootBox_t* rootBox;
|
|
860 |
|
|
861 |
rect = NW_LMgr_Box_GetDisplayBounds(box);
|
|
862 |
|
|
863 |
/* draw the background color */
|
|
864 |
|
|
865 |
backgroundProp.type = NW_CSS_ValueType_Token;
|
|
866 |
backgroundProp.value.token = NW_CSS_PropValue_transparent;
|
|
867 |
|
|
868 |
if (NW_Object_IsClass(box, &NW_LMgr_StaticTableCellBox_Class))
|
|
869 |
{
|
|
870 |
NW_LMgr_StaticTableCellBox_t *cell = NW_LMgr_StaticTableCellBoxOf(box);
|
|
871 |
NW_LMgr_StaticTableCellBox_GetBackground(cell, &backgroundProp);
|
|
872 |
}
|
|
873 |
else
|
|
874 |
{
|
|
875 |
status = NW_LMgr_Box_GetProperty(box, NW_CSS_Prop_backgroundColor, &backgroundProp);
|
|
876 |
}
|
|
877 |
|
|
878 |
if (hasFocus && NW_Object_IsInstanceOf(box, &NW_LMgr_AbstractTextBox_Class))
|
|
879 |
{
|
|
880 |
/* we want to change the background */
|
|
881 |
backgroundProp.type = NW_CSS_ValueType_Color;
|
|
882 |
|
|
883 |
deviceContext->GetHighlightColor( &highlightColor);
|
|
884 |
backgroundProp.value.integer = highlightColor;
|
|
885 |
}
|
|
886 |
|
|
887 |
if (backgroundProp.type == NW_CSS_ValueType_Color)
|
|
888 |
{
|
|
889 |
deviceContext->SetPaintMode ( NW_GDI_PaintMode_Copy);
|
|
890 |
deviceContext->SetBackgroundColor( backgroundProp.value.integer);
|
|
891 |
deviceContext->FillRectangle( &rect);
|
|
892 |
}
|
|
893 |
|
|
894 |
/* draw the background image */
|
|
895 |
|
|
896 |
/* check if background-image is defined */
|
|
897 |
backgroundPropValue.object = NULL;
|
|
898 |
(void)NW_LMgr_Box_GetPropertyValue(box, NW_CSS_Prop_backgroundImage, NW_CSS_ValueType_Image, &backgroundPropValue);
|
|
899 |
if (backgroundPropValue.object == NULL )
|
|
900 |
{
|
|
901 |
NW_THROW (KBrsrSuccess);
|
|
902 |
}
|
|
903 |
|
|
904 |
/* check if image is opened */
|
|
905 |
image = (NW_Image_AbstractImage_t*)backgroundPropValue.object;
|
|
906 |
(void) NW_Image_AbstractImage_GetSize(image, &size);
|
|
907 |
if (size.width == 0 || size.height == 0)
|
|
908 |
{
|
|
909 |
NW_THROW (KBrsrSuccess);
|
|
910 |
}
|
|
911 |
|
|
912 |
/* initialized some drawing coordinates */
|
|
913 |
viewOffset = deviceContext->ClipRect().point;
|
|
914 |
viewBounds = *(deviceContext->DisplayBounds());
|
|
915 |
startDraw = rect.point;
|
|
916 |
|
|
917 |
rootBox = NW_LMgr_Box_GetRootBox( box );
|
|
918 |
|
|
919 |
/* check for body box */
|
|
920 |
if( NW_LMgr_RootBox_GetBody( rootBox ) == box)
|
|
921 |
{
|
|
922 |
/* to make sure the image can be drawn on the entire view */
|
|
923 |
startDraw = viewBounds.point;
|
|
924 |
rect.dimension.width = rect.dimension.width + rect.point.x;
|
|
925 |
rect.dimension.height =rect.dimension.height + rect.point.y;
|
|
926 |
rect.point.x = 0;
|
|
927 |
rect.point.y = 0;
|
|
928 |
|
|
929 |
// Note: following is a temporary fix for bug RLAU-5W9LA8
|
|
930 |
// the cause of the bug was body box's width not being correctly set by format functions,
|
|
931 |
// instead it's always set to roughly view bounds width
|
|
932 |
// A better fix should be in post format functions
|
|
933 |
if (rect.dimension.width < viewBounds.dimension.width + viewOffset.x)
|
|
934 |
rect.dimension.width = viewBounds.dimension.width + viewOffset.x;
|
|
935 |
}
|
|
936 |
/* check for background-attachment property */
|
|
937 |
backgroundPropValue.token = NW_CSS_PropValue_scroll;
|
|
938 |
NW_LMgr_Box_GetPropertyValue(box, NW_CSS_Prop_backgroundAttachment, NW_CSS_ValueType_Token, &backgroundPropValue);
|
|
939 |
|
|
940 |
if (backgroundPropValue.token == NW_CSS_PropValue_background_fixed)
|
|
941 |
{
|
|
942 |
isFixed = NW_TRUE;
|
|
943 |
}
|
|
944 |
|
|
945 |
|
|
946 |
/* check and apply background-position property */
|
|
947 |
backgroundPropX.type = NW_CSS_ValueType_Token;
|
|
948 |
backgroundPropX.value.token = NW_CSS_PropValue_none;
|
|
949 |
backgroundPropY.type = NW_CSS_ValueType_Token;
|
|
950 |
backgroundPropY.value.token = NW_CSS_PropValue_none;
|
|
951 |
NW_LMgr_FrameInfo_t borderWidthInfo;
|
|
952 |
NW_LMgr_Box_GetBorderWidth(box, &borderWidthInfo, ELMgrFrameAll );
|
|
953 |
|
|
954 |
NW_LMgr_Box_GetPropertyFromList(box, NW_CSS_Prop_backgroundPosition_x, &backgroundPropX);
|
|
955 |
NW_LMgr_Box_GetPropertyFromList(box, NW_CSS_Prop_backgroundPosition_y, &backgroundPropY);
|
|
956 |
if(backgroundPropX.type == NW_CSS_ValueType_Token)
|
|
957 |
{
|
|
958 |
if((backgroundPropX.value.token == NW_CSS_PropValue_none) && (backgroundPropY.value.token != NW_CSS_PropValue_none))
|
|
959 |
{
|
|
960 |
backgroundPropX.value.token = NW_CSS_PropValue_center;
|
|
961 |
}
|
|
962 |
}
|
|
963 |
if(backgroundPropY.type == NW_CSS_ValueType_Token)
|
|
964 |
{
|
|
965 |
if((backgroundPropX.value.token != NW_CSS_PropValue_none) && (backgroundPropY.value.token == NW_CSS_PropValue_none))
|
|
966 |
{
|
|
967 |
backgroundPropY.value.token = NW_CSS_PropValue_center;
|
|
968 |
}
|
|
969 |
}
|
|
970 |
|
|
971 |
if(backgroundPropX.type == NW_CSS_ValueType_Token)
|
|
972 |
{
|
|
973 |
/* if background image needs to be shown as fixed, set the position relative to view bounds instead of box bounds */
|
|
974 |
if ((backgroundPropX.value.token == NW_CSS_PropValue_center )
|
|
975 |
&& size.width <= rect.dimension.width)
|
|
976 |
{
|
|
977 |
if (isFixed == NW_TRUE)
|
|
978 |
startDraw.x += (viewBounds.dimension.width - size.width)/2;
|
|
979 |
else
|
|
980 |
startDraw.x += (rect.dimension.width - size.width)/2;
|
|
981 |
}
|
|
982 |
else if (backgroundPropX.value.token == NW_CSS_PropValue_right)
|
|
983 |
{
|
|
984 |
if (isFixed == NW_TRUE)
|
|
985 |
startDraw.x += (viewBounds.dimension.width - size.width);
|
|
986 |
else
|
|
987 |
startDraw.x += (rect.dimension.width - size.width);
|
|
988 |
}
|
|
989 |
}
|
|
990 |
else if ( backgroundPropX.type == NW_CSS_ValueType_Number)
|
|
991 |
{
|
|
992 |
startDraw.x += (TInt32)backgroundPropX.value.decimal + borderWidthInfo.left;
|
|
993 |
}
|
|
994 |
else
|
|
995 |
{
|
|
996 |
startDraw.x += backgroundPropX.value.integer + borderWidthInfo.left;
|
|
997 |
}
|
|
998 |
|
|
999 |
if(backgroundPropY.type == NW_CSS_ValueType_Token)
|
|
1000 |
{
|
|
1001 |
if ((backgroundPropY.value.token == NW_CSS_PropValue_center) &&
|
|
1002 |
(size.height <= rect.dimension.height))
|
|
1003 |
{
|
|
1004 |
if (isFixed == NW_TRUE)
|
|
1005 |
startDraw.y += (viewBounds.dimension.height - size.height)/2;
|
|
1006 |
else
|
|
1007 |
startDraw.y += (rect.dimension.height - size.height)/2;
|
|
1008 |
}
|
|
1009 |
else if (backgroundPropY.value.token == NW_CSS_PropValue_bottom)
|
|
1010 |
{
|
|
1011 |
if (isFixed == NW_TRUE)
|
|
1012 |
startDraw.y += (viewBounds.dimension.height - size.height);
|
|
1013 |
else
|
|
1014 |
startDraw.y += (rect.dimension.height - size.height);
|
|
1015 |
}
|
|
1016 |
}
|
|
1017 |
else if ( backgroundPropY.type == NW_CSS_ValueType_Number)
|
|
1018 |
{
|
|
1019 |
startDraw.y += (TInt32)backgroundPropY.value.decimal + borderWidthInfo.top;
|
|
1020 |
}
|
|
1021 |
else
|
|
1022 |
{
|
|
1023 |
startDraw.y += backgroundPropY.value.integer + borderWidthInfo.top;
|
|
1024 |
}
|
|
1025 |
|
|
1026 |
/* Apply background-attachment feature only to the body element */
|
|
1027 |
if ( isFixed == NW_TRUE)
|
|
1028 |
{
|
|
1029 |
startDraw.x += viewOffset.x;
|
|
1030 |
startDraw.y += viewOffset.y;
|
|
1031 |
}
|
|
1032 |
|
|
1033 |
/* check and apply background-repeat property */
|
|
1034 |
backgroundPropValue.token = NW_CSS_PropValue_background_repeat;
|
|
1035 |
NW_LMgr_Box_GetPropertyValue(box, NW_CSS_Prop_backgroundRepeat, NW_CSS_ValueType_Token, &backgroundPropValue);
|
|
1036 |
|
|
1037 |
// Draw the image once at startDraw.
|
|
1038 |
if (backgroundPropValue.token == NW_CSS_PropValue_background_norepeat)
|
|
1039 |
{
|
|
1040 |
/* do no repeat, just draw the image once*/
|
|
1041 |
status = NW_Image_AbstractImage_DrawInRect (image, deviceContext, &startDraw, NULL, &rect );
|
|
1042 |
}
|
|
1043 |
|
|
1044 |
// If repeat-x, draw a row of images at startDraw.y
|
|
1045 |
else if (backgroundPropValue.token == NW_CSS_PropValue_background_repeat_x)
|
|
1046 |
{
|
|
1047 |
/* do horizonta repeat */
|
|
1048 |
/* in case the image is moved by background-position property, restore the start to left */
|
|
1049 |
if (isFixed == NW_FALSE)
|
|
1050 |
{
|
|
1051 |
startDraw.x = rect.point.x;
|
|
1052 |
}
|
|
1053 |
else
|
|
1054 |
{
|
|
1055 |
startDraw.x = viewBounds.point.x + viewOffset.x;
|
|
1056 |
}
|
|
1057 |
/*startDraw.x += deviceContext->ClipRect().point.x;*/
|
|
1058 |
|
|
1059 |
for (; startDraw.x < rect.point.x + rect.dimension.width; startDraw.x += size.width)
|
|
1060 |
{
|
|
1061 |
if (startDraw.x < viewBounds.point.x + viewOffset.x - size.width)
|
|
1062 |
continue;
|
|
1063 |
if (startDraw.x > viewBounds.point.x + viewOffset.x + viewBounds.dimension.width)
|
|
1064 |
break;
|
|
1065 |
|
|
1066 |
status = NW_Image_AbstractImage_DrawInRect (image, deviceContext, &startDraw, NULL, &rect);
|
|
1067 |
if (status != KBrsrSuccess)
|
|
1068 |
break;
|
|
1069 |
}
|
|
1070 |
}
|
|
1071 |
|
|
1072 |
// If repeat-y, draw a column of images at startDraw.x.
|
|
1073 |
else if (backgroundPropValue.token == NW_CSS_PropValue_background_repeat_y)
|
|
1074 |
{
|
|
1075 |
/* do verticall repeat */
|
|
1076 |
/* in case the image is moved by background-position property, restore the start to top */
|
|
1077 |
if (isFixed == NW_FALSE)
|
|
1078 |
{
|
|
1079 |
startDraw.y = rect.point.y;
|
|
1080 |
}
|
|
1081 |
else
|
|
1082 |
{
|
|
1083 |
startDraw.y = viewBounds.point.y + viewOffset.y;
|
|
1084 |
}
|
|
1085 |
|
|
1086 |
for (; startDraw.y < rect.point.y + rect.dimension.height; startDraw.y += size.height)
|
|
1087 |
{
|
|
1088 |
/* check to make sure only draw the images in the view */
|
|
1089 |
if (startDraw.y < viewBounds.point.y + viewOffset.y - size.height)
|
|
1090 |
continue;
|
|
1091 |
if (startDraw.y > viewBounds.point.y + viewOffset.y + viewBounds.dimension.height)
|
|
1092 |
break;
|
|
1093 |
|
|
1094 |
status = NW_Image_AbstractImage_DrawInRect (image, deviceContext, &startDraw, NULL, &rect);
|
|
1095 |
if (status != KBrsrSuccess)
|
|
1096 |
break;
|
|
1097 |
}
|
|
1098 |
}
|
|
1099 |
|
|
1100 |
// If repeating in both x and y directions and the image is a "dot"
|
|
1101 |
// stretch the image to fill the box. This speeds up rendering considerably.
|
|
1102 |
else if ((size.width == 1) && (size.height == 1))
|
|
1103 |
{
|
|
1104 |
NW_GDI_Rectangle_t realViewBounds;
|
|
1105 |
NW_GDI_Rectangle_t visibleArea;
|
|
1106 |
NW_GDI_Dimension3D_t scaledSize;
|
|
1107 |
|
|
1108 |
// Set the view rectangle
|
|
1109 |
realViewBounds = viewBounds;
|
|
1110 |
realViewBounds.point = viewOffset;
|
|
1111 |
|
|
1112 |
// Get the visible part of the box on which the image is stretched.
|
|
1113 |
if( !NW_GDI_Rectangle_Cross( &realViewBounds, &rect, &visibleArea ) )
|
|
1114 |
{
|
|
1115 |
// the box is not in the view
|
|
1116 |
NW_THROW_SUCCESS( status );
|
|
1117 |
}
|
|
1118 |
|
|
1119 |
scaledSize.width = visibleArea.dimension.width;
|
|
1120 |
scaledSize.height = visibleArea.dimension.height;
|
|
1121 |
scaledSize.depth = 0;
|
|
1122 |
|
|
1123 |
// Draw the image to fill scaledSize.
|
|
1124 |
status = NW_Image_AbstractImage_DrawScaled( image, deviceContext, &startDraw, &scaledSize );
|
|
1125 |
}
|
|
1126 |
|
|
1127 |
// Otherwise draw a grid of iamges.
|
|
1128 |
else
|
|
1129 |
{
|
|
1130 |
NW_GDI_Point2D_t boxBegin;
|
|
1131 |
NW_GDI_Point2D_t boxEnd;
|
|
1132 |
NW_GDI_Point2D_t point;
|
|
1133 |
NW_Int32 x;
|
|
1134 |
NW_Int32 y;
|
|
1135 |
|
|
1136 |
// Normalize the box's rectangle in the view.
|
|
1137 |
boxBegin.x = rect.point.x;
|
|
1138 |
boxBegin.y = rect.point.y;
|
|
1139 |
|
|
1140 |
boxEnd.x = boxBegin.x + rect.dimension.width;
|
|
1141 |
boxEnd.y = boxBegin.y + rect.dimension.height;
|
|
1142 |
|
|
1143 |
// IsFixed is only true when "background-attachment: fixed" is applied to
|
|
1144 |
// a "body" box. In this case place the first image at the top-left corner
|
|
1145 |
// of the view.
|
|
1146 |
if (isFixed)
|
|
1147 |
{
|
|
1148 |
startDraw.x = viewOffset.x;
|
|
1149 |
startDraw.y = viewOffset.y;
|
|
1150 |
}
|
|
1151 |
|
|
1152 |
// Otherwise place the first image at the top-left corner of the box.
|
|
1153 |
else
|
|
1154 |
{
|
|
1155 |
startDraw.x = boxBegin.x;
|
|
1156 |
startDraw.y = boxBegin.y;
|
|
1157 |
}
|
|
1158 |
|
|
1159 |
// Draw columns that overlap the box's rect.
|
|
1160 |
for (x = startDraw.x; x < boxEnd.x; x += size.width)
|
|
1161 |
{
|
|
1162 |
// Skip columns to the left of the box's rectangle.
|
|
1163 |
if ((x + size.width) < boxBegin.x)
|
|
1164 |
{
|
|
1165 |
continue;
|
|
1166 |
}
|
|
1167 |
|
|
1168 |
// Draw cells that overlap the box's box.
|
|
1169 |
for (y = startDraw.y; y < boxEnd.y; y += size.height)
|
|
1170 |
{
|
|
1171 |
// Skip cells above box's rectangle.
|
|
1172 |
if ((y + size.height) < boxBegin.y)
|
|
1173 |
{
|
|
1174 |
continue;
|
|
1175 |
}
|
|
1176 |
|
|
1177 |
// Draw the cell.
|
|
1178 |
point.x = x;
|
|
1179 |
point.y = y;
|
|
1180 |
|
|
1181 |
status = NW_Image_AbstractImage_DrawInRect(image, deviceContext, &point, NULL, &rect);
|
|
1182 |
_NW_THROW_ON_ERROR(status);
|
|
1183 |
}
|
|
1184 |
}
|
|
1185 |
}
|
|
1186 |
}
|
|
1187 |
|
|
1188 |
NW_CATCH (status)
|
|
1189 |
{
|
|
1190 |
}
|
|
1191 |
|
|
1192 |
NW_FINALLY
|
|
1193 |
{
|
|
1194 |
deviceContext->SetForegroundColor( initialColor);
|
|
1195 |
deviceContext->SetBackgroundColor( initialBackgroundColor);
|
|
1196 |
return status;
|
|
1197 |
}
|
|
1198 |
NW_END_TRY
|
|
1199 |
}
|
|
1200 |
|
|
1201 |
/* ------------------------------------------------------------------------- *
|
|
1202 |
* Function: NW_LMgr_Box_Draw
|
|
1203 |
* Description: The base class draw only draws the borders and the background.
|
|
1204 |
* Returns: KBrsrSuccess, KBrsrOutOfMemory.
|
|
1205 |
*/
|
|
1206 |
|
|
1207 |
TBrowserStatusCode
|
|
1208 |
_NW_LMgr_Box_Draw (NW_LMgr_Box_t* box,
|
|
1209 |
CGDIDeviceContext* deviceContext,
|
|
1210 |
NW_Uint8 hasFocus)
|
|
1211 |
{
|
|
1212 |
NW_GDI_PaintMode_t oldPaintMode;
|
|
1213 |
NW_Bool paintModeChanged = NW_FALSE;
|
|
1214 |
NW_TRY (status)
|
|
1215 |
{
|
|
1216 |
NW_LMgr_FrameInfo_t borderWidth;
|
|
1217 |
NW_LMgr_FrameInfo_t borderStyle;
|
|
1218 |
NW_LMgr_FrameInfo_t borderColor;
|
|
1219 |
NW_LMgr_PropertyValue_t displayVal;
|
|
1220 |
NW_LMgr_PropertyValue_t focusBehavior;
|
|
1221 |
NW_Bool getBorder = NW_FALSE;
|
|
1222 |
NW_LMgr_FrameInfo_t origBorderColor;
|
|
1223 |
|
|
1224 |
/* parameter assertion block */
|
|
1225 |
NW_ASSERT (box != NULL);
|
|
1226 |
NW_ASSERT (NW_Object_IsInstanceOf (box, &NW_LMgr_Box_Class));
|
|
1227 |
NW_ASSERT (deviceContext != NULL);
|
|
1228 |
|
|
1229 |
NW_LMgr_Box_Predraw(box, deviceContext, hasFocus);
|
|
1230 |
/* Check if display is actually a displayable one */
|
|
1231 |
displayVal.token = NW_CSS_PropValue_display_inline;
|
|
1232 |
(void) NW_LMgr_Box_GetPropertyValue (box, NW_CSS_Prop_display,
|
|
1233 |
NW_CSS_ValueType_Token, &displayVal);
|
|
1234 |
if (displayVal.token == NW_CSS_PropValue_none)
|
|
1235 |
{
|
|
1236 |
return KBrsrSuccess;
|
|
1237 |
}
|
|
1238 |
|
|
1239 |
// save paint mode
|
|
1240 |
oldPaintMode = deviceContext->PaintMode();
|
|
1241 |
deviceContext->SetPaintMode ( NW_GDI_PaintMode_Copy);
|
|
1242 |
paintModeChanged = NW_TRUE;
|
|
1243 |
|
|
1244 |
NW_LMgr_Box_GetBorderStyle (box, &borderStyle, ELMgrFrameAll );
|
|
1245 |
NW_LMgr_Box_GetBorderColor (box, &origBorderColor);
|
|
1246 |
|
|
1247 |
// do not check color and width unless border is present.
|
|
1248 |
if( !( borderStyle.top == NW_CSS_PropValue_none || borderStyle.top == NW_CSS_PropValue_hidden || origBorderColor.top == NW_GDI_Color_Transparent ) ||
|
|
1249 |
!( borderStyle.bottom == NW_CSS_PropValue_none || borderStyle.bottom == NW_CSS_PropValue_hidden || origBorderColor.bottom == NW_GDI_Color_Transparent) ||
|
|
1250 |
!( borderStyle.left == NW_CSS_PropValue_none || borderStyle.left == NW_CSS_PropValue_hidden || origBorderColor.left == NW_GDI_Color_Transparent ) ||
|
|
1251 |
!( borderStyle.right == NW_CSS_PropValue_none || borderStyle.right == NW_CSS_PropValue_hidden || origBorderColor.right == NW_GDI_Color_Transparent ) )
|
|
1252 |
{
|
|
1253 |
getBorder = NW_TRUE;
|
|
1254 |
NW_LMgr_Box_GetBorderColor (box, &borderColor);
|
|
1255 |
NW_LMgr_Box_GetBorderWidth (box, &borderWidth, ELMgrFrameAll );
|
|
1256 |
}
|
|
1257 |
else
|
|
1258 |
{
|
|
1259 |
// set border color to white
|
|
1260 |
borderColor.bottom = borderColor.left =
|
|
1261 |
borderColor.right = borderColor.top = NW_GDI_Color_White;
|
|
1262 |
// and the style to none
|
|
1263 |
borderWidth.bottom = borderWidth.left =
|
|
1264 |
borderWidth.right = borderWidth.top = 0;
|
|
1265 |
}
|
|
1266 |
|
|
1267 |
/* Modify the look of the box if we're in focus */
|
|
1268 |
if (hasFocus)
|
|
1269 |
{
|
|
1270 |
focusBehavior.token = NW_CSS_PropValue_none;
|
|
1271 |
(void) NW_LMgr_Box_GetPropertyValue (box, NW_CSS_Prop_focusBehavior,
|
|
1272 |
NW_CSS_ValueType_Token,
|
|
1273 |
&focusBehavior);
|
|
1274 |
|
|
1275 |
if (focusBehavior.token == NW_CSS_PropValue_growBorder)
|
|
1276 |
{
|
|
1277 |
// get the border color and style unless we already have them.
|
|
1278 |
if( getBorder == NW_FALSE )
|
|
1279 |
{
|
|
1280 |
NW_LMgr_Box_GetBorderColor (box, &borderColor);
|
|
1281 |
NW_LMgr_Box_GetBorderWidth (box, &borderWidth, ELMgrFrameAll );
|
|
1282 |
}
|
|
1283 |
borderWidth.top = (NW_GDI_Metric_t)(borderWidth.top + 1);
|
|
1284 |
borderWidth.bottom = (NW_GDI_Metric_t)(borderWidth.bottom + 1);
|
|
1285 |
borderWidth.left = (NW_GDI_Metric_t)(borderWidth.left + 1);
|
|
1286 |
borderWidth.right = (NW_GDI_Metric_t)(borderWidth.right + 1);
|
|
1287 |
|
|
1288 |
if (origBorderColor.top == NW_GDI_Color_Transparent)
|
|
1289 |
{
|
|
1290 |
borderStyle.top = NW_CSS_PropValue_solid;
|
|
1291 |
borderColor.top = deviceContext->ForegroundColor();
|
|
1292 |
}
|
|
1293 |
if (origBorderColor.bottom == NW_GDI_Color_Transparent)
|
|
1294 |
{
|
|
1295 |
borderStyle.bottom = NW_CSS_PropValue_solid;
|
|
1296 |
borderColor.bottom = deviceContext->ForegroundColor();
|
|
1297 |
}
|
|
1298 |
if (origBorderColor.left == NW_GDI_Color_Transparent)
|
|
1299 |
{
|
|
1300 |
borderStyle.left = NW_CSS_PropValue_solid;
|
|
1301 |
borderColor.left = deviceContext->ForegroundColor();
|
|
1302 |
}
|
|
1303 |
if (origBorderColor.right == NW_GDI_Color_Transparent)
|
|
1304 |
{
|
|
1305 |
borderStyle.right = NW_CSS_PropValue_solid;
|
|
1306 |
borderColor.right = deviceContext->ForegroundColor();
|
|
1307 |
}
|
|
1308 |
if ((borderStyle.top == NW_CSS_PropValue_none) || (borderStyle.top == NW_CSS_PropValue_hidden))
|
|
1309 |
{
|
|
1310 |
borderStyle.top = NW_CSS_PropValue_solid;
|
|
1311 |
}
|
|
1312 |
if ((borderStyle.bottom == NW_CSS_PropValue_none) || (borderStyle.bottom == NW_CSS_PropValue_hidden))
|
|
1313 |
{
|
|
1314 |
borderStyle.bottom = NW_CSS_PropValue_solid;
|
|
1315 |
}
|
|
1316 |
if ((borderStyle.left == NW_CSS_PropValue_none) || (borderStyle.left == NW_CSS_PropValue_hidden))
|
|
1317 |
{
|
|
1318 |
borderStyle.left = NW_CSS_PropValue_solid;
|
|
1319 |
}
|
|
1320 |
if ((borderStyle.right == NW_CSS_PropValue_none) || (borderStyle.right == NW_CSS_PropValue_hidden))
|
|
1321 |
{
|
|
1322 |
borderStyle.right = NW_CSS_PropValue_solid;
|
|
1323 |
}
|
|
1324 |
}
|
|
1325 |
}
|
|
1326 |
|
|
1327 |
/* TODO: if cache is empty, ignore CSS imposed by "a:visited" pseudo-class,
|
|
1328 |
but for now we just fix the color */
|
|
1329 |
|
|
1330 |
/* Check for link by looking at parent container. */
|
|
1331 |
if (NW_LMgr_Box_GetParent(box) != NULL && NW_Object_IsClass(NW_LMgr_Box_GetParent(box), &NW_LMgr_ActiveContainerBox_Class))
|
|
1332 |
{
|
|
1333 |
/* If Cache is empty, force border to be drawn in uncached color (blue).
|
|
1334 |
NOTE: GetNumEntries allocates a list of the cached files, so avoid it for non-links. */
|
|
1335 |
//if (UrlLoader_GetNumCacheEntries() == 0)
|
|
1336 |
// {
|
|
1337 |
// borderColor.top = NW_GDI_Color_Blue;
|
|
1338 |
// borderColor.bottom = NW_GDI_Color_Blue;
|
|
1339 |
// borderColor.left = NW_GDI_Color_Blue;
|
|
1340 |
// borderColor.right = NW_GDI_Color_Blue;
|
|
1341 |
// }
|
|
1342 |
}
|
|
1343 |
/* draw the border */
|
|
1344 |
/* TODO add support for other border types */
|
|
1345 |
status = NW_LMgr_Box_DrawBorder( NW_LMgr_Box_GetDisplayBounds(box), deviceContext, &borderWidth, &borderStyle, &borderColor);
|
|
1346 |
_NW_THROW_ON_ERROR(status);
|
|
1347 |
}
|
|
1348 |
NW_CATCH (status)
|
|
1349 |
{
|
|
1350 |
}
|
|
1351 |
NW_FINALLY
|
|
1352 |
{
|
|
1353 |
if( paintModeChanged == NW_TRUE )
|
|
1354 |
{
|
|
1355 |
// reset paint mode
|
|
1356 |
deviceContext->SetPaintMode( oldPaintMode );
|
|
1357 |
}
|
|
1358 |
return status;
|
|
1359 |
}
|
|
1360 |
NW_END_TRY
|
|
1361 |
}
|
|
1362 |
|
|
1363 |
/* -------------------------------------------------------------------------------- *
|
|
1364 |
* Function: NW_LMgr_Box_Update_RenderCache
|
|
1365 |
* Description: Updates the render cache
|
|
1366 |
* Returns: NW_TRUE, NW_FALSE
|
|
1367 |
*/
|
|
1368 |
|
|
1369 |
NW_Bool NW_LMgr_Box_Update_RenderCache (NW_LMgr_RootBox_t* rootBox,
|
|
1370 |
NW_LMgr_Box_t* box,
|
|
1371 |
NW_GDI_Rectangle_t* realClip,
|
|
1372 |
void ***ptr)
|
|
1373 |
{
|
|
1374 |
NW_Bool cachePresent = NW_FALSE;
|
|
1375 |
if (rootBox->renderedBoxes && rootBox->renderedClips )
|
|
1376 |
{
|
|
1377 |
cachePresent = NW_TRUE;
|
|
1378 |
NW_ADT_Vector_Metric_t index = NW_ADT_Vector_GetElementIndex(rootBox->renderedBoxes, &box);
|
|
1379 |
if (index == NW_ADT_Vector_AtEnd)
|
|
1380 |
{
|
|
1381 |
*ptr = NW_ADT_DynamicVector_InsertAt(rootBox->renderedBoxes, &box, NW_ADT_Vector_AtEnd);
|
|
1382 |
if (*ptr == NULL)
|
|
1383 |
return cachePresent;
|
|
1384 |
*ptr = NW_ADT_DynamicVector_InsertAt(rootBox->renderedClips, realClip, NW_ADT_Vector_AtEnd);
|
|
1385 |
if (*ptr == NULL)
|
|
1386 |
return cachePresent;
|
|
1387 |
}
|
|
1388 |
else
|
|
1389 |
{
|
|
1390 |
*ptr = NW_ADT_DynamicVector_ReplaceAt(rootBox->renderedBoxes, &box, index);
|
|
1391 |
if (*ptr == NULL)
|
|
1392 |
return cachePresent;
|
|
1393 |
|
|
1394 |
*ptr = NW_ADT_DynamicVector_ReplaceAt(rootBox->renderedClips, realClip, index);
|
|
1395 |
if (*ptr == NULL)
|
|
1396 |
return cachePresent;
|
|
1397 |
}
|
|
1398 |
}
|
|
1399 |
return cachePresent;
|
|
1400 |
}
|
|
1401 |
|
|
1402 |
/* -------------------------------------------------------------------------------- *
|
|
1403 |
* Function: NW_LMgr_Box_Render
|
|
1404 |
* Description: Renders the box.
|
|
1405 |
* Returns: KBrsrSuccess, KBrsrOutOfMemory
|
|
1406 |
*/
|
|
1407 |
|
|
1408 |
TBrowserStatusCode
|
|
1409 |
_NW_LMgr_Box_Render (NW_LMgr_Box_t* box,
|
|
1410 |
CGDIDeviceContext* deviceContext,
|
|
1411 |
NW_GDI_Rectangle_t* clipRect,
|
|
1412 |
NW_LMgr_Box_t* currentBox,
|
|
1413 |
NW_Uint8 flags,
|
|
1414 |
NW_Bool* hasFocus,
|
|
1415 |
NW_Bool* skipChildren,
|
|
1416 |
NW_LMgr_RootBox_t* rootBox )
|
|
1417 |
{
|
|
1418 |
NW_GDI_Rectangle_t visibleArea;
|
|
1419 |
NW_LMgr_PropertyValue_t floatVal;
|
|
1420 |
NW_LMgr_PropertyValue_t visibilityVal;
|
|
1421 |
NW_GDI_Rectangle_t viewBounds;
|
|
1422 |
NW_GDI_Rectangle_t oldClip = {{0, 0}, {0, 0}};
|
|
1423 |
NW_GDI_Rectangle_t realClip;
|
|
1424 |
NW_Bool clipRectChanged = NW_FALSE;
|
|
1425 |
void** ptr = NULL;
|
|
1426 |
|
|
1427 |
NW_TRY (status)
|
|
1428 |
{
|
|
1429 |
/* Should we draw floats? */
|
|
1430 |
if (!(flags & NW_LMgr_Box_Flags_DrawFloats))
|
|
1431 |
{
|
|
1432 |
floatVal.token = NW_CSS_PropValue_none;
|
|
1433 |
(void) NW_LMgr_Box_GetPropertyValue (box, NW_CSS_Prop_float,
|
|
1434 |
NW_CSS_ValueType_Token, &floatVal);
|
|
1435 |
if (floatVal.token != NW_CSS_PropValue_none)
|
|
1436 |
{
|
|
1437 |
NW_THROW_SUCCESS (status);
|
|
1438 |
}
|
|
1439 |
}
|
|
1440 |
// check if the this box has focus
|
|
1441 |
// if hasFocus is already set to true by any parent
|
|
1442 |
// then it should not be overuled.
|
|
1443 |
if( !(*hasFocus) && currentBox == box )
|
|
1444 |
{
|
|
1445 |
*hasFocus = NW_TRUE;
|
|
1446 |
}
|
|
1447 |
|
|
1448 |
/* Calculate the view bounds */
|
|
1449 |
viewBounds = *(deviceContext->DisplayBounds());
|
|
1450 |
viewBounds.point = *(deviceContext->Origin());
|
|
1451 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetDisplayBounds( box );
|
|
1452 |
|
|
1453 |
/* Calculate tree extents first */
|
|
1454 |
if (!NW_GDI_Rectangle_Cross(clipRect, &boxBounds, &visibleArea))
|
|
1455 |
{
|
|
1456 |
NW_THROW_SUCCESS (status);
|
|
1457 |
}
|
|
1458 |
/* Is the box visible on screen? If not, we don't draw */
|
|
1459 |
if (!NW_GDI_Rectangle_Cross(&viewBounds, &visibleArea, NULL))
|
|
1460 |
{
|
|
1461 |
NW_THROW_SUCCESS (status);
|
|
1462 |
}
|
|
1463 |
/* Calculate the part of the clip that is visible on screen;
|
|
1464 |
if the clip is off-screen, don't draw */
|
|
1465 |
if (!NW_GDI_Rectangle_Cross(clipRect, &viewBounds, &realClip))
|
|
1466 |
{
|
|
1467 |
NW_THROW_SUCCESS (status);
|
|
1468 |
}
|
|
1469 |
|
|
1470 |
/* Save the old clip rect */
|
|
1471 |
oldClip = deviceContext->ClipRect();
|
|
1472 |
/* Set the new clip rect */
|
|
1473 |
deviceContext->SetClipRect( &realClip );
|
|
1474 |
clipRectChanged = NW_TRUE;
|
|
1475 |
|
|
1476 |
/* Check if visibility val is not hidden */
|
|
1477 |
visibilityVal.token = NW_CSS_PropValue_visible;
|
|
1478 |
(void) NW_LMgr_Box_GetPropertyValue (box, NW_CSS_Prop_visibility,
|
|
1479 |
NW_CSS_ValueType_Token, &visibilityVal);
|
|
1480 |
if ((visibilityVal.token == NW_CSS_PropValue_hidden) ||
|
|
1481 |
(visibilityVal.token == NW_CSS_PropValue_collapse))
|
|
1482 |
{
|
|
1483 |
NW_THROW_SUCCESS(status);
|
|
1484 |
}
|
|
1485 |
|
|
1486 |
/* make the box draw itself */
|
|
1487 |
status = NW_LMgr_Box_Draw (box, deviceContext, *hasFocus);
|
|
1488 |
_NW_THROW_ON_ERROR (status);
|
|
1489 |
|
|
1490 |
/* Add the box and the clip to the cache */
|
|
1491 |
NW_Bool cachePresent = NW_LMgr_Box_Update_RenderCache (rootBox, box, &realClip, &ptr);
|
|
1492 |
if (cachePresent)
|
|
1493 |
{
|
|
1494 |
NW_THROW_OOM_ON_NULL(ptr, status);
|
|
1495 |
}
|
|
1496 |
}
|
|
1497 |
NW_CATCH (status)
|
|
1498 |
{
|
|
1499 |
}
|
|
1500 |
NW_FINALLY
|
|
1501 |
{
|
|
1502 |
// box has no child
|
|
1503 |
*skipChildren = NW_FALSE;
|
|
1504 |
|
|
1505 |
if( clipRectChanged == NW_TRUE )
|
|
1506 |
{
|
|
1507 |
/* Reset the clip rect */
|
|
1508 |
deviceContext->SetClipRect( &oldClip);
|
|
1509 |
}
|
|
1510 |
return status;
|
|
1511 |
}
|
|
1512 |
NW_END_TRY
|
|
1513 |
}
|
|
1514 |
|
|
1515 |
/* ------------------------------------------------------------------------- *
|
|
1516 |
* Function: NW_LMgr_Box_GetBaseline
|
|
1517 |
* Description: Returns the baseline of a box. The default implementation
|
|
1518 |
* returns the bottom of the box content area as the baseline.
|
|
1519 |
* Returns: KBrsrSuccess, KBrsrOutOfMemory.
|
|
1520 |
*/
|
|
1521 |
|
|
1522 |
NW_GDI_Metric_t
|
|
1523 |
_NW_LMgr_Box_GetBaseline(NW_LMgr_Box_t* box){
|
|
1524 |
|
|
1525 |
NW_ASSERT(box != NULL);
|
|
1526 |
|
|
1527 |
return (NW_GDI_Metric_t)(NW_LMgr_Box_GetFormatBounds(box).dimension.height);
|
|
1528 |
}
|
|
1529 |
|
|
1530 |
/* ------------------------------------------------------------------------- *
|
|
1531 |
* Function: NW_LMgr_Box_Shift
|
|
1532 |
* Description: Shifts the contents of the box by a given offset. The default
|
|
1533 |
* implementation simply modifies the box boundaries.
|
|
1534 |
* Returns: KBrsrSuccess
|
|
1535 |
*/
|
|
1536 |
|
|
1537 |
TBrowserStatusCode
|
|
1538 |
_NW_LMgr_Box_Shift (NW_LMgr_Box_t* box, NW_GDI_Point2D_t *delta){
|
|
1539 |
|
|
1540 |
NW_ASSERT(box != NULL);
|
|
1541 |
|
|
1542 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetFormatBounds( box );
|
|
1543 |
boxBounds.point.x = (NW_GDI_Metric_t)(boxBounds.point.x + delta->x);
|
|
1544 |
boxBounds.point.y = (NW_GDI_Metric_t)(boxBounds.point.y + delta->y);
|
|
1545 |
NW_LMgr_Box_SetFormatBounds( box, boxBounds );
|
|
1546 |
|
|
1547 |
return KBrsrSuccess;
|
|
1548 |
}
|
|
1549 |
|
|
1550 |
/* ------------------------------------------------------------------------- *
|
|
1551 |
* Function: NW_LMgr_Box_Clone
|
|
1552 |
* Description: Clone returns a "deep" copy of the box, where the actual definition of
|
|
1553 |
* "deep" is up to the individual box type. The default implementation
|
|
1554 |
* fails. Only the ContainerBox and its descendants have
|
|
1555 |
* meaningful implementations at present, because they are the only
|
|
1556 |
* ones that need it. TODO: Fix this.
|
|
1557 |
* Returns: NULL.
|
|
1558 |
*/
|
|
1559 |
|
|
1560 |
NW_LMgr_Box_t*
|
|
1561 |
_NW_LMgr_Box_Clone (NW_LMgr_Box_t* box){
|
|
1562 |
|
|
1563 |
NW_REQUIRED_PARAM(box);
|
|
1564 |
NW_ASSERT(0);
|
|
1565 |
|
|
1566 |
return NULL;
|
|
1567 |
}
|
|
1568 |
|
|
1569 |
/* ------------------------------------------------------------------------- *
|
|
1570 |
protected methods
|
|
1571 |
* ------------------------------------------------------------------------- */
|
|
1572 |
|
|
1573 |
/* ------------------------------------------------------------------------- *
|
|
1574 |
public methods
|
|
1575 |
* ------------------------------------------------------------------------- */
|
|
1576 |
|
|
1577 |
/* ------------------------------------------------------------------------- *
|
|
1578 |
* Function: NW_LMgr_Box_GetRawProperty
|
|
1579 |
* Description: Tries to get a property from the box's own property list.
|
|
1580 |
* Property inheritance is ignored.
|
|
1581 |
* Returns: KBrsrSuccess, KBrsrNotFound.
|
|
1582 |
*/
|
|
1583 |
|
|
1584 |
TBrowserStatusCode
|
|
1585 |
NW_LMgr_Box_GetRawProperty(NW_LMgr_Box_t *box,
|
|
1586 |
NW_LMgr_PropertyName_t name,
|
|
1587 |
NW_LMgr_Property_t* property)
|
|
1588 |
{
|
|
1589 |
TBrowserStatusCode status;
|
|
1590 |
NW_LMgr_Property_t origProperty;
|
|
1591 |
|
|
1592 |
NW_ASSERT(box != NULL);
|
|
1593 |
|
|
1594 |
if(box->propList != NULL){
|
|
1595 |
status = NW_LMgr_PropertyList_Get(box->propList, name, &origProperty);
|
|
1596 |
if (status != KBrsrSuccess) {
|
|
1597 |
return KBrsrNotFound;
|
|
1598 |
}
|
|
1599 |
|
|
1600 |
property->type = (NW_LMgr_PropertyValueType_t)(origProperty.type & NW_CSS_ValueType_Mask);
|
|
1601 |
property->value = origProperty.value;
|
|
1602 |
|
|
1603 |
status = KBrsrSuccess;
|
|
1604 |
}
|
|
1605 |
else {
|
|
1606 |
status = KBrsrNotFound;
|
|
1607 |
}
|
|
1608 |
|
|
1609 |
return status;
|
|
1610 |
}
|
|
1611 |
|
|
1612 |
/* ------------------------------------------------------------------------- *
|
|
1613 |
* Function: NW_LMgr_Box_GetPropertyFromList
|
|
1614 |
* Description: Tries to get a property from the box's own property list.
|
|
1615 |
* Property inheritance is ignored.
|
|
1616 |
* Returns: KBrsrSuccess, KBrsrNotFound.
|
|
1617 |
*/
|
|
1618 |
|
|
1619 |
TBrowserStatusCode
|
|
1620 |
NW_LMgr_Box_GetPropertyFromList(NW_LMgr_Box_t* box,
|
|
1621 |
NW_LMgr_PropertyName_t name,
|
|
1622 |
NW_LMgr_Property_t* property)
|
|
1623 |
{
|
|
1624 |
TBrowserStatusCode status;
|
|
1625 |
NW_LMgr_Property_t origProperty;
|
|
1626 |
NW_Bool specialProperty, isMargin = NW_FALSE, isMarker = NW_FALSE;
|
|
1627 |
|
|
1628 |
NW_ASSERT(box != NULL);
|
|
1629 |
|
|
1630 |
if( box->propList )
|
|
1631 |
{
|
|
1632 |
// In Vertical Layout Mode, table, tr, td, th need to ignore margin, padding,
|
|
1633 |
// border, whitespace. This special handling is done in
|
|
1634 |
// NW_LMgr_VerticalTableBox_GetPropertyFromList.
|
|
1635 |
// For rest of the properties (specialProperty flag is false) we handle them
|
|
1636 |
// the normal way
|
|
1637 |
if (NW_Object_IsClass(box, &NW_LMgr_VerticalTableBox_Class) ||
|
|
1638 |
NW_Object_IsClass(box, &NW_LMgr_VerticalTableCellBox_Class) ||
|
|
1639 |
NW_Object_IsClass(box, &NW_LMgr_VerticalTableRowBox_Class))
|
|
1640 |
{
|
|
1641 |
status = NW_LMgr_VerticalTableBox_GetPropertyFromList(box, name, property, &specialProperty);
|
|
1642 |
if (specialProperty)
|
|
1643 |
{
|
|
1644 |
return status;
|
|
1645 |
}
|
|
1646 |
}
|
|
1647 |
|
|
1648 |
if(NW_Object_IsInstanceOf(box, &LMgrMarkerImage_Class) || NW_Object_IsInstanceOf(box, &LMgrMarkerText_Class))
|
|
1649 |
{
|
|
1650 |
isMarker = NW_TRUE;
|
|
1651 |
}
|
|
1652 |
if( NW_LMgr_RootBox_GetSmallScreenOn( NW_LMgr_Box_GetRootBox( box ) ) )
|
|
1653 |
{
|
|
1654 |
if((name == NW_CSS_Prop_margin) || (name == NW_CSS_Prop_leftMargin) ||
|
|
1655 |
(name == NW_CSS_Prop_rightMargin) || (name == NW_CSS_Prop_topMargin) ||
|
|
1656 |
(name == NW_CSS_Prop_bottomMargin) )
|
|
1657 |
{
|
|
1658 |
isMargin = NW_TRUE;
|
|
1659 |
if( NW_Object_IsDerivedFrom(box, &NW_LMgr_ImgContainerBox_Class) && !isMarker)
|
|
1660 |
{
|
|
1661 |
return KBrsrNotFound;
|
|
1662 |
}
|
|
1663 |
}
|
|
1664 |
}
|
|
1665 |
|
|
1666 |
status = NW_LMgr_PropertyList_Get(box->propList, name, &origProperty);
|
|
1667 |
if (status != KBrsrSuccess)
|
|
1668 |
{
|
|
1669 |
return KBrsrNotFound;
|
|
1670 |
}
|
|
1671 |
|
|
1672 |
if(isMargin && !isMarker)
|
|
1673 |
{
|
|
1674 |
if(origProperty.value.integer < 0)
|
|
1675 |
{
|
|
1676 |
property->value.integer = 0;
|
|
1677 |
return KBrsrSuccess;
|
|
1678 |
}
|
|
1679 |
}
|
|
1680 |
|
|
1681 |
*property = origProperty;
|
|
1682 |
status = NW_LMgr_Box_ResolveRelativeProperty (box, name, property);
|
|
1683 |
if (status != KBrsrSuccess)
|
|
1684 |
{
|
|
1685 |
return KBrsrNotFound;
|
|
1686 |
}
|
|
1687 |
|
|
1688 |
property->type = (NW_LMgr_PropertyValueType_t)(property->type & NW_CSS_ValueType_Mask);
|
|
1689 |
|
|
1690 |
status = KBrsrSuccess;
|
|
1691 |
}
|
|
1692 |
else
|
|
1693 |
{
|
|
1694 |
status = KBrsrNotFound;
|
|
1695 |
}
|
|
1696 |
|
|
1697 |
return status;
|
|
1698 |
}
|
|
1699 |
|
|
1700 |
/* ------------------------------------------------------------------------- *
|
|
1701 |
* Function: NW_LMgr_Box_GetProperty
|
|
1702 |
* Description: Tries to get a property from the box's own property list.
|
|
1703 |
* If the property is not found, and the property is inherited,
|
|
1704 |
* it queries the ancestors for it.
|
|
1705 |
* Returns: KBrsrSuccess, KBrsrNotFound.
|
|
1706 |
*/
|
|
1707 |
|
|
1708 |
TBrowserStatusCode
|
|
1709 |
NW_LMgr_Box_GetProperty (NW_LMgr_Box_t* box,
|
|
1710 |
NW_LMgr_PropertyName_t name,
|
|
1711 |
NW_LMgr_Property_t* property)
|
|
1712 |
{
|
|
1713 |
NW_LMgr_Box_t* childBox = box;
|
|
1714 |
NW_Bool lookingForInheritProp = NW_FALSE;
|
|
1715 |
// parameter assertion block
|
|
1716 |
NW_ASSERT (NW_Object_IsInstanceOf (box, &NW_LMgr_Box_Class));
|
|
1717 |
|
|
1718 |
do
|
|
1719 |
{
|
|
1720 |
TBrowserStatusCode status;
|
|
1721 |
NW_LMgr_Property_t p;
|
|
1722 |
|
|
1723 |
status = NW_LMgr_Box_GetPropertyFromList(box, name, &p);
|
|
1724 |
if( status == KBrsrSuccess )
|
|
1725 |
{
|
|
1726 |
if( p.type != NW_CSS_ValueType_Token ||
|
|
1727 |
p.value.token != NW_CSS_PropValue_inherit)
|
|
1728 |
{
|
|
1729 |
// if we are looking for inherit property, then
|
|
1730 |
// first make sure that the property value did not get resolved
|
|
1731 |
// while calling NW_LMgr_Box_GetPropertyFromList on the parent box.
|
|
1732 |
// if it was modified, then we need to take a look at the
|
|
1733 |
// original type to check if resolving the value is appropriate here.
|
|
1734 |
// for examp: parent has 50% as height which gets resolved to 100px,
|
|
1735 |
// so then we get the inherited value as 100px instead of the correct
|
|
1736 |
// 50% (50px)
|
|
1737 |
if( lookingForInheritProp == NW_TRUE && box->propList )
|
|
1738 |
{
|
|
1739 |
NW_LMgr_Property_t origProperty;
|
|
1740 |
status = NW_LMgr_PropertyList_Get( box->propList, name, &origProperty );
|
|
1741 |
if( status == KBrsrSuccess && origProperty.type != p.type )
|
|
1742 |
{
|
|
1743 |
// resolve the original value on the child now
|
|
1744 |
status = NW_LMgr_Box_ResolveRelativeProperty( childBox, name, &origProperty);
|
|
1745 |
if( status == KBrsrSuccess )
|
|
1746 |
{
|
|
1747 |
*property = origProperty;
|
|
1748 |
property->type =
|
|
1749 |
(NW_LMgr_PropertyValueType_t) (property->type & NW_CSS_ValueType_Mask);
|
|
1750 |
return KBrsrSuccess;
|
|
1751 |
}
|
|
1752 |
}
|
|
1753 |
}
|
|
1754 |
*property = p;
|
|
1755 |
property->type =
|
|
1756 |
(NW_LMgr_PropertyValueType_t) (property->type & NW_CSS_ValueType_Mask);
|
|
1757 |
return KBrsrSuccess;
|
|
1758 |
}
|
|
1759 |
}
|
|
1760 |
else
|
|
1761 |
{
|
|
1762 |
if (!(name & NW_CSS_PropInherit))
|
|
1763 |
{
|
|
1764 |
// drop out and return "not found"
|
|
1765 |
break;
|
|
1766 |
}
|
|
1767 |
}
|
|
1768 |
// The prop is inherit
|
|
1769 |
lookingForInheritProp = NW_TRUE;
|
|
1770 |
box = (NW_LMgr_Box_t*) NW_LMgr_Box_GetParent (box);
|
|
1771 |
if( !box )
|
|
1772 |
{
|
|
1773 |
break;
|
|
1774 |
}
|
|
1775 |
// note: Allow reading direction property from anonymous box
|
|
1776 |
if (name != NW_CSS_Prop_textDirection)
|
|
1777 |
{
|
|
1778 |
// Check if the parent is an anonymous box
|
|
1779 |
if (NW_Object_IsInstanceOf(box, &LMgrAnonBlock_Class))
|
|
1780 |
{
|
|
1781 |
// this parent is an anonymous box, we should go up to see if grandpa has
|
|
1782 |
// the prop we are interested.
|
|
1783 |
box = (NW_LMgr_Box_t*) NW_LMgr_Box_GetParent( box );
|
|
1784 |
}
|
|
1785 |
}
|
|
1786 |
} while( box );
|
|
1787 |
|
|
1788 |
// the property was not found
|
|
1789 |
return KBrsrNotFound;
|
|
1790 |
}
|
|
1791 |
|
|
1792 |
/* ------------------------------------------------------------------------- *
|
|
1793 |
* Function: NW_LMgr_Box_GetPropertyValue
|
|
1794 |
* Description: Same as GetProperty, only the type of the property is not returned.
|
|
1795 |
* Returns: KBrsrSuccess, KBrsrNotFound.
|
|
1796 |
*/
|
|
1797 |
|
|
1798 |
/* TODO: This method should go away. We should always query for the property type.
|
|
1799 |
*/
|
|
1800 |
|
|
1801 |
TBrowserStatusCode
|
|
1802 |
NW_LMgr_Box_GetPropertyValue (NW_LMgr_Box_t *box,
|
|
1803 |
NW_LMgr_PropertyName_t name,
|
|
1804 |
NW_LMgr_PropertyValueType_t type,
|
|
1805 |
NW_LMgr_PropertyValue_t *value)
|
|
1806 |
{
|
|
1807 |
NW_LMgr_Property_t property;
|
|
1808 |
TBrowserStatusCode status;
|
|
1809 |
NW_LMgr_RootBox_t* rootBox;
|
|
1810 |
NW_Bool flag;
|
|
1811 |
NW_Bool inMarquee = NW_FALSE;
|
|
1812 |
|
|
1813 |
NW_ASSERT(box != NULL);
|
|
1814 |
|
|
1815 |
status = NW_LMgr_Box_GetProperty (box, name, &property);
|
|
1816 |
if (status != KBrsrSuccess) {
|
|
1817 |
return status;
|
|
1818 |
}
|
|
1819 |
|
|
1820 |
if (type == (property.type & NW_CSS_ValueType_Mask))
|
|
1821 |
{
|
|
1822 |
*value = property.value;
|
|
1823 |
rootBox = NW_LMgr_Box_GetRootBox( box );
|
|
1824 |
flag = NW_LMgr_RootBox_GetSmallScreenOn( rootBox );
|
|
1825 |
|
|
1826 |
if (NW_Object_IsInstanceOf(box, &NW_LMgr_BidiFlowBox_Class))
|
|
1827 |
{
|
|
1828 |
/* we want to limit the width of the FlowBoxes to be the display width
|
|
1829 |
in vertical layout mode
|
|
1830 |
*/
|
|
1831 |
if ((name == NW_CSS_Prop_width) && flag)
|
|
1832 |
{
|
|
1833 |
CGDIDeviceContext* deviceContext;
|
|
1834 |
const NW_GDI_Rectangle_t* rectangle;
|
|
1835 |
|
|
1836 |
deviceContext = NW_LMgr_RootBox_GetDeviceContext (rootBox);
|
|
1837 |
rectangle = deviceContext->DisplayBounds();
|
|
1838 |
|
|
1839 |
if (value->integer > rectangle->dimension.width)
|
|
1840 |
{
|
|
1841 |
value->integer = (NW_Uint32)(rectangle->dimension.width-4);
|
|
1842 |
}
|
|
1843 |
}
|
|
1844 |
}
|
|
1845 |
/* In vertical layout mode, we want to ignore the whitespace property */
|
|
1846 |
if ((name == NW_CSS_Prop_whitespace) && flag)
|
|
1847 |
{
|
|
1848 |
while( box != NULL )
|
|
1849 |
{
|
|
1850 |
if( NW_Object_IsClass( box, &NW_LMgr_MarqueeBox_Class ) == NW_TRUE )
|
|
1851 |
{
|
|
1852 |
inMarquee = NW_TRUE;
|
|
1853 |
break;
|
|
1854 |
}
|
|
1855 |
if (!box->parent)
|
|
1856 |
{
|
|
1857 |
break;
|
|
1858 |
}
|
|
1859 |
box = NW_LMgr_BoxOf( box->parent );
|
|
1860 |
}
|
|
1861 |
if (!inMarquee)
|
|
1862 |
{
|
|
1863 |
if (value->token == NW_CSS_PropValue_pre)
|
|
1864 |
{
|
|
1865 |
value->token = NW_CSS_PropValue_flags_smallScreenPre;
|
|
1866 |
} else {
|
|
1867 |
value->token = NW_CSS_PropValue_normal;
|
|
1868 |
}
|
|
1869 |
}
|
|
1870 |
}
|
|
1871 |
return KBrsrSuccess;
|
|
1872 |
} else {
|
|
1873 |
return KBrsrNotFound;
|
|
1874 |
}
|
|
1875 |
}
|
|
1876 |
|
|
1877 |
/* ------------------------------------------------------------------------- *
|
|
1878 |
* Function: NW_LMgr_Box_SetProperty
|
|
1879 |
* Description: Sets a property on a box.
|
|
1880 |
* Returns: KBrsrSuccess if successful; KBrsrOutOfMemory if
|
|
1881 |
* out of memory.
|
|
1882 |
*/
|
|
1883 |
|
|
1884 |
TBrowserStatusCode
|
|
1885 |
NW_LMgr_Box_SetProperty (NW_LMgr_Box_t* box,
|
|
1886 |
NW_LMgr_PropertyName_t name,
|
|
1887 |
NW_LMgr_Property_t* property)
|
|
1888 |
{
|
|
1889 |
NW_TRY (status) {
|
|
1890 |
NW_ASSERT(box != NULL);
|
|
1891 |
|
|
1892 |
if (box->propList == NULL) {
|
|
1893 |
box->propList =
|
|
1894 |
(NW_LMgr_PropertyList_t*) NW_LMgr_SimplePropertyList_New( 2, 10 );
|
|
1895 |
NW_THROW_OOM_ON_NULL (box->propList, status);
|
|
1896 |
}
|
|
1897 |
|
|
1898 |
status = NW_LMgr_PropertyList_Set (box->propList, name, property);
|
|
1899 |
_NW_THROW_ON_ERROR (status);
|
|
1900 |
|
|
1901 |
} NW_CATCH (status) {
|
|
1902 |
} NW_FINALLY {
|
|
1903 |
return status;
|
|
1904 |
} NW_END_TRY
|
|
1905 |
}
|
|
1906 |
|
|
1907 |
/* ------------------------------------------------------------------------- *
|
|
1908 |
* Function: NW_LMgr_Box_RemoveProperty
|
|
1909 |
* Description: Removes a property from a box.
|
|
1910 |
* Returns: KBrsrSuccess if successful; KBrsrOutOfMemory if
|
|
1911 |
* out of memory.
|
|
1912 |
*/
|
|
1913 |
|
|
1914 |
TBrowserStatusCode
|
|
1915 |
NW_LMgr_Box_RemoveProperty (NW_LMgr_Box_t* box,
|
|
1916 |
NW_LMgr_PropertyName_t name)
|
|
1917 |
{
|
|
1918 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
1919 |
|
|
1920 |
NW_ASSERT(box != NULL);
|
|
1921 |
|
|
1922 |
if (box->propList != NULL) {
|
|
1923 |
status = NW_LMgr_PropertyList_Remove (box->propList, name);
|
|
1924 |
}
|
|
1925 |
|
|
1926 |
return status;
|
|
1927 |
}
|
|
1928 |
|
|
1929 |
/* ------------------------------------------------------------------------- *
|
|
1930 |
* Function: NW_LMgr_Box_RemovePropertyWithoutDelete
|
|
1931 |
* Description: Removes a property from a box; however, does NOT delete the property
|
|
1932 |
* Only for simple property list
|
|
1933 |
* Returns: KBrsrSuccess if successful; KBrsrOutOfMemory if
|
|
1934 |
* out of memory.
|
|
1935 |
*/
|
|
1936 |
|
|
1937 |
TBrowserStatusCode
|
|
1938 |
NW_LMgr_Box_RemovePropertyWithoutDelete (NW_LMgr_Box_t* box,
|
|
1939 |
NW_LMgr_PropertyName_t name)
|
|
1940 |
{
|
|
1941 |
TBrowserStatusCode status = KBrsrSuccess;
|
|
1942 |
|
|
1943 |
NW_ASSERT(box != NULL);
|
|
1944 |
NW_ASSERT( NW_Object_IsInstanceOf(box->propList, &NW_LMgr_SimplePropertyList_Class) );
|
|
1945 |
|
|
1946 |
if (box->propList != NULL)
|
|
1947 |
{
|
|
1948 |
status = NW_LMgr_SimplePropertyList_RemoveWithoutDelete (
|
|
1949 |
(NW_LMgr_SimplePropertyList_t*)(box->propList),
|
|
1950 |
name);
|
|
1951 |
}
|
|
1952 |
|
|
1953 |
return status;
|
|
1954 |
}
|
|
1955 |
|
|
1956 |
/* ------------------------------------------------------------------------- *
|
|
1957 |
* Function: NW_LMgr_Box_ApplyFontProps
|
|
1958 |
* Description: Use the CSS properties of a text box to match a GDI font and cache
|
|
1959 |
* this as the NW_Prop_GDI_Font property. The allocates a font object
|
|
1960 |
* which needs to be freed when the box is destroyed.
|
|
1961 |
* Returns: KBrsrSuccess, KBrsrOutOfMemory.
|
|
1962 |
*/
|
|
1963 |
TBrowserStatusCode
|
|
1964 |
NW_LMgr_Box_ApplyFontProps (NW_LMgr_Box_t* box)
|
|
1965 |
{
|
|
1966 |
NW_LMgr_Property_t fontProp;
|
|
1967 |
|
|
1968 |
fontProp.type = NW_CSS_ValueType_Font;
|
|
1969 |
fontProp.value.object = NULL;
|
|
1970 |
|
|
1971 |
NW_TRY (status)
|
|
1972 |
{
|
|
1973 |
NW_LMgr_RootBox_t* rootBox;
|
|
1974 |
CGDIDeviceContext* deviceContext;
|
|
1975 |
NW_LMgr_Property_t fontFamily;
|
|
1976 |
NW_LMgr_Property_t size;
|
|
1977 |
NW_LMgr_Property_t style;
|
|
1978 |
NW_LMgr_Property_t weight;
|
|
1979 |
NW_LMgr_Property_t variant;
|
|
1980 |
NW_Uint8 gdiFontStyle;
|
|
1981 |
NW_Uint8 gdiFontVariant;
|
|
1982 |
TBrowserStatusCode s1, s2, s3, s4, s5;
|
|
1983 |
|
|
1984 |
/* Check whether the properties have already been applied */
|
|
1985 |
NW_LMgr_Box_GetPropertyFromList (box, NW_CSS_Prop_fontObject, &fontProp);
|
|
1986 |
if (fontProp.value.object != NULL)
|
|
1987 |
{
|
|
1988 |
return KBrsrSuccess;
|
|
1989 |
}
|
|
1990 |
|
|
1991 |
// Get the properties from the box property list
|
|
1992 |
s1 = NW_LMgr_Box_GetPropertyFromList (box, NW_CSS_Prop_fontFamily, &fontFamily);
|
|
1993 |
s2 = NW_LMgr_Box_GetPropertyFromList (box, NW_CSS_Prop_fontSize, &size);
|
|
1994 |
s3 = NW_LMgr_Box_GetPropertyFromList (box, NW_CSS_Prop_fontStyle, &style);
|
|
1995 |
s4 = NW_LMgr_Box_GetPropertyFromList (box, NW_CSS_Prop_fontWeight, &weight);
|
|
1996 |
s5 = NW_LMgr_Box_GetPropertyFromList (box, NW_CSS_Prop_fontVariant, &variant);
|
|
1997 |
|
|
1998 |
// If there are no properties to apply, we return. If the box is the root,
|
|
1999 |
// we must apply the properties at all times.
|
|
2000 |
if (s1 == KBrsrNotFound && s2 == KBrsrNotFound && s3 == KBrsrNotFound &&
|
|
2001 |
s4 == KBrsrNotFound && s5 == KBrsrNotFound && box->parent != NULL)
|
|
2002 |
{
|
|
2003 |
return KBrsrSuccess;
|
|
2004 |
}
|
|
2005 |
|
|
2006 |
// Set defaults
|
|
2007 |
fontFamily.value.object = const_cast<NW_Text_t*>(KGDIFontDefaultFamily);
|
|
2008 |
size.value.integer = KGDIFontZeroSize;
|
|
2009 |
style.value.token = NW_CSS_PropValue_normal;
|
|
2010 |
weight.value.integer = KGDIFontDefaultWeight;
|
|
2011 |
variant.value.token = NW_CSS_PropValue_normal;
|
|
2012 |
|
|
2013 |
// Now take into account inheritance
|
|
2014 |
NW_LMgr_Box_GetProperty (box, NW_CSS_Prop_fontFamily, &fontFamily);
|
|
2015 |
NW_LMgr_Box_GetProperty (box, NW_CSS_Prop_fontSize, &size);
|
|
2016 |
NW_LMgr_Box_GetProperty (box, NW_CSS_Prop_fontStyle, &style);
|
|
2017 |
NW_LMgr_Box_GetProperty (box, NW_CSS_Prop_fontWeight, &weight);
|
|
2018 |
NW_LMgr_Box_GetProperty (box, NW_CSS_Prop_fontVariant, &variant);
|
|
2019 |
|
|
2020 |
// For negative value, use default font size
|
|
2021 |
if ( size.value.integer < 0 )
|
|
2022 |
{
|
|
2023 |
size.value.decimal = KGDIFontDefaultSizeInPt;
|
|
2024 |
size.type = NW_CSS_ValueType_Pt;
|
|
2025 |
}
|
|
2026 |
|
|
2027 |
// Check the device resolution in order to resolve the correct font size for the device
|
|
2028 |
CEikonEnv* eikEnv = CEikonEnv::Static();
|
|
2029 |
CWsScreenDevice& screenDev = *eikEnv->ScreenDevice();
|
|
2030 |
|
|
2031 |
// we are using pixels to pass off to the device context, from there they get converted to twips
|
|
2032 |
TInt px = 0;
|
|
2033 |
|
|
2034 |
if (size.type == NW_CSS_ValueType_Pt)
|
|
2035 |
{
|
|
2036 |
TInt valInt = (TInt)NW_Math_round(size.value.decimal);
|
|
2037 |
|
|
2038 |
px = screenDev.VerticalTwipsToPixels(FontUtils::TwipsFromPoints(valInt));
|
|
2039 |
|
|
2040 |
size.type = NW_CSS_ValueType_Px;
|
|
2041 |
size.value.integer = px;
|
|
2042 |
}
|
|
2043 |
else if (size.type == NW_CSS_ValueType_Px)
|
|
2044 |
{
|
|
2045 |
TUint dpi = screenDev.VerticalTwipsToPixels(KTwipsPerInch);
|
|
2046 |
|
|
2047 |
// Since web designers assume a 96 pixel per inch (ppi) display use that as the reference point.
|
|
2048 |
// Thus the multiplier should be:
|
|
2049 |
// ppi/96
|
|
2050 |
// Below is a list of the density of commercially available LCD displays.
|
|
2051 |
// Density Multiplier:
|
|
2052 |
// 400 ppi 4.2
|
|
2053 |
// 210 ppi 2.2
|
|
2054 |
// 200 ppi 2.1
|
|
2055 |
// 120 ppi 1.3
|
|
2056 |
// 100 ppi 1.0
|
|
2057 |
// 96 ppi 1.0
|
|
2058 |
if ((200 > dpi) && (dpi > 120))
|
|
2059 |
{
|
|
2060 |
px = (TInt)((float)size.value.integer * 1.3);
|
|
2061 |
}
|
|
2062 |
else if ((210 > dpi) && (dpi > 200))
|
|
2063 |
{
|
|
2064 |
px = (TInt)((float)size.value.integer * 2.1);
|
|
2065 |
}
|
|
2066 |
else if ((400 > dpi) && (dpi > 210))
|
|
2067 |
{
|
|
2068 |
px = (TInt)((float)size.value.integer * 2.2);
|
|
2069 |
}
|
|
2070 |
else if (dpi > 400)
|
|
2071 |
{
|
|
2072 |
px = (TInt)((float)size.value.integer * 4.2);
|
|
2073 |
}
|
|
2074 |
|
|
2075 |
size.value.integer = px;
|
|
2076 |
}
|
|
2077 |
|
|
2078 |
switch (style.value.token)
|
|
2079 |
{
|
|
2080 |
case NW_CSS_PropValue_oblique:
|
|
2081 |
gdiFontStyle = EGDIFontStyleOblique;
|
|
2082 |
break;
|
|
2083 |
|
|
2084 |
case NW_CSS_PropValue_italic:
|
|
2085 |
gdiFontStyle = EGDIFontStyleItalic;
|
|
2086 |
break;
|
|
2087 |
|
|
2088 |
default:
|
|
2089 |
gdiFontStyle = KGDIFontDefaultStyle;
|
|
2090 |
}
|
|
2091 |
|
|
2092 |
switch (variant.value.token)
|
|
2093 |
{
|
|
2094 |
case NW_CSS_PropValue_smallcaps:
|
|
2095 |
gdiFontVariant = EGDIFontVariantSmallCaps;
|
|
2096 |
break;
|
|
2097 |
|
|
2098 |
default:
|
|
2099 |
gdiFontVariant = KGDIFontDefaultVariant;
|
|
2100 |
}
|
|
2101 |
|
|
2102 |
// we're going to need the DeviceContext to create Font
|
|
2103 |
rootBox = NW_LMgr_Box_GetRootBox (box);
|
|
2104 |
NW_ASSERT (rootBox != NULL);
|
|
2105 |
|
|
2106 |
deviceContext = NW_LMgr_RootBox_GetDeviceContext (rootBox);
|
|
2107 |
NW_ASSERT (deviceContext != NULL);
|
|
2108 |
|
|
2109 |
fontProp.type = NW_CSS_ValueType_Font;
|
|
2110 |
fontProp.value.object =
|
|
2111 |
deviceContext->CreateFont ((NW_Text_t*) fontFamily.value.object,
|
|
2112 |
(TGDIFontStyle) gdiFontStyle,
|
|
2113 |
(NW_Uint8) size.value.integer,
|
|
2114 |
(NW_Uint16) weight.value.integer,
|
|
2115 |
(TGDIFontVariant) gdiFontVariant);
|
|
2116 |
NW_THROW_OOM_ON_NULL (fontProp.value.object, status);
|
|
2117 |
|
|
2118 |
// Add the computed GDI font to the property list
|
|
2119 |
status = NW_LMgr_Box_SetProperty (NW_LMgr_BoxOf(box),
|
|
2120 |
NW_CSS_Prop_fontObject, &fontProp);
|
|
2121 |
|
|
2122 |
_NW_THROW_ON_ERROR (status);
|
|
2123 |
|
|
2124 |
}
|
|
2125 |
NW_CATCH (status)
|
|
2126 |
{
|
|
2127 |
delete (CGDIFont*)fontProp.value.object;
|
|
2128 |
}
|
|
2129 |
NW_FINALLY
|
|
2130 |
{
|
|
2131 |
return status;
|
|
2132 |
}
|
|
2133 |
NW_END_TRY
|
|
2134 |
}
|
|
2135 |
|
|
2136 |
/* ------------------------------------------------------------------------- *
|
|
2137 |
* Function: NW_LMgr_Box_GetFont
|
|
2138 |
* Description: Get the GDI font handle.
|
|
2139 |
* Returns: KBrsrSuccess, KBrsrOutOfMemory.
|
|
2140 |
*/
|
|
2141 |
|
|
2142 |
CGDIFont*
|
|
2143 |
NW_LMgr_Box_GetFont (NW_LMgr_Box_t* box)
|
|
2144 |
{
|
|
2145 |
TBrowserStatusCode status;
|
|
2146 |
NW_LMgr_PropertyValue_t font;
|
|
2147 |
|
|
2148 |
NW_ASSERT(box != NULL);
|
|
2149 |
|
|
2150 |
font.object = NULL;
|
|
2151 |
|
|
2152 |
/* If GDI font handle prop is set, return it */
|
|
2153 |
status = NW_LMgr_Box_GetPropertyValue (box, NW_CSS_Prop_fontObject, NW_CSS_ValueType_Font, &font);
|
|
2154 |
if (status == KBrsrSuccess) {
|
|
2155 |
return (CGDIFont*) font.object;
|
|
2156 |
}
|
|
2157 |
else {
|
|
2158 |
return NULL;
|
|
2159 |
}
|
|
2160 |
}
|
|
2161 |
|
|
2162 |
/* ------------------------------------------------------------------------- *
|
|
2163 |
* Function: NW_LMgr_Box_GetModelProp
|
|
2164 |
* Description: Returns a single box-model property for the box
|
|
2165 |
* (as opposed to GetModelProps which returns the values for
|
|
2166 |
* all sides of the box).
|
|
2167 |
* Returns: Property value.
|
|
2168 |
*/
|
|
2169 |
|
|
2170 |
/* TODO: move all this to GetValueProp */
|
|
2171 |
|
|
2172 |
NW_Int32
|
|
2173 |
NW_LMgr_Box_GetModelProp(NW_LMgr_Box_t *box, NW_LMgr_PropertyName_t propName)
|
|
2174 |
{
|
|
2175 |
NW_LMgr_Property_t prop;
|
|
2176 |
NW_LMgr_PropertyName_t shortcutProp;
|
|
2177 |
NW_LMgr_PropertyValueType_t defaultPropType;
|
|
2178 |
NW_Bool doInherit = NW_FALSE;
|
|
2179 |
TBrowserStatusCode status;
|
|
2180 |
|
|
2181 |
switch (propName) {
|
|
2182 |
case NW_CSS_Prop_topBorderWidth:
|
|
2183 |
case NW_CSS_Prop_bottomBorderWidth:
|
|
2184 |
case NW_CSS_Prop_leftBorderWidth:
|
|
2185 |
case NW_CSS_Prop_rightBorderWidth:
|
|
2186 |
|
|
2187 |
shortcutProp = NW_CSS_Prop_borderWidth;
|
|
2188 |
defaultPropType = NW_CSS_ValueType_Px;
|
|
2189 |
break;
|
|
2190 |
|
|
2191 |
case NW_CSS_Prop_topBorderStyle:
|
|
2192 |
case NW_CSS_Prop_bottomBorderStyle:
|
|
2193 |
case NW_CSS_Prop_leftBorderStyle:
|
|
2194 |
case NW_CSS_Prop_rightBorderStyle:
|
|
2195 |
|
|
2196 |
shortcutProp = NW_CSS_Prop_borderStyle;
|
|
2197 |
defaultPropType = NW_CSS_ValueType_Token;
|
|
2198 |
break;
|
|
2199 |
|
|
2200 |
case NW_CSS_Prop_topBorderColor:
|
|
2201 |
case NW_CSS_Prop_bottomBorderColor:
|
|
2202 |
case NW_CSS_Prop_leftBorderColor:
|
|
2203 |
case NW_CSS_Prop_rightBorderColor:
|
|
2204 |
|
|
2205 |
shortcutProp = NW_CSS_Prop_borderColor;
|
|
2206 |
defaultPropType = NW_CSS_ValueType_Color;
|
|
2207 |
break;
|
|
2208 |
|
|
2209 |
case NW_CSS_Prop_topPadding:
|
|
2210 |
case NW_CSS_Prop_bottomPadding:
|
|
2211 |
case NW_CSS_Prop_leftPadding:
|
|
2212 |
case NW_CSS_Prop_rightPadding:
|
|
2213 |
|
|
2214 |
shortcutProp = NW_CSS_Prop_padding;
|
|
2215 |
defaultPropType = NW_CSS_ValueType_Px;
|
|
2216 |
break;
|
|
2217 |
|
|
2218 |
case NW_CSS_Prop_topMargin:
|
|
2219 |
case NW_CSS_Prop_bottomMargin:
|
|
2220 |
case NW_CSS_Prop_leftMargin:
|
|
2221 |
case NW_CSS_Prop_rightMargin:
|
|
2222 |
|
|
2223 |
shortcutProp = NW_CSS_Prop_margin;
|
|
2224 |
defaultPropType = NW_CSS_ValueType_Px;
|
|
2225 |
break;
|
|
2226 |
|
|
2227 |
default:
|
|
2228 |
NW_ASSERT(0);
|
|
2229 |
return 0;
|
|
2230 |
}
|
|
2231 |
|
|
2232 |
status = NW_LMgr_Box_GetPropertyFromList(box, propName, &prop);
|
|
2233 |
if (status == KBrsrSuccess) {
|
|
2234 |
if ((prop.type == NW_CSS_ValueType_Token) && (prop.value.token == NW_CSS_PropValue_inherit)) {
|
|
2235 |
doInherit = NW_TRUE;
|
|
2236 |
}
|
|
2237 |
else if (prop.type == defaultPropType) {
|
|
2238 |
if ((shortcutProp == NW_CSS_Prop_padding) || (shortcutProp == NW_CSS_Prop_borderWidth)) {
|
|
2239 |
if (prop.value.integer < 0) {
|
|
2240 |
return 0;
|
|
2241 |
}
|
|
2242 |
}
|
|
2243 |
return prop.value.integer;
|
|
2244 |
}
|
|
2245 |
else if (shortcutProp == NW_CSS_Prop_margin) {
|
|
2246 |
/* Special handling of auto margins */
|
|
2247 |
if ((prop.type == NW_CSS_ValueType_Token) && (prop.value.token == NW_CSS_PropValue_auto)) {
|
|
2248 |
return NW_LMgr_FrameInfo_AutoMargin;
|
|
2249 |
}
|
|
2250 |
}
|
|
2251 |
}
|
|
2252 |
status = NW_LMgr_Box_GetPropertyFromList(box, shortcutProp, &prop);
|
|
2253 |
if (status == KBrsrSuccess) {
|
|
2254 |
if ((prop.type == NW_CSS_ValueType_Token) && (prop.value.token == NW_CSS_PropValue_inherit)) {
|
|
2255 |
doInherit = NW_TRUE;
|
|
2256 |
}
|
|
2257 |
else if (prop.type == defaultPropType) {
|
|
2258 |
if ((shortcutProp == NW_CSS_Prop_padding) || (shortcutProp == NW_CSS_Prop_borderWidth)) {
|
|
2259 |
if (prop.value.integer < 0) {
|
|
2260 |
return 0;
|
|
2261 |
}
|
|
2262 |
}
|
|
2263 |
return prop.value.integer;
|
|
2264 |
}
|
|
2265 |
else if (shortcutProp == NW_CSS_Prop_margin) {
|
|
2266 |
/* Special handling of auto margins */
|
|
2267 |
if ((prop.type == NW_CSS_ValueType_Token) && (prop.value.token == NW_CSS_PropValue_auto)) {
|
|
2268 |
return NW_LMgr_FrameInfo_AutoMargin;
|
|
2269 |
}
|
|
2270 |
}
|
|
2271 |
}
|
|
2272 |
|
|
2273 |
if (doInherit && box->parent)
|
|
2274 |
{
|
|
2275 |
if (NW_Object_IsInstanceOf(box->parent, &LMgrAnonBlock_Class))
|
|
2276 |
{
|
|
2277 |
// this parent is an anonymous box, we should go up to see if grandpa has
|
|
2278 |
// the prop we are interested.
|
|
2279 |
box = (NW_LMgr_Box_t*) NW_LMgr_Box_GetParent (box);
|
|
2280 |
if (box->parent == NULL) {
|
|
2281 |
return 0;
|
|
2282 |
}
|
|
2283 |
}
|
|
2284 |
return NW_LMgr_Box_GetModelProp((NW_LMgr_Box_t*)(box->parent), propName);
|
|
2285 |
}
|
|
2286 |
|
|
2287 |
/* Otherwise return defaults */
|
|
2288 |
if (shortcutProp == NW_CSS_Prop_borderColor) {
|
|
2289 |
NW_LMgr_PropertyValue_t color;
|
|
2290 |
color.integer = 0;
|
|
2291 |
status = NW_LMgr_Box_GetPropertyValue(box, NW_CSS_Prop_color, NW_CSS_ValueType_Color, &color);
|
|
2292 |
return color.integer;
|
|
2293 |
}
|
|
2294 |
else if (shortcutProp == NW_CSS_Prop_borderWidth)
|
|
2295 |
{
|
|
2296 |
if (NW_Object_IsDerivedFrom(box, &NW_LMgr_ImgContainerBox_Class))
|
|
2297 |
{
|
|
2298 |
return (NW_LMgr_ImgContainerBox_ImageIsBroken(box) == NW_TRUE) ?
|
|
2299 |
NW_CSS_PropValue_none : NW_LMgr_Box_MinBorderWidth;
|
|
2300 |
}
|
|
2301 |
else
|
|
2302 |
{
|
|
2303 |
return NW_LMgr_Box_MediumBorderWidth;
|
|
2304 |
}
|
|
2305 |
}
|
|
2306 |
else if (shortcutProp == NW_CSS_Prop_borderStyle) {
|
|
2307 |
if (NW_Object_IsDerivedFrom(box, &NW_LMgr_ImgContainerBox_Class) &&
|
|
2308 |
NW_LMgr_ImgContainerBox_ImageIsBroken( box ) == NW_TRUE )
|
|
2309 |
{
|
|
2310 |
return NW_CSS_PropValue_solid;
|
|
2311 |
}
|
|
2312 |
return NW_CSS_PropValue_none;
|
|
2313 |
}
|
|
2314 |
else {
|
|
2315 |
return 0;
|
|
2316 |
}
|
|
2317 |
}
|
|
2318 |
|
|
2319 |
|
|
2320 |
/* ------------------------------------------------------------------------- *
|
|
2321 |
* Function: NW_LMgr_Box_GetBorderWidth
|
|
2322 |
* Description: Calculates the width of the box border on all four sides
|
|
2323 |
* and stores it in borderWidth.
|
|
2324 |
* Returns: void.
|
|
2325 |
*/
|
|
2326 |
|
|
2327 |
void
|
|
2328 |
NW_LMgr_Box_GetBorderWidth(NW_LMgr_Box_t *box,
|
|
2329 |
NW_LMgr_FrameInfo_t *borderWidth,
|
|
2330 |
NW_Int8 aFrameSide )
|
|
2331 |
{
|
|
2332 |
NW_LMgr_FrameInfo_t borderStyle;
|
|
2333 |
|
|
2334 |
borderWidth->left = 0;
|
|
2335 |
borderWidth->right = 0;
|
|
2336 |
borderWidth->top = 0;
|
|
2337 |
borderWidth->bottom = 0;
|
|
2338 |
|
|
2339 |
/* set the width to zero if the box style is "none" */
|
|
2340 |
NW_LMgr_Box_GetBorderStyle( box, &borderStyle, aFrameSide );
|
|
2341 |
|
|
2342 |
if( ( aFrameSide & ELMgrFrameLeft ) &&
|
|
2343 |
borderStyle.left != NW_CSS_PropValue_none && borderStyle.left != NW_CSS_PropValue_hidden )
|
|
2344 |
{
|
|
2345 |
borderWidth->left = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_leftBorderWidth);
|
|
2346 |
}
|
|
2347 |
if( ( aFrameSide & ELMgrFrameBottom ) &&
|
|
2348 |
borderStyle.bottom != NW_CSS_PropValue_none && borderStyle.bottom != NW_CSS_PropValue_hidden )
|
|
2349 |
{
|
|
2350 |
borderWidth->bottom = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_bottomBorderWidth);
|
|
2351 |
}
|
|
2352 |
if( ( aFrameSide & ELMgrFrameTop ) &&
|
|
2353 |
borderStyle.top != NW_CSS_PropValue_none && borderStyle.top != NW_CSS_PropValue_hidden )
|
|
2354 |
{
|
|
2355 |
borderWidth->top = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_topBorderWidth);
|
|
2356 |
}
|
|
2357 |
if( ( aFrameSide & ELMgrFrameRight ) &&
|
|
2358 |
borderStyle.right != NW_CSS_PropValue_none && borderStyle.right != NW_CSS_PropValue_hidden )
|
|
2359 |
{
|
|
2360 |
borderWidth->right = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_rightBorderWidth);
|
|
2361 |
}
|
|
2362 |
}
|
|
2363 |
|
|
2364 |
/* ------------------------------------------------------------------------- *
|
|
2365 |
* Function: NW_LMgr_Box_GetBorderStyle
|
|
2366 |
* Description: Gets a set of box border-style properties
|
|
2367 |
* (left, right, top, bottom) and stores them in borderStyle.
|
|
2368 |
* Returns: void (in case no property are set, the default value of 0
|
|
2369 |
* is returned for the property value).
|
|
2370 |
*/
|
|
2371 |
|
|
2372 |
void
|
|
2373 |
NW_LMgr_Box_GetBorderStyle(NW_LMgr_Box_t *box,
|
|
2374 |
NW_LMgr_FrameInfo_t* borderStyle,
|
|
2375 |
NW_Int8 aFrameSide )
|
|
2376 |
{
|
|
2377 |
// init
|
|
2378 |
borderStyle->left = 0;
|
|
2379 |
borderStyle->right = 0;
|
|
2380 |
borderStyle->top = 0;
|
|
2381 |
borderStyle->bottom = 0;
|
|
2382 |
//
|
|
2383 |
if( aFrameSide & ELMgrFrameLeft )
|
|
2384 |
{
|
|
2385 |
borderStyle->left = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_leftBorderStyle);
|
|
2386 |
}
|
|
2387 |
if( aFrameSide & ELMgrFrameRight )
|
|
2388 |
{
|
|
2389 |
borderStyle->right = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_rightBorderStyle);
|
|
2390 |
}
|
|
2391 |
if( aFrameSide & ELMgrFrameTop )
|
|
2392 |
{
|
|
2393 |
borderStyle->top = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_topBorderStyle);
|
|
2394 |
}
|
|
2395 |
if( aFrameSide & ELMgrFrameBottom )
|
|
2396 |
{
|
|
2397 |
borderStyle->bottom = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_bottomBorderStyle);
|
|
2398 |
}
|
|
2399 |
}
|
|
2400 |
|
|
2401 |
/* ------------------------------------------------------------------------- *
|
|
2402 |
* Function: NW_LMgr_Box_GetBorderColor
|
|
2403 |
* Description: Gets a set of box border-color properties
|
|
2404 |
* (left, right, top, bottom) and stores them in borderColor.
|
|
2405 |
* Returns: void (in case no property are set, the default value of 0
|
|
2406 |
* is returned for the property value).
|
|
2407 |
*/
|
|
2408 |
|
|
2409 |
void
|
|
2410 |
NW_LMgr_Box_GetBorderColor(NW_LMgr_Box_t *box,
|
|
2411 |
NW_LMgr_FrameInfo_t *borderColor)
|
|
2412 |
{
|
|
2413 |
borderColor->left = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_leftBorderColor);
|
|
2414 |
borderColor->right = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_rightBorderColor);
|
|
2415 |
borderColor->top = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_topBorderColor);
|
|
2416 |
borderColor->bottom = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_bottomBorderColor);
|
|
2417 |
}
|
|
2418 |
|
|
2419 |
/* ------------------------------------------------------------------------- *
|
|
2420 |
* Function: NW_LMgr_Box_GetMargins
|
|
2421 |
* Description: Calculates the width of the box margin on all four sides
|
|
2422 |
* and stores it in "margins".
|
|
2423 |
* Returns: void.
|
|
2424 |
*/
|
|
2425 |
|
|
2426 |
void
|
|
2427 |
NW_LMgr_Box_GetMargins(NW_LMgr_Box_t *box,
|
|
2428 |
NW_LMgr_FrameInfo_t *margins,
|
|
2429 |
NW_LMgr_FrameInfo_t* isAuto,
|
|
2430 |
NW_Int8 aFrameSide )
|
|
2431 |
{
|
|
2432 |
NW_LMgr_RootBox_t* rootBox;
|
|
2433 |
|
|
2434 |
if (isAuto)
|
|
2435 |
{
|
|
2436 |
NW_Mem_memset(isAuto, 0, sizeof(NW_LMgr_FrameInfo_t));
|
|
2437 |
}
|
|
2438 |
|
|
2439 |
if( aFrameSide & ELMgrFrameLeft )
|
|
2440 |
{
|
|
2441 |
margins->left = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_leftMargin);
|
|
2442 |
}
|
|
2443 |
if( aFrameSide & ELMgrFrameRight )
|
|
2444 |
{
|
|
2445 |
margins->right = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_rightMargin);
|
|
2446 |
}
|
|
2447 |
if( aFrameSide & ELMgrFrameTop )
|
|
2448 |
{
|
|
2449 |
margins->top = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_topMargin);
|
|
2450 |
}
|
|
2451 |
if( aFrameSide & ELMgrFrameBottom )
|
|
2452 |
{
|
|
2453 |
margins->bottom = NW_LMgr_Box_GetModelProp(box, NW_CSS_Prop_bottomMargin);
|
|
2454 |
}
|
|
2455 |
|
|
2456 |
if( ( aFrameSide & ELMgrFrameLeft ) && margins->left == NW_LMgr_FrameInfo_Auto)
|
|
2457 |
{
|
|
2458 |
margins->left = 0;
|
|
2459 |
if (isAuto)
|
|
2460 |
{
|
|
2461 |
isAuto->left = 1;
|
|
2462 |
}
|
|
2463 |
}
|
|
2464 |
if( ( aFrameSide & ELMgrFrameRight ) && margins->right == NW_LMgr_FrameInfo_Auto)
|
|
2465 |
{
|
|
2466 |
margins->right = 0;
|
|
2467 |
if (isAuto)
|
|
2468 |
{
|
|
2469 |
isAuto->right = 1;
|
|
2470 |
}
|
|
2471 |
}
|
|
2472 |
if( ( aFrameSide & ELMgrFrameTop ) && margins->top == NW_LMgr_FrameInfo_Auto)
|
|
2473 |
{
|
|
2474 |
margins->top = 0;
|
|
2475 |
if (isAuto)
|
|
2476 |
{
|
|
2477 |
isAuto->top = 1;
|
|
2478 |
}
|
|
2479 |
}
|
|
2480 |
if( ( aFrameSide & ELMgrFrameBottom ) && margins->bottom == NW_LMgr_FrameInfo_Auto)
|
|
2481 |
{
|
|
2482 |
margins->bottom = 0;
|
|
2483 |
if (isAuto)
|
|
2484 |
{
|
|
2485 |
isAuto->bottom = 1;
|
|
2486 |
}
|
|
2487 |
}
|
|
2488 |
|
|
2489 |
rootBox = NW_LMgr_Box_GetRootBox(box);
|
|
2490 |
if( NW_LMgr_RootBox_GetSmallScreenOn( rootBox ) )
|
|
2491 |
{
|
|
2492 |
CGDIDeviceContext* deviceContext;
|
|
2493 |
const NW_GDI_Rectangle_t* rectangle;
|
|
2494 |
|
|
2495 |
/* We want to limit the margin to 15% of display width */
|
|
2496 |
if ((margins->left != NW_LMgr_FrameInfo_Auto) || (margins->right != NW_LMgr_FrameInfo_Auto))
|
|
2497 |
{
|
|
2498 |
NW_GDI_Metric_t maxMargin = 0;
|
|
2499 |
deviceContext = NW_LMgr_RootBox_GetDeviceContext (rootBox);
|
|
2500 |
rectangle = deviceContext->DisplayBounds();
|
|
2501 |
maxMargin = (NW_GDI_Metric_t)(rectangle->dimension.width*15/100);
|
|
2502 |
|
|
2503 |
if( ( aFrameSide & ELMgrFrameLeft ) && margins->left > maxMargin)
|
|
2504 |
{
|
|
2505 |
margins->left = maxMargin;
|
|
2506 |
}
|
|
2507 |
if( ( aFrameSide & ELMgrFrameRight ) && margins->right > maxMargin)
|
|
2508 |
{
|
|
2509 |
margins->right = maxMargin;
|
|
2510 |
}
|
|
2511 |
}
|
|
2512 |
}
|
|
2513 |
}
|
|
2514 |
|
|
2515 |
/* ------------------------------------------------------------------------- *
|
|
2516 |
* Function: NW_LMgr_Box_GetPadding
|
|
2517 |
* Description: Calculates the width of the box padding on all four sides
|
|
2518 |
* and stores it in "padding".
|
|
2519 |
* Returns: void
|
|
2520 |
*/
|
|
2521 |
|
|
2522 |
void
|
|
2523 |
NW_LMgr_Box_GetPadding(NW_LMgr_Box_t *box,
|
|
2524 |
NW_LMgr_FrameInfo_t* padding,
|
|
2525 |
NW_Int8 aFrameSide )
|
|
2526 |
{
|
|
2527 |
// init
|
|
2528 |
padding->left = 0;
|
|
2529 |
padding->right = 0;
|
|
2530 |
padding->top = 0;
|
|
2531 |
padding->bottom = 0;
|
|
2532 |
//
|
|
2533 |
if( aFrameSide & ELMgrFrameLeft )
|
|
2534 |
{
|
|
2535 |
padding->left = NW_LMgr_Box_GetModelProp( box, NW_CSS_Prop_leftPadding );
|
|
2536 |
}
|
|
2537 |
if( aFrameSide & ELMgrFrameRight )
|
|
2538 |
{
|
|
2539 |
padding->right = NW_LMgr_Box_GetModelProp( box, NW_CSS_Prop_rightPadding );
|
|
2540 |
}
|
|
2541 |
if( aFrameSide & ELMgrFrameTop )
|
|
2542 |
{
|
|
2543 |
padding->top = NW_LMgr_Box_GetModelProp( box, NW_CSS_Prop_topPadding );
|
|
2544 |
}
|
|
2545 |
if( aFrameSide & ELMgrFrameBottom )
|
|
2546 |
{
|
|
2547 |
padding->bottom = NW_LMgr_Box_GetModelProp( box, NW_CSS_Prop_bottomPadding );
|
|
2548 |
}
|
|
2549 |
}
|
|
2550 |
|
|
2551 |
|
|
2552 |
/* ------------------------------------------------------------------------- *
|
|
2553 |
* Function: NW_LMgr_Box_DrawSolidBorder
|
|
2554 |
* Description: Draws a solid border around the content of the box,
|
|
2555 |
using the current boundaries of the box.
|
|
2556 |
* Returns: KBrsrSuccess, KBrsrFailure (?), KBrsrOutOfMemory.
|
|
2557 |
*/
|
|
2558 |
|
|
2559 |
/* ------------------------------------------------------------------------- *
|
|
2560 |
* Function: NW_LMgr_Box_DrawSolidBorder
|
|
2561 |
* Description: Draws a solid border around the content of the box,
|
|
2562 |
using the current boundaries of the box.
|
|
2563 |
* Returns: KBrsrSuccess, KBrsrFailure (?), KBrsrOutOfMemory.
|
|
2564 |
*/
|
|
2565 |
|
|
2566 |
TBrowserStatusCode
|
|
2567 |
NW_LMgr_Box_DrawBorder (NW_GDI_Rectangle_t bounds,
|
|
2568 |
CGDIDeviceContext* deviceContext,
|
|
2569 |
NW_LMgr_FrameInfo_t* borderWidth,
|
|
2570 |
NW_LMgr_FrameInfo_t* borderStyle,
|
|
2571 |
NW_LMgr_FrameInfo_t* borderColor)
|
|
2572 |
{
|
|
2573 |
NW_GDI_Color_t oldFg;
|
|
2574 |
NW_GDI_Pattern_t oldPat;
|
|
2575 |
|
|
2576 |
oldFg = deviceContext->ForegroundColor();
|
|
2577 |
oldPat = deviceContext->LinePattern();
|
|
2578 |
|
|
2579 |
NW_TRY (status) {
|
|
2580 |
NW_GDI_Metric_t innerWidth, innerHeight;
|
|
2581 |
NW_Uint8 i;
|
|
2582 |
NW_GDI_Point2D_t vertices[2];
|
|
2583 |
NW_Float32 ratioTopLeft=0, ratioBottomLeft=0, ratioTopRight=0, ratioBottomRight=0;
|
|
2584 |
NW_Float32 ratioLeftTop=0, ratioLeftBottom=0, ratioRightTop=0, ratioRightBottom=0;
|
|
2585 |
|
|
2586 |
innerWidth = (NW_GDI_Metric_t)(bounds.dimension.width - borderWidth->left - borderWidth->right);
|
|
2587 |
innerHeight = (NW_GDI_Metric_t)(bounds.dimension.height - borderWidth->top - borderWidth->bottom);
|
|
2588 |
|
|
2589 |
if (borderWidth->right == 0) {
|
|
2590 |
ratioTopRight = 0;
|
|
2591 |
} else {
|
|
2592 |
ratioTopRight = ((NW_Float32)borderWidth->top)/((NW_Float32)borderWidth->right);
|
|
2593 |
}
|
|
2594 |
if (ratioTopRight > 0) {
|
|
2595 |
ratioRightTop = 1/ratioTopRight;
|
|
2596 |
}
|
|
2597 |
|
|
2598 |
if (borderWidth->right == 0) {
|
|
2599 |
ratioBottomRight = 0;
|
|
2600 |
} else {
|
|
2601 |
ratioBottomRight = ((NW_Float32)borderWidth->bottom)/((NW_Float32)borderWidth->right);
|
|
2602 |
}
|
|
2603 |
if (ratioBottomRight > 0) {
|
|
2604 |
ratioRightBottom = 1/ratioBottomRight;
|
|
2605 |
}
|
|
2606 |
|
|
2607 |
if (borderWidth->left == 0) {
|
|
2608 |
ratioTopLeft = 0;
|
|
2609 |
} else {
|
|
2610 |
ratioTopLeft = ((NW_Float32)borderWidth->top)/((NW_Float32)borderWidth->left);
|
|
2611 |
}
|
|
2612 |
if (ratioTopLeft > 0) {
|
|
2613 |
ratioLeftTop = 1/ratioTopLeft;
|
|
2614 |
}
|
|
2615 |
|
|
2616 |
if (borderWidth->left == 0) {
|
|
2617 |
ratioBottomLeft = 0;
|
|
2618 |
} else {
|
|
2619 |
ratioBottomLeft = ((NW_Float32)borderWidth->bottom)/((NW_Float32)borderWidth->left);
|
|
2620 |
}
|
|
2621 |
if (ratioBottomLeft > 0) {
|
|
2622 |
ratioLeftBottom = 1/ratioBottomLeft;
|
|
2623 |
}
|
|
2624 |
|
|
2625 |
/* draw top border */
|
|
2626 |
if (borderWidth->top > 0)
|
|
2627 |
{
|
|
2628 |
if ( borderColor->top == NW_GDI_Color_Transparent) {
|
|
2629 |
borderStyle->top = NW_CSS_PropValue_none;
|
|
2630 |
} else {
|
|
2631 |
deviceContext->SetForegroundColor( borderColor->top);
|
|
2632 |
}
|
|
2633 |
deviceContext->SetLinePattern( NW_LMgr_Box_ConvertBorderStyle(borderStyle->top));
|
|
2634 |
|
|
2635 |
for (i=0; i<borderWidth->top; i++) {
|
|
2636 |
if (borderStyle->top == NW_CSS_PropValue_solid ||
|
|
2637 |
borderStyle->top == NW_CSS_PropValue_dashed ||
|
|
2638 |
borderStyle->top == NW_CSS_PropValue_dotted) {
|
|
2639 |
vertices[0].x = (NW_GDI_Metric_t)(bounds.point.x + i*ratioLeftTop);
|
|
2640 |
vertices[0].y = vertices[1].y = (NW_GDI_Metric_t)(bounds.point.y + i);
|
|
2641 |
vertices[1].x = (NW_GDI_Metric_t)(bounds.point.x + bounds.dimension.width - i*ratioRightTop - 1);
|
|
2642 |
} else if (borderStyle->top == NW_CSS_PropValue_bevelled) {
|
|
2643 |
if (i >= innerWidth/2) {
|
|
2644 |
continue;
|
|
2645 |
}
|
|
2646 |
vertices[0].x = (NW_GDI_Metric_t)(bounds.point.x + borderWidth->left + i);
|
|
2647 |
vertices[0].y = vertices[1].y = (NW_GDI_Metric_t)(bounds.point.y + borderWidth->top - i - 1);
|
|
2648 |
vertices[1].x = (NW_GDI_Metric_t)(bounds.point.x + bounds.dimension.width - borderWidth->right - i - 1);
|
|
2649 |
} else {
|
|
2650 |
// skip any unknown border styles
|
|
2651 |
continue;
|
|
2652 |
}
|
|
2653 |
status = deviceContext->DrawPolyline( 2, vertices, NW_FALSE);
|
|
2654 |
_NW_THROW_ON_ERROR(status);
|
|
2655 |
}
|
|
2656 |
}
|
|
2657 |
|
|
2658 |
/* draw left border */
|
|
2659 |
if (borderWidth->left > 0)
|
|
2660 |
{
|
|
2661 |
if ( borderColor->left == NW_GDI_Color_Transparent) {
|
|
2662 |
borderStyle->left = NW_CSS_PropValue_none;
|
|
2663 |
} else {
|
|
2664 |
deviceContext->SetForegroundColor( borderColor->left);
|
|
2665 |
}
|
|
2666 |
deviceContext->SetLinePattern( NW_LMgr_Box_ConvertBorderStyle(borderStyle->left));
|
|
2667 |
|
|
2668 |
for (i=0; i<borderWidth->left; i++) {
|
|
2669 |
if (borderStyle->left == NW_CSS_PropValue_solid ||
|
|
2670 |
borderStyle->left == NW_CSS_PropValue_dashed ||
|
|
2671 |
borderStyle->left == NW_CSS_PropValue_dotted) {
|
|
2672 |
vertices[0].x = vertices[1].x = (NW_GDI_Metric_t)(bounds.point.x + i);
|
|
2673 |
vertices[0].y = (NW_GDI_Metric_t)(bounds.point.y + i*ratioTopLeft);
|
|
2674 |
vertices[1].y = (NW_GDI_Metric_t)(bounds.point.y + bounds.dimension.height - i*ratioBottomLeft - 1);
|
|
2675 |
} else if (borderStyle->left == NW_CSS_PropValue_bevelled) {
|
|
2676 |
if (i >= innerHeight/2) {
|
|
2677 |
continue;
|
|
2678 |
}
|
|
2679 |
vertices[0].x = vertices[1].x = (NW_GDI_Metric_t)(bounds.point.x + borderWidth->left - i - 1);
|
|
2680 |
vertices[0].y = (NW_GDI_Metric_t)(bounds.point.y + borderWidth->top + i);
|
|
2681 |
vertices[1].y = (NW_GDI_Metric_t)(bounds.point.y + bounds.dimension.height - borderWidth->bottom - i - 1);
|
|
2682 |
} else {
|
|
2683 |
// skip any unknown border styles
|
|
2684 |
continue;
|
|
2685 |
}
|
|
2686 |
status = deviceContext->DrawPolyline( 2, vertices, NW_FALSE);
|
|
2687 |
_NW_THROW_ON_ERROR(status);
|
|
2688 |
}
|
|
2689 |
}
|
|
2690 |
|
|
2691 |
/* draw bottom border */
|
|
2692 |
if (borderWidth->bottom > 0)
|
|
2693 |
{
|
|
2694 |
if ( borderColor->bottom == NW_GDI_Color_Transparent) {
|
|
2695 |
borderStyle->bottom = NW_CSS_PropValue_none;
|
|
2696 |
} else {
|
|
2697 |
deviceContext->SetForegroundColor( borderColor->bottom);
|
|
2698 |
}
|
|
2699 |
deviceContext->SetLinePattern( NW_LMgr_Box_ConvertBorderStyle(borderStyle->bottom));
|
|
2700 |
|
|
2701 |
for (i=0; i<borderWidth->bottom; i++) {
|
|
2702 |
if (borderStyle->bottom == NW_CSS_PropValue_solid ||
|
|
2703 |
borderStyle->bottom == NW_CSS_PropValue_dashed ||
|
|
2704 |
borderStyle->bottom == NW_CSS_PropValue_dotted) {
|
|
2705 |
vertices[0].x = (NW_GDI_Metric_t)(bounds.point.x + i*ratioLeftBottom);
|
|
2706 |
vertices[0].y = vertices[1].y = (NW_GDI_Metric_t)(bounds.point.y + bounds.dimension.height - i - 1);
|
|
2707 |
vertices[1].x = (NW_GDI_Metric_t)(bounds.point.x + bounds.dimension.width - i*ratioRightBottom - 1);
|
|
2708 |
} else if (borderStyle->bottom == NW_CSS_PropValue_bevelled) {
|
|
2709 |
if (i >= innerWidth/2) {
|
|
2710 |
continue;
|
|
2711 |
}
|
|
2712 |
vertices[0].x = (NW_GDI_Metric_t)(bounds.point.x + borderWidth->left + i);
|
|
2713 |
vertices[0].y = vertices[1].y = (NW_GDI_Metric_t)(bounds.point.y + bounds.dimension.height - borderWidth->bottom + i);
|
|
2714 |
vertices[1].x = (NW_GDI_Metric_t)(bounds.point.x + bounds.dimension.width - borderWidth->right - i - 1);
|
|
2715 |
} else {
|
|
2716 |
// skip any unknown border styles
|
|
2717 |
continue;
|
|
2718 |
}
|
|
2719 |
status = deviceContext->DrawPolyline( 2, vertices, NW_FALSE);
|
|
2720 |
_NW_THROW_ON_ERROR(status);
|
|
2721 |
}
|
|
2722 |
}
|
|
2723 |
|
|
2724 |
/* draw right border */
|
|
2725 |
if (borderWidth->right > 0)
|
|
2726 |
{
|
|
2727 |
if ( borderColor->right == NW_GDI_Color_Transparent) {
|
|
2728 |
borderStyle->right = NW_CSS_PropValue_none;
|
|
2729 |
} else {
|
|
2730 |
deviceContext->SetForegroundColor( borderColor->right);
|
|
2731 |
}
|
|
2732 |
deviceContext->SetLinePattern( NW_LMgr_Box_ConvertBorderStyle(borderStyle->right));
|
|
2733 |
|
|
2734 |
for (i=0; i<borderWidth->right; i++) {
|
|
2735 |
if (borderStyle->right == NW_CSS_PropValue_solid ||
|
|
2736 |
borderStyle->right == NW_CSS_PropValue_dashed ||
|
|
2737 |
borderStyle->right == NW_CSS_PropValue_dotted) {
|
|
2738 |
vertices[0].x = vertices[1].x = (NW_GDI_Metric_t)(bounds.point.x + bounds.dimension.width - 1 - i);
|
|
2739 |
vertices[0].y = (NW_GDI_Metric_t)(bounds.point.y + i*ratioTopRight);
|
|
2740 |
vertices[1].y = (NW_GDI_Metric_t)(bounds.point.y + bounds.dimension.height - i*ratioBottomRight - 1);
|
|
2741 |
} else if (borderStyle->right == NW_CSS_PropValue_bevelled) {
|
|
2742 |
if (i >= innerHeight/2) {
|
|
2743 |
continue;
|
|
2744 |
}
|
|
2745 |
vertices[0].x = vertices[1].x = (NW_GDI_Metric_t)(bounds.point.x + bounds.dimension.width - borderWidth->right + i);
|
|
2746 |
vertices[0].y = (NW_GDI_Metric_t)(bounds.point.y + borderWidth->top + i);
|
|
2747 |
vertices[1].y = (NW_GDI_Metric_t)(bounds.point.y + bounds.dimension.height - borderWidth->bottom - i - 1);
|
|
2748 |
} else {
|
|
2749 |
// skip any unknown border styles
|
|
2750 |
continue;
|
|
2751 |
}
|
|
2752 |
status = deviceContext->DrawPolyline( 2, vertices, NW_FALSE);
|
|
2753 |
_NW_THROW_ON_ERROR(status);
|
|
2754 |
}
|
|
2755 |
}
|
|
2756 |
|
|
2757 |
} NW_CATCH (status) {
|
|
2758 |
} NW_FINALLY {
|
|
2759 |
deviceContext->SetForegroundColor( oldFg);
|
|
2760 |
deviceContext->SetLinePattern(oldPat);
|
|
2761 |
return status;
|
|
2762 |
} NW_END_TRY
|
|
2763 |
}
|
|
2764 |
|
|
2765 |
/* ------------------------------------------------------------------------- *
|
|
2766 |
* Function: NW_LMgr_Box_GetSizeProperties
|
|
2767 |
* Description: This method gets any size properties set on box. If the
|
|
2768 |
* property is not set, (-1) is returned. This is OK because
|
|
2769 |
* negative values are illegal for CSS_width and CSS_height.
|
|
2770 |
* Returns: KBrsrSuccess
|
|
2771 |
*/
|
|
2772 |
|
|
2773 |
TBrowserStatusCode
|
|
2774 |
NW_LMgr_Box_GetSizeProperties(NW_LMgr_Box_t *box,
|
|
2775 |
NW_GDI_Dimension2D_t *size){
|
|
2776 |
|
|
2777 |
NW_LMgr_PropertyValue_t sizeVal;
|
|
2778 |
|
|
2779 |
NW_ASSERT(box != NULL);
|
|
2780 |
NW_ASSERT(size != NULL);
|
|
2781 |
|
|
2782 |
size->width = -1;
|
|
2783 |
size->height = -1;
|
|
2784 |
|
|
2785 |
if(NW_LMgr_Box_GetPropertyValue(box, NW_CSS_Prop_width, NW_CSS_ValueType_Px, &sizeVal) == KBrsrSuccess){
|
|
2786 |
size->width = (NW_GDI_Metric_t)sizeVal.integer;
|
|
2787 |
}
|
|
2788 |
|
|
2789 |
if(NW_LMgr_Box_GetPropertyValue(box, NW_CSS_Prop_height, NW_CSS_ValueType_Px, &sizeVal) == KBrsrSuccess){
|
|
2790 |
size->height = (NW_GDI_Metric_t)sizeVal.integer;
|
|
2791 |
}
|
|
2792 |
return KBrsrSuccess;
|
|
2793 |
}
|
|
2794 |
|
|
2795 |
/* ------------------------------------------------------------------------- *
|
|
2796 |
* Function: NW_LMgr_Box_GetMinimumSize
|
|
2797 |
* Description: This method first adds margins, borders, and padding to minimum
|
|
2798 |
* content size. While this method is final, it invokes a virtual
|
|
2799 |
* method to get the minimum content size.
|
|
2800 |
* Returns: KBrsrSuccess, KBrsrOutOfMemory
|
|
2801 |
*/
|
|
2802 |
|
|
2803 |
TBrowserStatusCode
|
|
2804 |
NW_LMgr_Box_GetMinimumSize (NW_LMgr_Box_t* box,
|
|
2805 |
NW_GDI_Dimension2D_t* size)
|
|
2806 |
{
|
|
2807 |
NW_TRY (status) {
|
|
2808 |
NW_LMgr_FrameInfo_t padding, borderWidth;
|
|
2809 |
|
|
2810 |
NW_ASSERT(box != NULL);
|
|
2811 |
NW_ASSERT(size != NULL);
|
|
2812 |
|
|
2813 |
NW_LMgr_RootBox_t* rootBox = NW_LMgr_Box_GetRootBox( box );
|
|
2814 |
|
|
2815 |
// for bgsound support: in normal screen mode if it's object box, still check visibility
|
|
2816 |
if( NW_LMgr_RootBox_GetSmallScreenOn( rootBox ) ||
|
|
2817 |
NW_Object_IsInstanceOf (box, &NW_LMgr_ObjectBox_Class) )
|
|
2818 |
{
|
|
2819 |
NW_LMgr_PropertyValue_t visibilityVal;
|
|
2820 |
visibilityVal.token = NW_CSS_PropValue_visible;
|
|
2821 |
status = NW_LMgr_Box_GetPropertyValue (box, NW_CSS_Prop_visibility,
|
|
2822 |
NW_CSS_ValueType_Token, &visibilityVal);
|
|
2823 |
if (status == KBrsrSuccess && visibilityVal.token == NW_CSS_PropValue_hidden)
|
|
2824 |
{
|
|
2825 |
size->width = 0 ;
|
|
2826 |
size->height = 0;
|
|
2827 |
NW_THROW_SUCCESS(status);
|
|
2828 |
}
|
|
2829 |
}
|
|
2830 |
|
|
2831 |
/* In case of vertical layout is enabled set the height and width to zero
|
|
2832 |
if the visibility attrib is hidden*/
|
|
2833 |
/* Start with minimum content box */
|
|
2834 |
status = NW_LMgr_Box_GetMinimumContentSize (box, size);
|
|
2835 |
_NW_THROW_ON_ERROR (status);
|
|
2836 |
|
|
2837 |
if ((size->width == 0) && (size->height == 0))
|
|
2838 |
NW_THROW_SUCCESS(status);
|
|
2839 |
|
|
2840 |
/* Now add any border, padding */
|
|
2841 |
NW_LMgr_Box_GetPadding(box, &padding, ELMgrFrameAll );
|
|
2842 |
NW_LMgr_Box_GetBorderWidth(box, &borderWidth, ELMgrFrameAll );
|
|
2843 |
|
|
2844 |
size->width =
|
|
2845 |
(NW_GDI_Metric_t) (size->width + padding.left + padding.right +
|
|
2846 |
borderWidth.left + borderWidth.right);
|
|
2847 |
size->height =
|
|
2848 |
(NW_GDI_Metric_t) (size->height + padding.top + padding.bottom +
|
|
2849 |
borderWidth.top + borderWidth.bottom);
|
|
2850 |
|
|
2851 |
} NW_CATCH (status) {
|
|
2852 |
} NW_FINALLY {
|
|
2853 |
return status;
|
|
2854 |
} NW_END_TRY
|
|
2855 |
}
|
|
2856 |
|
|
2857 |
/* ------------------------------------------------------------------------- *
|
|
2858 |
* Function: NW_LMgr_Box_HasFixedWidth
|
|
2859 |
* Description: Determines whether the box has fixed width.
|
|
2860 |
* Returns: NW_TRUE, NW_FALSE
|
|
2861 |
*/
|
|
2862 |
|
|
2863 |
NW_Bool
|
|
2864 |
NW_LMgr_Box_HasFixedWidth(NW_LMgr_Box_t* box){
|
|
2865 |
|
|
2866 |
NW_LMgr_Property_t prop;
|
|
2867 |
TBrowserStatusCode status;
|
|
2868 |
|
|
2869 |
NW_ASSERT(box != NULL);
|
|
2870 |
|
|
2871 |
if(NW_LMgr_Box_HasFixedContentSize(box) == NW_TRUE){
|
|
2872 |
return NW_TRUE;
|
|
2873 |
}
|
|
2874 |
|
|
2875 |
prop.type = NW_CSS_ValueType_Token;
|
|
2876 |
prop.value.integer = NW_CSS_PropValue_auto;
|
|
2877 |
status = NW_LMgr_Box_GetProperty(box, NW_CSS_Prop_width, &prop);
|
|
2878 |
if (status == KBrsrSuccess && prop.type == NW_CSS_ValueType_Px) {
|
|
2879 |
return NW_TRUE;
|
|
2880 |
}
|
|
2881 |
|
|
2882 |
return NW_FALSE;
|
|
2883 |
|
|
2884 |
}
|
|
2885 |
|
|
2886 |
/* ------------------------------------------------------------------------- *
|
|
2887 |
* Function: NW_LMgr_Box_HasFixedHeight
|
|
2888 |
* Description: Determines whether the box has fixed height.
|
|
2889 |
* Returns: NW_TRUE, NW_FALSE
|
|
2890 |
*/
|
|
2891 |
|
|
2892 |
NW_Bool
|
|
2893 |
NW_LMgr_Box_HasFixedHeight(NW_LMgr_Box_t* box){
|
|
2894 |
|
|
2895 |
NW_LMgr_Property_t prop;
|
|
2896 |
TBrowserStatusCode status;
|
|
2897 |
|
|
2898 |
NW_ASSERT(box != NULL);
|
|
2899 |
|
|
2900 |
if(NW_LMgr_Box_HasFixedContentSize(box) == NW_TRUE){
|
|
2901 |
return NW_TRUE;
|
|
2902 |
}
|
|
2903 |
|
|
2904 |
prop.type = NW_CSS_ValueType_Token;
|
|
2905 |
prop.value.integer = NW_CSS_PropValue_auto;
|
|
2906 |
status = NW_LMgr_Box_GetProperty(box, NW_CSS_Prop_width, &prop);
|
|
2907 |
if (status == KBrsrSuccess && prop.type == NW_CSS_ValueType_Px) {
|
|
2908 |
return NW_TRUE;
|
|
2909 |
}
|
|
2910 |
|
|
2911 |
return NW_FALSE;
|
|
2912 |
}
|
|
2913 |
|
|
2914 |
/* ------------------------------------------------------------------------- *
|
|
2915 |
* Function: NW_LMgr_Box_GetEm
|
|
2916 |
* Description: Calculates the em size for the box.
|
|
2917 |
* Returns: The em size in pixels.
|
|
2918 |
*/
|
|
2919 |
|
|
2920 |
/* TODO: change this interface so that out-of-memory status is propagated up
|
|
2921 |
*/
|
|
2922 |
|
|
2923 |
NW_GDI_Metric_t
|
|
2924 |
NW_LMgr_Box_GetEm (NW_LMgr_Box_t* box)
|
|
2925 |
{
|
|
2926 |
NW_GDI_Metric_t em = 0;
|
|
2927 |
|
|
2928 |
NW_TRY (status)
|
|
2929 |
{
|
|
2930 |
CGDIFont *font;
|
|
2931 |
TGDIFontInfo fontInfo;
|
|
2932 |
|
|
2933 |
/* Set the GDI to the box font */
|
|
2934 |
font = NW_LMgr_Box_GetFont(box);
|
|
2935 |
NW_THROW_ON_NULL(font, status, KBrsrUnexpectedError);
|
|
2936 |
|
|
2937 |
/* Get the em value */
|
|
2938 |
status = font->GetFontInfo( &fontInfo);
|
|
2939 |
_NW_THROW_ON_ERROR(status);
|
|
2940 |
em = fontInfo.height;
|
|
2941 |
}
|
|
2942 |
NW_CATCH (status)
|
|
2943 |
{
|
|
2944 |
em = 0;
|
|
2945 |
}
|
|
2946 |
NW_FINALLY
|
|
2947 |
{
|
|
2948 |
return em;
|
|
2949 |
}
|
|
2950 |
NW_END_TRY
|
|
2951 |
}
|
|
2952 |
|
|
2953 |
/* ------------------------------------------------------------------------- *
|
|
2954 |
* Function: NW_LMgr_Box_GetEx
|
|
2955 |
* Description: Calculates the ex size for the box.
|
|
2956 |
* Returns: The ex size in pixels.
|
|
2957 |
*/
|
|
2958 |
|
|
2959 |
/* TODO: Currently ex is set to be 1/2 of em, becuase we have no way
|
|
2960 |
* of accessing the actual dimensions of the 'x' character. This
|
|
2961 |
* should be fixed.
|
|
2962 |
* TODO: change this interface so that out-of-memory status is propagated up
|
|
2963 |
*/
|
|
2964 |
|
|
2965 |
NW_GDI_Metric_t
|
|
2966 |
NW_LMgr_Box_GetEx (NW_LMgr_Box_t* box)
|
|
2967 |
{
|
|
2968 |
return (NW_GDI_Metric_t)(NW_LMgr_Box_GetEm(box)/2);
|
|
2969 |
}
|
|
2970 |
|
|
2971 |
/* ------------------------------------------------------------------------- *
|
|
2972 |
* Function: NW_LMgr_Box_FindBoxOfClass
|
|
2973 |
* Description: Tries to find a box of a given class or, if the class is an
|
|
2974 |
* interface specification, implementing that interface. If
|
|
2975 |
* the derived flag is set, then the parent boxes are queried
|
|
2976 |
* for an instance of the given class.
|
|
2977 |
* Returns: The box, if found. Otherwise, NULL.
|
|
2978 |
*/
|
|
2979 |
|
|
2980 |
NW_LMgr_Box_t*
|
|
2981 |
NW_LMgr_Box_FindBoxOfClass (NW_LMgr_Box_t* box,
|
|
2982 |
const NW_Object_Class_t* theClass,
|
|
2983 |
NW_Bool derived)
|
|
2984 |
{
|
|
2985 |
/* parameter assertion block */
|
|
2986 |
NW_ASSERT (NW_Object_IsInstanceOf (box, &NW_LMgr_Box_Class));
|
|
2987 |
|
|
2988 |
/* traverse up the box tree looking for the first box of either derived from
|
|
2989 |
the specified class or, if the specified class is an interface
|
|
2990 |
specification, implementing that interface */
|
|
2991 |
while (box != NULL) {
|
|
2992 |
NW_Object_t* object;
|
|
2993 |
|
|
2994 |
object = NW_Object_QueryInterface (box, theClass);
|
|
2995 |
if (object != NULL && (derived || NW_Object_IsClass (object, theClass))) {
|
|
2996 |
return box;
|
|
2997 |
}
|
|
2998 |
|
|
2999 |
/* try the parent */
|
|
3000 |
box = (NW_LMgr_Box_t*) NW_LMgr_Box_GetParent (box);
|
|
3001 |
}
|
|
3002 |
|
|
3003 |
/* return the result */
|
|
3004 |
return box;
|
|
3005 |
}
|
|
3006 |
|
|
3007 |
/* ------------------------------------------------------------------------- */
|
|
3008 |
NW_LMgr_RootBox_t*
|
|
3009 |
_NW_LMgr_Box_GetRootBox (NW_LMgr_Box_t* box)
|
|
3010 |
{
|
|
3011 |
// ZAL: temp: change rootBox back to NW_LMgr_RootBox_t*
|
|
3012 |
// parameter assertion block
|
|
3013 |
NW_ASSERT (NW_Object_IsInstanceOf (box, &NW_LMgr_Box_Class));
|
|
3014 |
|
|
3015 |
// if the rootBox is not set, then get it from the parent and then set it.
|
|
3016 |
if( !box->rootBox )
|
|
3017 |
{
|
|
3018 |
if( box->parent )
|
|
3019 |
{
|
|
3020 |
box->rootBox = (void*)NW_LMgr_Box_GetRootBox( box->parent );
|
|
3021 |
}
|
|
3022 |
// no parent means that we are at the rootbox level
|
|
3023 |
// However if it is not the rootbox, then the box is corrupt as
|
|
3024 |
// we cannot get to the rootbox level.
|
|
3025 |
else if( NW_Object_IsClass( box, &NW_LMgr_RootBox_Class ) )
|
|
3026 |
{
|
|
3027 |
// rootbox points back to itself
|
|
3028 |
box->rootBox = (void*)NW_LMgr_RootBoxOf( box );
|
|
3029 |
}
|
|
3030 |
else
|
|
3031 |
{
|
|
3032 |
// NW_ASSERT( NW_FALSE )???
|
|
3033 |
}
|
|
3034 |
}
|
|
3035 |
return (NW_LMgr_RootBox_t*)box->rootBox;
|
|
3036 |
}
|
|
3037 |
|
|
3038 |
/* ------------------------------------------------------------------------- *
|
|
3039 |
* Function: NW_LMgr_Box_Detach
|
|
3040 |
* Description: Detaches the box from its parent.
|
|
3041 |
* Returns: KBrsrSuccess.
|
|
3042 |
*/
|
|
3043 |
|
|
3044 |
TBrowserStatusCode
|
|
3045 |
NW_LMgr_Box_Detach (NW_LMgr_Box_t* box)
|
|
3046 |
{
|
|
3047 |
NW_LMgr_ContainerBox_t* parentBox;
|
|
3048 |
|
|
3049 |
/* parameter assertion block */
|
|
3050 |
NW_ASSERT(box != NULL);
|
|
3051 |
NW_ASSERT (NW_Object_IsInstanceOf (box, &NW_LMgr_Box_Class));
|
|
3052 |
|
|
3053 |
/* get the parent box of the box - if it doesn't have one we simply return
|
|
3054 |
success */
|
|
3055 |
parentBox = NW_LMgr_Box_GetParent (box);
|
|
3056 |
if (parentBox == NULL) {
|
|
3057 |
return KBrsrSuccess;
|
|
3058 |
}
|
|
3059 |
|
|
3060 |
/* invoke the ContainerBox's method to remove the child */
|
|
3061 |
return NW_LMgr_ContainerBox_RemoveChild (parentBox, box);
|
|
3062 |
}
|
|
3063 |
|
|
3064 |
/* ------------------------------------------------------------------------- *
|
|
3065 |
* Function: NW_LMgr_Box_DrawBackground
|
|
3066 |
* Description: Redraws the box and its descendants. Its behavior is only
|
|
3067 |
*/
|
|
3068 |
|
|
3069 |
TBrowserStatusCode
|
|
3070 |
NW_LMgr_Box_DrawBackground (NW_LMgr_Box_t* box,
|
|
3071 |
NW_LMgr_ContainerBox_t* parent,
|
|
3072 |
CGDIDeviceContext* deviceContext)
|
|
3073 |
{
|
|
3074 |
NW_TRY (status) {
|
|
3075 |
NW_LMgr_Box_t *parentBox = NW_LMgr_BoxOf(parent);
|
|
3076 |
NW_LMgr_Property_t prop;
|
|
3077 |
|
|
3078 |
/* Get the rootbox */
|
|
3079 |
if (NW_Object_IsClass(parent, &NW_LMgr_RootBox_Class)) {
|
|
3080 |
return KBrsrSuccess;
|
|
3081 |
}
|
|
3082 |
|
|
3083 |
status = NW_LMgr_Box_DrawBackground(box, parentBox->parent, deviceContext);
|
|
3084 |
_NW_THROW_ON_ERROR (status);
|
|
3085 |
|
|
3086 |
prop.type = NW_CSS_ValueType_Token;
|
|
3087 |
prop.value.token = NW_CSS_PropValue_transparent;
|
|
3088 |
// special handling for getting background color of StaticTableCellBox
|
|
3089 |
if (NW_Object_IsInstanceOf (parent, &NW_LMgr_StaticTableCellBox_Class))
|
|
3090 |
{
|
|
3091 |
NW_LMgr_StaticTableCellBox_t *cell = NW_LMgr_StaticTableCellBoxOf(parent);
|
|
3092 |
NW_LMgr_StaticTableCellBox_GetBackground(cell, &prop);
|
|
3093 |
}
|
|
3094 |
else
|
|
3095 |
{
|
|
3096 |
NW_LMgr_Box_GetProperty(parentBox, NW_CSS_Prop_backgroundColor, &prop);
|
|
3097 |
}
|
|
3098 |
|
|
3099 |
if (prop.type == NW_CSS_ValueType_Color)
|
|
3100 |
{
|
|
3101 |
NW_LMgr_Box_t tempBox;
|
|
3102 |
// set the rootbox so that we can get the cached settings
|
|
3103 |
status = NW_LMgr_Box_Initialize (&tempBox, 1);
|
|
3104 |
tempBox.rootBox = NW_LMgr_Box_GetRootBox( box );
|
|
3105 |
_NW_THROW_ON_ERROR (status);
|
|
3106 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetDisplayBounds( box );
|
|
3107 |
NW_GDI_Rectangle_t parentBoxBounds = NW_LMgr_Box_GetDisplayBounds( parentBox );
|
|
3108 |
NW_GDI_Rectangle_t tempBoxBounds = NW_LMgr_Box_GetDisplayBounds( &tempBox );
|
|
3109 |
|
|
3110 |
if (NW_GDI_Rectangle_Cross (&boxBounds, &parentBoxBounds, &tempBoxBounds))
|
|
3111 |
{
|
|
3112 |
/* Draw the background */
|
|
3113 |
NW_LMgr_Box_SetProperty (&tempBox, NW_CSS_Prop_backgroundColor, &prop);
|
|
3114 |
// set display bounds
|
|
3115 |
NW_LMgr_Box_UpdateDisplayBounds(&tempBox, tempBoxBounds);
|
|
3116 |
status = NW_LMgr_Box_Draw (&tempBox, deviceContext, NW_FALSE);
|
|
3117 |
if (status != KBrsrSuccess) {
|
|
3118 |
NW_Object_Terminate (&tempBox);
|
|
3119 |
if (status != KBrsrOutOfMemory) {
|
|
3120 |
status = KBrsrUnexpectedError;
|
|
3121 |
}
|
|
3122 |
return status;
|
|
3123 |
}
|
|
3124 |
}
|
|
3125 |
|
|
3126 |
NW_Object_Terminate (&tempBox);
|
|
3127 |
}
|
|
3128 |
|
|
3129 |
} NW_CATCH (status) {
|
|
3130 |
} NW_FINALLY {
|
|
3131 |
return status;
|
|
3132 |
} NW_END_TRY
|
|
3133 |
}
|
|
3134 |
|
|
3135 |
|
|
3136 |
/* ------------------------------------------------------------------------- */
|
|
3137 |
TBrowserStatusCode
|
|
3138 |
NW_LMgr_Box_GetInnerRectangle(NW_LMgr_Box_t* box,
|
|
3139 |
NW_GDI_Rectangle_t* innerRectangle)
|
|
3140 |
{
|
|
3141 |
NW_GDI_Rectangle_t bounds;
|
|
3142 |
NW_LMgr_FrameInfo_t padding;
|
|
3143 |
NW_LMgr_FrameInfo_t borderWidth;
|
|
3144 |
|
|
3145 |
/* Get all margin, border and padding settings */
|
|
3146 |
bounds = (NW_LMgr_Box_GetDisplayBounds(box));
|
|
3147 |
NW_LMgr_Box_GetPadding(box, &padding, ELMgrFrameAll );
|
|
3148 |
NW_LMgr_Box_GetBorderWidth(box, &borderWidth, ELMgrFrameAll );
|
|
3149 |
|
|
3150 |
innerRectangle->point.x =
|
|
3151 |
(NW_GDI_Metric_t)(bounds.point.x + borderWidth.left + padding.left);
|
|
3152 |
|
|
3153 |
innerRectangle->point.y =
|
|
3154 |
(NW_GDI_Metric_t)(bounds.point.y + borderWidth.top + padding.top);
|
|
3155 |
|
|
3156 |
innerRectangle->dimension.height = (NW_GDI_Metric_t)(bounds.dimension.height -
|
|
3157 |
(borderWidth.top + borderWidth.bottom + padding.top + padding.bottom));
|
|
3158 |
|
|
3159 |
innerRectangle->dimension.width = (NW_GDI_Metric_t)(bounds.dimension.width -
|
|
3160 |
(borderWidth.left + borderWidth.right + padding.left + padding.right));
|
|
3161 |
|
|
3162 |
return KBrsrSuccess;
|
|
3163 |
}
|
|
3164 |
|
|
3165 |
/* ------------------------------------------------------------------------- */
|
|
3166 |
NW_Bool
|
|
3167 |
NW_LMgr_Box_GetVisibleBounds(const NW_LMgr_Box_t* box,
|
|
3168 |
NW_GDI_Rectangle_t* bounds)
|
|
3169 |
{
|
|
3170 |
NW_GDI_Rectangle_t rect;
|
|
3171 |
NW_LMgr_PropertyValue_t overflow;
|
|
3172 |
|
|
3173 |
if (bounds != NULL) {
|
|
3174 |
NW_Mem_memset(bounds, 0, sizeof(NW_GDI_Rectangle_t));
|
|
3175 |
}
|
|
3176 |
|
|
3177 |
rect = NW_LMgr_Box_GetDisplayBounds((NW_LMgr_Box_t*)box);
|
|
3178 |
|
|
3179 |
box = (NW_LMgr_Box_t*)box->parent;
|
|
3180 |
while (box != NULL) {
|
|
3181 |
if (NW_Object_IsClass(box, &NW_LMgr_BidiFlowBox_Class) ||
|
|
3182 |
NW_Object_IsClass(box, &NW_LMgr_StaticTableBox_Class) ||
|
|
3183 |
NW_Object_IsClass(box, &NW_LMgr_StaticTableCellBox_Class)) {
|
|
3184 |
overflow.token = NW_CSS_PropValue_visible;
|
|
3185 |
(void)NW_LMgr_Box_GetPropertyValue((NW_LMgr_Box_t*)box, NW_CSS_Prop_overflow,
|
|
3186 |
NW_CSS_ValueType_Token, &overflow);
|
|
3187 |
if (overflow.token == NW_CSS_PropValue_hidden) {
|
|
3188 |
NW_GDI_Rectangle_t temp;
|
|
3189 |
NW_GDI_Rectangle_t boxBounds = NW_LMgr_Box_GetDisplayBounds( NW_LMgr_BoxOf( box ) );
|
|
3190 |
if (!NW_GDI_Rectangle_Cross(&rect, &boxBounds, &temp)) {
|
|
3191 |
return NW_FALSE;
|
|
3192 |
}
|
|
3193 |
rect = temp;
|
|
3194 |
}
|
|
3195 |
}
|
|
3196 |
|
|
3197 |
box = (NW_LMgr_Box_t*)box->parent;
|
|
3198 |
}
|
|
3199 |
|
|
3200 |
if (bounds != NULL) {
|
|
3201 |
*bounds = rect;
|
|
3202 |
}
|
|
3203 |
return NW_TRUE;
|
|
3204 |
}
|
|
3205 |
|
|
3206 |
/* ------------------------------------------------------------------------- *
|
|
3207 |
* Function: NW_LMgr_Box_Refresh
|
|
3208 |
* Description: Redraws the box and its descendants. Its behavior is only
|
|
3209 |
* guaranteed to be correct if "overflow: hidden" is set. Any
|
|
3210 |
* already displayed overflows will not be cleared.
|
|
3211 |
* The usage of this method should be limited to the cases
|
|
3212 |
* where an _isolated_ part of the box tree needs to be updated;
|
|
3213 |
* in all other cases, the whole tree should be redrawn.
|
|
3214 |
* Refresh CANNOT be called on the root box.
|
|
3215 |
* Returns: KBrsrSuccess.
|
|
3216 |
*/
|
|
3217 |
|
|
3218 |
TBrowserStatusCode
|
|
3219 |
NW_LMgr_Box_Refresh (NW_LMgr_Box_t* box)
|
|
3220 |
{
|
|
3221 |
NW_LMgr_RootBox_t* rootBox;
|
|
3222 |
|
|
3223 |
NW_ASSERT (!NW_Object_IsClass(box, &NW_LMgr_RootBox_Class));
|
|
3224 |
|
|
3225 |
/* Get the rootbox */
|
|
3226 |
rootBox = NW_LMgr_Box_GetRootBox (box);
|
|
3227 |
// if( !rootBox || !rootBox->renderedBoxes ){
|
|
3228 |
if( !rootBox ){
|
|
3229 |
// refresh might be called even if the rendered boxes are null (when the cache is invalidated)
|
|
3230 |
return KBrsrSuccess;
|
|
3231 |
}
|
|
3232 |
|
|
3233 |
return NW_LMgr_RootBox_Refresh(rootBox, box);
|
|
3234 |
}
|
|
3235 |
|
|
3236 |
void
|
|
3237 |
NW_LMgr_Box_SetHasFocus(NW_LMgr_Box_t* box, NW_Bool hasFocus)
|
|
3238 |
{
|
|
3239 |
NW_LMgr_Box_t* thisObj;
|
|
3240 |
|
|
3241 |
// for convenience
|
|
3242 |
thisObj = NW_LMgr_BoxOf (box);
|
|
3243 |
|
|
3244 |
thisObj->hasFocus = hasFocus;
|
|
3245 |
}
|
|
3246 |
|
|
3247 |
NW_Bool
|
|
3248 |
NW_LMgr_Box_HasFocus(NW_LMgr_Box_t* box)
|
|
3249 |
{
|
|
3250 |
NW_LMgr_Box_t* thisObj;
|
|
3251 |
|
|
3252 |
// for convenience
|
|
3253 |
thisObj = NW_LMgr_BoxOf (box);
|
|
3254 |
|
|
3255 |
return thisObj->hasFocus;
|
|
3256 |
}
|
|
3257 |
|
|
3258 |
NW_GDI_Rectangle_t
|
|
3259 |
NW_LMgr_Box_GetFormatBounds( NW_LMgr_Box_t* aBox )
|
|
3260 |
{
|
|
3261 |
if( aBox )
|
|
3262 |
{
|
|
3263 |
return aBox->iFormatBounds;
|
|
3264 |
}
|
|
3265 |
else
|
|
3266 |
{
|
|
3267 |
NW_ASSERT( 0 );
|
|
3268 |
NW_GDI_Rectangle_t invalidRect;
|
|
3269 |
invalidRect.dimension.height = -1;
|
|
3270 |
invalidRect.dimension.width = -1;
|
|
3271 |
invalidRect.point.x = -1;
|
|
3272 |
invalidRect.point.y = -1;
|
|
3273 |
return invalidRect;
|
|
3274 |
}
|
|
3275 |
}
|
|
3276 |
|
|
3277 |
void NW_LMgr_Box_SetFormatBounds( NW_LMgr_Box_t* aBox, NW_GDI_Rectangle_t aFormatBounds )
|
|
3278 |
{
|
|
3279 |
if( aBox )
|
|
3280 |
{
|
|
3281 |
aBox->iFormatBounds = aFormatBounds;
|
|
3282 |
}
|
|
3283 |
}
|
|
3284 |
|
|
3285 |
NW_GDI_Rectangle_t
|
|
3286 |
NW_LMgr_Box_GetDisplayBounds( NW_LMgr_Box_t* aBox )
|
|
3287 |
{
|
|
3288 |
if( aBox )
|
|
3289 |
{
|
|
3290 |
return aBox->iDisplayBounds;
|
|
3291 |
}
|
|
3292 |
else
|
|
3293 |
{
|
|
3294 |
NW_GDI_Rectangle_t invalidRect;
|
|
3295 |
invalidRect.dimension.height = -1;
|
|
3296 |
invalidRect.dimension.width = -1;
|
|
3297 |
invalidRect.point.x = -1;
|
|
3298 |
invalidRect.point.y = -1;
|
|
3299 |
return invalidRect;
|
|
3300 |
}
|
|
3301 |
}
|
|
3302 |
|
|
3303 |
void NW_LMgr_Box_UpdateDisplayBounds( NW_LMgr_Box_t* aBox, NW_GDI_Rectangle_t aDisplayBounds )
|
|
3304 |
{
|
|
3305 |
if( aBox )
|
|
3306 |
{
|
|
3307 |
aBox->iDisplayBounds = aDisplayBounds;
|
|
3308 |
}
|
|
3309 |
}
|
|
3310 |
|
|
3311 |
/**
|
|
3312 |
* NW_LMgr_Box_UpdateContainerBodyBox
|
|
3313 |
* @description This method updates hight for displayBounds and formatBounds
|
|
3314 |
* of bodybox container to take into account body bottom margin.
|
|
3315 |
* it is called only once after page load complete
|
|
3316 |
* @param NW_LMgr_RootBox_t* aRootBox: pointer to the rootBox
|
|
3317 |
*
|
|
3318 |
* @return void
|
|
3319 |
*/
|
|
3320 |
void NW_LMgr_Box_UpdateContainerBodyBox( NW_LMgr_RootBox_t* aRootBox )
|
|
3321 |
{
|
|
3322 |
NW_GDI_Metric_t bottomMargin = 0;
|
|
3323 |
NW_LMgr_Box_t* bodyBox = NW_LMgr_RootBox_GetBody(aRootBox);
|
|
3324 |
if(bodyBox != NULL)
|
|
3325 |
{
|
|
3326 |
|
|
3327 |
NW_LMgr_ContainerBox_s *parent = bodyBox->parent;
|
|
3328 |
if(parent != NULL)
|
|
3329 |
{
|
|
3330 |
|
|
3331 |
bottomMargin =
|
|
3332 |
(NW_GDI_Metric_t)NW_LMgr_Box_GetModelProp(bodyBox,
|
|
3333 |
NW_CSS_Prop_bottomMargin);
|
|
3334 |
if(bottomMargin > 0)
|
|
3335 |
{
|
|
3336 |
NW_GDI_Rectangle_t formatBounds =
|
|
3337 |
NW_LMgr_Box_GetFormatBounds( (NW_LMgr_Box_t* )parent);
|
|
3338 |
formatBounds.dimension.height += bottomMargin;
|
|
3339 |
(void) NW_LMgr_Box_SetFormatBounds( (NW_LMgr_Box_t* )parent, formatBounds );
|
|
3340 |
NW_GDI_Rectangle_t displayBounds = NW_LMgr_Box_GetDisplayBounds((NW_LMgr_Box_t*) parent);
|
|
3341 |
displayBounds.dimension.height += bottomMargin;
|
|
3342 |
((NW_LMgr_Box_t* )parent)->iDisplayBounds.dimension.height =
|
|
3343 |
displayBounds.dimension.height;
|
|
3344 |
}
|
|
3345 |
}
|
|
3346 |
}
|
|
3347 |
|
|
3348 |
}
|
|
3349 |
/* ------------------------------------------------------------------------- *
|
|
3350 |
convenience functions
|
|
3351 |
* ------------------------------------------------------------------------- */
|
|
3352 |
|
|
3353 |
/* ------------------------------------------------------------------------- */
|
|
3354 |
TBrowserStatusCode
|
|
3355 |
NW_LMgr_Box_Initialize (NW_LMgr_Box_t* box,
|
|
3356 |
NW_ADT_Vector_Metric_t numProperties)
|
|
3357 |
{
|
|
3358 |
return NW_Object_Initialize (&NW_LMgr_Box_Class, box, numProperties);
|
|
3359 |
}
|
|
3360 |
|
|
3361 |
/* ------------------------------------------------------------------------- */
|
|
3362 |
NW_LMgr_Box_t*
|
|
3363 |
NW_LMgr_Box_New (NW_ADT_Vector_Metric_t numProperties)
|
|
3364 |
{
|
|
3365 |
return (NW_LMgr_Box_t*)
|
|
3366 |
NW_Object_New (&NW_LMgr_Box_Class, (NW_Uint32)numProperties);
|
|
3367 |
}
|
|
3368 |
|
|
3369 |
|
|
3370 |
#ifdef _DEBUG
|
|
3371 |
/*lint -save -esym(960, 87) -e64 Only preprocessor statements and comments before '#include', Type mismatch */
|
|
3372 |
|
|
3373 |
#include "LMgrAnonBlock.h"
|
|
3374 |
#include "LMgrAnonTableBox.h"
|
|
3375 |
#include "LMgrMarkerImage.h"
|
|
3376 |
#include "LMgrMarkerText.h"
|
|
3377 |
#include "LMgrObjectBoxOOC.h"
|
|
3378 |
#include "nw_fbox_buttonbox.h"
|
|
3379 |
#include "nw_fbox_checkbox.h"
|
|
3380 |
#include "nw_fbox_fileselectionbox.h"
|
|
3381 |
#include "nw_fbox_formbox.h"
|
|
3382 |
#include "nw_fbox_imagebuttonbox.h"
|
|
3383 |
#include "nw_fbox_inputbox.h"
|
|
3384 |
#include "nw_fbox_optgrpbox.h"
|
|
3385 |
#include "nw_fbox_optionbox.h"
|
|
3386 |
#include "nw_fbox_passwordbox.h"
|
|
3387 |
#include "nw_fbox_hiddenbox.h"
|
|
3388 |
#include "nw_fbox_radiobox.h"
|
|
3389 |
#include "nw_fbox_selectbox.h"
|
|
3390 |
#include "nw_fbox_textareabox.h"
|
|
3391 |
#include "nw_lmgr_activebox.h"
|
|
3392 |
#include "nw_lmgr_activecontainerbox.h"
|
|
3393 |
#include "nw_lmgr_animatedimagebox.h"
|
|
3394 |
#include "nw_lmgr_areabox.h"
|
|
3395 |
#include "nw_lmgr_bidiflowbox.h"
|
|
3396 |
#include "nw_lmgr_containerbox.h"
|
|
3397 |
#include "nw_lmgr_breakbox.h"
|
|
3398 |
#include "nw_lmgr_emptybox.h"
|
|
3399 |
#include "nw_lmgr_imagebox.h"
|
|
3400 |
#include "nw_lmgr_flowbox.h"
|
|
3401 |
#include "nw_lmgr_formatbox.h"
|
|
3402 |
#include "nw_lmgr_linebox.h"
|
|
3403 |
#include "nw_lmgr_rootbox.h"
|
|
3404 |
#include "nw_lmgr_mediabox.h"
|
|
3405 |
#include "nw_lmgr_nobrbox.h"
|
|
3406 |
#include "nw_lmgr_rulebox.h"
|
|
3407 |
#include "nw_lmgr_splittextbox.h"
|
|
3408 |
#include "nw_lmgr_statictablebox.h"
|
|
3409 |
#include "nw_lmgr_statictablecellbox.h"
|
|
3410 |
#include "nw_lmgr_statictablerowbox.h"
|
|
3411 |
#include "nw_lmgr_textbox.h"
|
|
3412 |
|
|
3413 |
|
|
3414 |
|
|
3415 |
#define countof(x) (sizeof(x)/sizeof(x[0]))
|
|
3416 |
|
|
3417 |
typedef struct
|
|
3418 |
{
|
|
3419 |
const NW_Object_Class_t* objClass;
|
|
3420 |
const NW_Int8* className;
|
|
3421 |
} ClassNameItem_t;
|
|
3422 |
|
|
3423 |
const ClassNameItem_t classNames[] =
|
|
3424 |
{
|
|
3425 |
{&NW_FBox_ButtonBox_Class, (NW_Int8*)"FBox_ButtonBox"},
|
|
3426 |
{&NW_FBox_CheckBox_Class, (NW_Int8*)"FBox_CheckBox"},
|
|
3427 |
{&NW_FBox_FileSelectionBox_Class, (NW_Int8*)"FBox_FileSelectionBox"},
|
|
3428 |
{&NW_FBox_ImageButtonBox_Class, (NW_Int8*)"FBox_ImageButtonBox"},
|
|
3429 |
{&NW_FBox_InputBox_Class, (NW_Int8*)"FBox_InputBox"},
|
|
3430 |
{&NW_FBox_OptGrpBox_Class, (NW_Int8*)"FBox_OptGrpBox"},
|
|
3431 |
{&NW_FBox_OptionBox_Class, (NW_Int8*)"FBox_OptionBox"},
|
|
3432 |
{&NW_FBox_PasswordBox_Class, (NW_Int8*)"FBox_PasswordBox"},
|
|
3433 |
{&NW_FBox_HiddenBox_Class, (NW_Int8*)"FBox_HiddenBox"},
|
|
3434 |
{&NW_FBox_RadioBox_Class, (NW_Int8*)"FBox_RadioBox"},
|
|
3435 |
{&NW_FBox_SelectBox_Class, (NW_Int8*)"FBox_SelectBox"},
|
|
3436 |
{&NW_FBox_TextAreaBox_Class, (NW_Int8*)"FBox_TextAreaBox"},
|
|
3437 |
{&NW_LMgr_AbstractTextBox_Class, (NW_Int8*)"AbstractTextBox"},
|
|
3438 |
{&NW_LMgr_ActiveBox_Class, (NW_Int8*)"ActiveBox"},
|
|
3439 |
{&NW_LMgr_ActiveContainerBox_Class, (NW_Int8*)"ActiveContainerBox"},
|
|
3440 |
{&NW_LMgr_AnimatedImageBox_Class, (NW_Int8*)"AnimatedImageBox"},
|
|
3441 |
{&LMgrAnonBlock_Class, (NW_Int8*)"AnonBlockBox"},
|
|
3442 |
{&LMgrAnonTableBox_Class, (NW_Int8*)"AnonTableBox"},
|
|
3443 |
{&NW_LMgr_AreaBox_Class, (NW_Int8*)"AreaBox"},
|
|
3444 |
{&NW_LMgr_BidiFlowBox_Class, (NW_Int8*)"BidiFlowBox"},
|
|
3445 |
{&NW_LMgr_BreakBox_Class, (NW_Int8*)"BreakBox"},
|
|
3446 |
{&NW_LMgr_ContainerBox_Class, (NW_Int8*)"ContainerBox"},
|
|
3447 |
{&NW_LMgr_EmptyBox_Class, (NW_Int8*)"EmptyBox"},
|
|
3448 |
{&NW_LMgr_FlowBox_Class, (NW_Int8*)"FlowBox"},
|
|
3449 |
{&NW_LMgr_FormatBox_Class, (NW_Int8*)"FormatBox"},
|
|
3450 |
{&NW_LMgr_ImageBox_Class, (NW_Int8*)"ImageBox"},
|
|
3451 |
{&NW_LMgr_ImgContainerBox_Class, (NW_Int8*)"ImgContainerBox"},
|
|
3452 |
{&NW_LMgr_ImageMapBox_Class, (NW_Int8*)"ImageMapBox"},
|
|
3453 |
{&NW_LMgr_LineBox_Class, (NW_Int8*)"LineBox"},
|
|
3454 |
{&LMgrMarkerImage_Class, (NW_Int8*)"MarkerImageBox"},
|
|
3455 |
{&LMgrMarkerText_Class, (NW_Int8*)"MarkerTextBox"},
|
|
3456 |
{&NW_LMgr_MarqueeBox_Class, (NW_Int8*)"MarqueeBox"},
|
|
3457 |
{&NW_LMgr_MediaBox_Class, (NW_Int8*)"MediaBox"},
|
|
3458 |
{&NW_LMgr_NobrBox_Class, (NW_Int8*)"NobrBox"},
|
|
3459 |
{&NW_LMgr_ObjectBox_Class, (NW_Int8*)"ObjectBox"},
|
|
3460 |
{&NW_LMgr_PosFlowBox_Class, (NW_Int8*)"PositionedBox"},
|
|
3461 |
{&NW_LMgr_RootBox_Class, (NW_Int8*)"RootBox"},
|
|
3462 |
{&NW_LMgr_RuleBox_Class, (NW_Int8*)"RuleBox"},
|
|
3463 |
{&NW_LMgr_SplitTextBox_Class, (NW_Int8*)"SplitTextBox"},
|
|
3464 |
{&NW_LMgr_StaticTableBox_Class, (NW_Int8*)"StaticTableBox"},
|
|
3465 |
{&NW_LMgr_StaticTableCellBox_Class, (NW_Int8*)"StaticTableCellBox"},
|
|
3466 |
{&NW_LMgr_StaticTableRowBox_Class, (NW_Int8*)"StaticTableRowBox"},
|
|
3467 |
{&NW_LMgr_TextBox_Class, (NW_Int8*)"TextBox"},
|
|
3468 |
{&NW_LMgr_VerticalTableBox_Class, (NW_Int8*)"VerticalTableBox"},
|
|
3469 |
{&NW_LMgr_VerticalTableCellBox_Class, (NW_Int8*)"VerticalTableCellBox"},
|
|
3470 |
{&NW_LMgr_VerticalTableRowBox_Class, (NW_Int8*)"VerticalRowBox"},
|
|
3471 |
};
|
|
3472 |
#define CLASS_NAMES_COUNT countof(classNames)
|
|
3473 |
|
|
3474 |
const NW_Int8*
|
|
3475 |
NW_LMgr_Box_GetBoxType (NW_LMgr_Box_t *box) {
|
|
3476 |
|
|
3477 |
for (int i = 0; i < CLASS_NAMES_COUNT; i++) {
|
|
3478 |
if (classNames[i].objClass == box->super.super.super.objClass) {
|
|
3479 |
return classNames[i].className;
|
|
3480 |
}
|
|
3481 |
}
|
|
3482 |
|
|
3483 |
return (NW_Int8*)"Unknown box: update NW_LMgr_Box_GetBoxType and/or the classNames table in LMgrBox.cpp.";
|
|
3484 |
}
|
|
3485 |
|
|
3486 |
/* ------------------------------------------------------------------------- */
|
|
3487 |
/* HACK! HACK! HACK!
|
|
3488 |
* This is here ONLY for debugging purposes. The proper way to do this
|
|
3489 |
* (making GetBoxInfo virtual on box) would clutter the Box interface
|
|
3490 |
* too much.
|
|
3491 |
*/
|
|
3492 |
|
|
3493 |
|
|
3494 |
static
|
|
3495 |
NW_Uint16
|
|
3496 |
GetBoxLevel (NW_LMgr_Box_t *box, NW_LMgr_Box_t *rootBox) {
|
|
3497 |
NW_Uint16 level;
|
|
3498 |
|
|
3499 |
level = 0;
|
|
3500 |
while (box != rootBox) {
|
|
3501 |
level ++;
|
|
3502 |
box = (NW_LMgr_Box_t*)NW_LMgr_Box_GetParent (box);
|
|
3503 |
NW_ASSERT (box != NULL);
|
|
3504 |
}
|
|
3505 |
|
|
3506 |
return level;
|
|
3507 |
}
|
|
3508 |
|
|
3509 |
static
|
|
3510 |
void
|
|
3511 |
PrintBoxInfo (NW_LMgr_Box_t *box, NW_Uint16 level) {
|
|
3512 |
|
|
3513 |
const NW_Int8 *typeStr;
|
|
3514 |
NW_Ucs2 *textBoxStr = NULL;
|
|
3515 |
NW_Ucs2 indentBuf[256];
|
|
3516 |
NW_Ucs2 typeBuf[64];
|
|
3517 |
NW_Ucs2 tableInfo[64];
|
|
3518 |
NW_Ucs2 tableInfoFormat[] = { 'S', '%', 'd', ':', 'B', '%', 'd', ':',
|
|
3519 |
'H', '%', 'd', ':', 'V', '%', 'd', '\0' };
|
|
3520 |
NW_Uint16 i;
|
|
3521 |
NW_LMgr_StaticTableBox_t *tableBox = NULL;
|
|
3522 |
NW_Uint16 numBorderInfos = 0;
|
|
3523 |
NW_Uint16 numSpans = 0;
|
|
3524 |
NW_Uint16 numHEdges = 0;
|
|
3525 |
NW_Uint16 numVEdges = 0;
|
|
3526 |
NW_GDI_Rectangle_t bounds;
|
|
3527 |
NW_GDI_Rectangle_t dispBounds;
|
|
3528 |
NW_Text_t *displayText = NULL;
|
|
3529 |
|
|
3530 |
typeStr = NW_LMgr_Box_GetBoxType(box);
|
|
3531 |
|
|
3532 |
if (NW_Object_IsInstanceOf (box, &NW_LMgr_AbstractTextBox_Class)) {
|
|
3533 |
displayText = NW_LMgr_AbstractTextBox_GetDisplayText(NW_LMgr_AbstractTextBoxOf(box), NW_TRUE);
|
|
3534 |
if( displayText )
|
|
3535 |
textBoxStr = NW_Text_GetUCS2Buffer (displayText,
|
|
3536 |
NW_Text_Flags_Copy, NULL, NULL);
|
|
3537 |
if (textBoxStr) {
|
|
3538 |
NW_Str_Strcharreplace (textBoxStr, '\n', '>');
|
|
3539 |
|
|
3540 |
// Trunc the text to 900 (NW_Debug_Log doesn't allow a print statement larger than 1024).
|
|
3541 |
if (displayText->characterCount > 900) {
|
|
3542 |
textBoxStr[900] = '\0';
|
|
3543 |
}
|
|
3544 |
}
|
|
3545 |
}
|
|
3546 |
|
|
3547 |
//NW_Str_StrcpyConst(typeBuf, (char*)typeStr);
|
|
3548 |
/* Get the box bounds */
|
|
3549 |
bounds = NW_LMgr_Box_GetFormatBounds(box);
|
|
3550 |
dispBounds = NW_LMgr_Box_GetDisplayBounds (box);
|
|
3551 |
|
|
3552 |
/* Indent the line */
|
|
3553 |
for (i=0; i<level*2 && i < 254; i++) {
|
|
3554 |
indentBuf[i] = ' ';
|
|
3555 |
}
|
|
3556 |
indentBuf[i] = '\0';
|
|
3557 |
|
|
3558 |
/* Print the info */
|
|
3559 |
if (textBoxStr)
|
|
3560 |
{
|
|
3561 |
NW_LOG12(NW_LOG_LEVEL3, "%s%s %X [bounds:(%d,%d)-(%d,%d), dispBounds:(%d,%d)-(%d,%d)\"%s\"]",
|
|
3562 |
indentBuf,
|
|
3563 |
typeBuf,
|
|
3564 |
box,
|
|
3565 |
(NW_Uint16)bounds.point.x,
|
|
3566 |
(NW_Uint16)bounds.point.y,
|
|
3567 |
(NW_Uint16)bounds.dimension.width,
|
|
3568 |
(NW_Uint16)bounds.dimension.height,
|
|
3569 |
(NW_Uint16)dispBounds.point.x,
|
|
3570 |
(NW_Uint16)dispBounds.point.y,
|
|
3571 |
(NW_Uint16)dispBounds.dimension.width,
|
|
3572 |
(NW_Uint16)dispBounds.dimension.height,
|
|
3573 |
textBoxStr);
|
|
3574 |
|
|
3575 |
NW_Str_Delete (textBoxStr);
|
|
3576 |
NW_Object_Delete(displayText);
|
|
3577 |
}
|
|
3578 |
else if (tableBox)
|
|
3579 |
{
|
|
3580 |
NW_Str_Sprintf(tableInfo, tableInfoFormat,
|
|
3581 |
(NW_Uint32)numSpans,
|
|
3582 |
(NW_Uint32)numBorderInfos,
|
|
3583 |
(NW_Uint32)numHEdges,
|
|
3584 |
(NW_Uint32)numVEdges);
|
|
3585 |
|
|
3586 |
NW_LOG12(NW_LOG_LEVEL3, "%s%s %X [bounds:(%d,%d)-(%d,%d), dispBounds:(%d,%d)-(%d,%d) %s]",
|
|
3587 |
indentBuf,
|
|
3588 |
typeBuf,
|
|
3589 |
box,
|
|
3590 |
(NW_Uint16)bounds.point.x,
|
|
3591 |
(NW_Uint16)bounds.point.y,
|
|
3592 |
(NW_Uint16)bounds.dimension.width,
|
|
3593 |
(NW_Uint16)bounds.dimension.height,
|
|
3594 |
(NW_Uint16)dispBounds.point.x,
|
|
3595 |
(NW_Uint16)dispBounds.point.y,
|
|
3596 |
(NW_Uint16)dispBounds.dimension.width,
|
|
3597 |
(NW_Uint16)dispBounds.dimension.height,
|
|
3598 |
tableInfo);
|
|
3599 |
}
|
|
3600 |
else
|
|
3601 |
{
|
|
3602 |
NW_LOG11(NW_LOG_LEVEL3, "%s%s %X [bounds:(%d,%d)-(%d,%d), dispBounds:(%d,%d)-(%d,%d)]",
|
|
3603 |
indentBuf,
|
|
3604 |
typeBuf,
|
|
3605 |
box,
|
|
3606 |
(NW_Uint16)bounds.point.x,
|
|
3607 |
(NW_Uint16)bounds.point.y,
|
|
3608 |
(NW_Uint16)bounds.dimension.width,
|
|
3609 |
(NW_Uint16)bounds.dimension.height,
|
|
3610 |
(NW_Uint16)dispBounds.point.x,
|
|
3611 |
(NW_Uint16)dispBounds.point.y,
|
|
3612 |
(NW_Uint16)dispBounds.dimension.width,
|
|
3613 |
(NW_Uint16)dispBounds.dimension.height);
|
|
3614 |
if( NW_Object_IsInstanceOf (box, &NW_LMgr_StaticTableBox_Class ) == NW_TRUE )
|
|
3615 |
{
|
|
3616 |
NW_LMgr_StaticTableContext_t *ctx = NW_LMgr_StaticTableBoxOf( box )->ctx;
|
|
3617 |
if( ctx != NULL )
|
|
3618 |
{
|
|
3619 |
NW_LOG4(NW_LOG_LEVEL3, "%s%s \" [Table - Min,Max:(%d,%d)]",
|
|
3620 |
indentBuf,
|
|
3621 |
typeBuf,
|
|
3622 |
(NW_Uint16)ctx->tableMinWidth,
|
|
3623 |
(NW_Uint16)ctx->tableMaxWidth );
|
|
3624 |
}
|
|
3625 |
}
|
|
3626 |
else if( NW_Object_IsInstanceOf (box, &NW_LMgr_StaticTableCellBox_Class ) == NW_TRUE )
|
|
3627 |
{
|
|
3628 |
NW_LOG4(NW_LOG_LEVEL3, "%s%s \" [Cell - Min,Max:(%d,%d)]",
|
|
3629 |
indentBuf,
|
|
3630 |
typeBuf,
|
|
3631 |
NW_LMgr_StaticTableCellBoxOf( box )->minWidth,
|
|
3632 |
NW_LMgr_StaticTableCellBoxOf( box )->maxWidth);
|
|
3633 |
}
|
|
3634 |
}
|
|
3635 |
}
|
|
3636 |
|
|
3637 |
|
|
3638 |
TBrowserStatusCode
|
|
3639 |
NW_LMgr_Box_DumpBoxTree(NW_LMgr_Box_t* box)
|
|
3640 |
{
|
|
3641 |
NW_LMgr_BoxVisitor_t boxVisitor;
|
|
3642 |
NW_LMgr_Box_t *current;
|
|
3643 |
NW_Uint16 level;
|
|
3644 |
|
|
3645 |
/* Initialize the BoxVisitor */
|
|
3646 |
NW_LMgr_BoxVisitor_Initialize (&boxVisitor, box);
|
|
3647 |
|
|
3648 |
/* Dump the subtree */
|
|
3649 |
NW_LOG0(NW_LOG_LEVEL3, "Printing the box tree...");
|
|
3650 |
NW_LOG0(NW_LOG_LEVEL3, "N.B.: The displayed class names could be names of superclasses!");
|
|
3651 |
while((current = NW_LMgr_BoxVisitor_NextBox (&boxVisitor, NULL)) != NULL) {
|
|
3652 |
|
|
3653 |
level = GetBoxLevel (current, box);
|
|
3654 |
|
|
3655 |
/* Get the boxInfo for the current box */
|
|
3656 |
PrintBoxInfo (current, level);
|
|
3657 |
}
|
|
3658 |
|
|
3659 |
return KBrsrSuccess;
|
|
3660 |
}
|
|
3661 |
|
|
3662 |
/*lint -restore*/
|
|
3663 |
#endif /* _DEBUG */
|
|
3664 |
|
|
3665 |
|