Skip to content

Commit ec7e75e

Browse files
Merge branch 'develop'
2 parents 407475e + 8ea7694 commit ec7e75e

File tree

12 files changed

+401
-56
lines changed

12 files changed

+401
-56
lines changed

wffweb/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.webfirmframework</groupId>
55
<artifactId>wffweb</artifactId>
6-
<version>2.1.13</version>
6+
<version>2.1.14</version>
77

88
<properties>
99
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2014-2017 Web Firm Framework
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.webfirmframework.wffweb;
17+
18+
public class DataWffIdOutOfRangeError extends WffError {
19+
20+
private static final long serialVersionUID = 1L;
21+
22+
public DataWffIdOutOfRangeError() {
23+
super();
24+
}
25+
26+
public DataWffIdOutOfRangeError(final String message, final Throwable cause,
27+
final boolean enableSuppression, final boolean writableStackTrace) {
28+
super(message, cause, enableSuppression, writableStackTrace);
29+
}
30+
31+
public DataWffIdOutOfRangeError(final String message,
32+
final Throwable cause) {
33+
super(message, cause);
34+
}
35+
36+
public DataWffIdOutOfRangeError(final String message) {
37+
super(message);
38+
}
39+
40+
public DataWffIdOutOfRangeError(final Throwable cause) {
41+
super(cause);
42+
}
43+
44+
}

wffweb/src/main/java/com/webfirmframework/wffweb/css/HeightCss.java

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,17 @@ public class HeightCss extends AbstractCssProperty<HeightCss> {
3636
public static final String AUTO = "auto";
3737
public static final String INITIAL = "initial";
3838
public static final String INHERIT = "inherit";
39+
public static final String FIT_CONTENT = "fit-content";
40+
public static final String AVAILABLE = "available";
41+
public static final String MIN_CONTENT = "min-content";
42+
public static final String MAX_CONTENT = "max-content";
43+
public static final String FILL = "fill";
44+
public static final String CONTENT_BOX = "content-box";
45+
public static final String BORDER_BOX = "border-box";
3946

40-
private static final List<String> PREDEFINED_CONSTANTS = Arrays
41-
.asList(INITIAL, INHERIT, AUTO);
47+
private static final List<String> PREDEFINED_CONSTANTS = Arrays.asList(
48+
INITIAL, INHERIT, AUTO, FIT_CONTENT, AVAILABLE, MIN_CONTENT,
49+
MAX_CONTENT, FILL, CONTENT_BOX, BORDER_BOX);
4250

4351
private String cssValue;
4452
private Float value;
@@ -205,9 +213,8 @@ public HeightCss setCssValue(final String cssValue) {
205213
break;
206214
}
207215
}
208-
if (trimmedCssValue.equalsIgnoreCase(INITIAL)
209-
|| trimmedCssValue.equalsIgnoreCase(INHERIT)
210-
|| trimmedCssValue.equalsIgnoreCase(AUTO)) {
216+
if (PREDEFINED_CONSTANTS
217+
.contains(TagStringUtil.toLowerCase(trimmedCssValue))) {
211218
this.cssValue = trimmedCssValue.toLowerCase();
212219
cssLengthUnit = null;
213220
invalidValue = false;
@@ -258,6 +265,66 @@ public void setAsAuto() {
258265
setCssValue(AUTO);
259266
}
260267

268+
/**
269+
* sets as {@code available}.
270+
*
271+
* @since 2.1.14
272+
* @author WFF
273+
*/
274+
public void setAsAvailable() {
275+
setCssValue(AVAILABLE);
276+
}
277+
278+
/**
279+
* sets as {@code min-content}.
280+
*
281+
* @since 2.1.14
282+
* @author WFF
283+
*/
284+
public void setAsMinContent() {
285+
setCssValue(MIN_CONTENT);
286+
}
287+
288+
/**
289+
* sets as {@code max-content}.
290+
*
291+
* @since 2.1.14
292+
* @author WFF
293+
*/
294+
public void setAsMaxContent() {
295+
setCssValue(MAX_CONTENT);
296+
}
297+
298+
/**
299+
* sets as {@code fill}.
300+
*
301+
* @since 2.1.14
302+
* @author WFF
303+
*/
304+
public void setAsFill() {
305+
setCssValue(FILL);
306+
}
307+
308+
/**
309+
* sets as {@code content-box}.
310+
*
311+
* @since 2.1.14
312+
* @author WFF
313+
*/
314+
public void setAsContentBox() {
315+
setCssValue(CONTENT_BOX);
316+
}
317+
318+
/**
319+
* sets as {@code border-box}.
320+
*
321+
* @since 2.1.14
322+
* @author WFF
323+
*/
324+
public void setAsBorderBox() {
325+
setCssValue(BORDER_BOX);
326+
}
327+
261328
/**
262329
* validates if the given cssValue is valid for this class.
263330
*

wffweb/src/main/java/com/webfirmframework/wffweb/css/WidthCss.java

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,17 @@ public class WidthCss extends AbstractCssProperty<WidthCss> {
3636
public static final String AUTO = "auto";
3737
public static final String INITIAL = "initial";
3838
public static final String INHERIT = "inherit";
39+
public static final String FIT_CONTENT = "fit-content";
40+
public static final String AVAILABLE = "available";
41+
public static final String MIN_CONTENT = "min-content";
42+
public static final String MAX_CONTENT = "max-content";
43+
public static final String FILL = "fill";
44+
public static final String CONTENT_BOX = "content-box";
45+
public static final String BORDER_BOX = "border-box";
3946

40-
private static final List<String> PREDEFINED_CONSTANTS = Arrays
41-
.asList(INITIAL, INHERIT, AUTO);
47+
private static final List<String> PREDEFINED_CONSTANTS = Arrays.asList(
48+
INITIAL, INHERIT, AUTO, FIT_CONTENT, AVAILABLE, MIN_CONTENT,
49+
MAX_CONTENT, FILL, CONTENT_BOX, BORDER_BOX);
4250

4351
private String cssValue;
4452
private Float value;
@@ -217,9 +225,8 @@ public WidthCss setCssValue(final String cssValue) {
217225
break;
218226
}
219227
}
220-
if (trimmedCssValue.equalsIgnoreCase(INITIAL)
221-
|| trimmedCssValue.equalsIgnoreCase(INHERIT)
222-
|| trimmedCssValue.equalsIgnoreCase(AUTO)) {
228+
if (PREDEFINED_CONSTANTS
229+
.contains(TagStringUtil.toLowerCase(trimmedCssValue))) {
223230
this.cssValue = trimmedCssValue.toLowerCase();
224231
cssLengthUnit = null;
225232
value = null;
@@ -272,6 +279,66 @@ public void setAsAuto() {
272279
setCssValue(AUTO);
273280
}
274281

282+
/**
283+
* sets as {@code available}.
284+
*
285+
* @since 2.1.14
286+
* @author WFF
287+
*/
288+
public void setAsAvailable() {
289+
setCssValue(AVAILABLE);
290+
}
291+
292+
/**
293+
* sets as {@code min-content}.
294+
*
295+
* @since 2.1.14
296+
* @author WFF
297+
*/
298+
public void setAsMinContent() {
299+
setCssValue(MIN_CONTENT);
300+
}
301+
302+
/**
303+
* sets as {@code max-content}.
304+
*
305+
* @since 2.1.14
306+
* @author WFF
307+
*/
308+
public void setAsMaxContent() {
309+
setCssValue(MAX_CONTENT);
310+
}
311+
312+
/**
313+
* sets as {@code fill}.
314+
*
315+
* @since 2.1.14
316+
* @author WFF
317+
*/
318+
public void setAsFill() {
319+
setCssValue(FILL);
320+
}
321+
322+
/**
323+
* sets as {@code content-box}.
324+
*
325+
* @since 2.1.14
326+
* @author WFF
327+
*/
328+
public void setAsContentBox() {
329+
setCssValue(CONTENT_BOX);
330+
}
331+
332+
/**
333+
* sets as {@code border-box}.
334+
*
335+
* @since 2.1.14
336+
* @author WFF
337+
*/
338+
public void setAsBorderBox() {
339+
setCssValue(BORDER_BOX);
340+
}
341+
275342
/**
276343
* validates if the given cssValue is valid for this class.
277344
*

wffweb/src/main/java/com/webfirmframework/wffweb/server/page/ChildTagAppendListenerImpl.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,9 @@ public void childAppended(final Event event) {
9595

9696
final DataWffId dataWffId = parentTag.getDataWffId();
9797

98-
if (dataWffId == null) {
99-
if (LOGGER.isLoggable(Level.WARNING)) {
100-
LOGGER.warning(
101-
"Could not find data-wff-id from direct parent tag");
102-
}
98+
if (dataWffId == null && LOGGER.isLoggable(Level.WARNING)) {
99+
LOGGER.warning(
100+
"Could not find data-wff-id from direct parent tag");
103101
}
104102

105103
//@formatter:off

wffweb/src/main/java/com/webfirmframework/wffweb/server/page/js/WffJsFile.java

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ public enum WffJsFile {
7171

7272
private String optimizedFileContent;
7373

74-
private static Set<String> functionNames;
74+
private static volatile Set<String> functionNames;
7575

7676
private static Set<String> variableNames;
7777

78-
private static volatile int functionId = 0;
78+
private static int functionId = 0;
7979

80-
private static volatile int variableId = 0;
80+
private static int variableId = 0;
8181

8282
private static String[][] minifiableParts = { { "else {", "else{" },
8383
{ "} else", "}else" }, { "if (", "if(" }, { ") {", "){" } };
@@ -414,33 +414,40 @@ public static String getAllOptimizedContent(final String wsUrl,
414414

415415
allOptimizedContent = builder.toString().trim();
416416

417-
if (PRODUCTION_MODE && functionNames != null
418-
&& variableNames != null && minifiableParts != null) {
417+
if (PRODUCTION_MODE && functionNames != null) {
419418

420-
for (final String name : functionNames) {
421-
allOptimizedContent = allOptimizedContent.replace(name,
422-
"f" + (++functionId));
423-
}
419+
synchronized (WffJsFile.class) {
424420

425-
for (final String name : variableNames) {
426-
allOptimizedContent = allOptimizedContent.replace(name,
427-
"v" + (++variableId));
428-
}
421+
if (functionNames != null) {
429422

430-
for (final String[] each : minifiableParts) {
431-
allOptimizedContent = allOptimizedContent.replace(each[0],
432-
each[1]);
433-
}
423+
for (final String name : functionNames) {
424+
allOptimizedContent = allOptimizedContent
425+
.replace(name, "f" + (++functionId));
426+
}
427+
428+
for (final String name : variableNames) {
429+
allOptimizedContent = allOptimizedContent
430+
.replace(name, "v" + (++variableId));
431+
}
434432

435-
// there is bug while enabling this, also enable in Task
436-
// for (final Task task : Task.getSortedTasks()) {
437-
// allOptimizedContent = allOptimizedContent
438-
// .replace(task.name(), task.getShortName());
439-
// }
433+
for (final String[] each : minifiableParts) {
434+
allOptimizedContent = allOptimizedContent
435+
.replace(each[0], each[1]);
436+
}
437+
438+
// there is bug while enabling this, also enable in Task
439+
// for (final Task task : Task.getSortedTasks()) {
440+
// allOptimizedContent = allOptimizedContent
441+
// .replace(task.name(), task.getShortName());
442+
// }
443+
444+
functionNames = null;
445+
variableNames = null;
446+
minifiableParts = null;
440447

441-
functionNames = null;
442-
variableNames = null;
443-
minifiableParts = null;
448+
}
449+
450+
}
444451

445452
}
446453

wffweb/src/main/java/com/webfirmframework/wffweb/tag/html/AbstractHtml.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,7 @@ private void initSharedObject(final AbstractHtml child) {
485485
&& eachChild.getTagName() != null
486486
&& !eachChild.getTagName().isEmpty()) {
487487

488-
eachChild.setDataWffId(
489-
sharedObject.getNewDataWffId(ACCESS_OBJECT));
488+
eachChild.initDataWffId(sharedObject);
490489

491490
}
492491

@@ -2739,6 +2738,21 @@ public static AbstractHtml getTagFromWffBMBytes(final byte[] bmMessageBytes,
27392738
}
27402739
}
27412740

2741+
private void initDataWffId(final AbstractHtml5SharedObject sharedObject) {
2742+
if (dataWffId == null) {
2743+
synchronized (this) {
2744+
if (dataWffId == null) {
2745+
final DataWffId newDataWffId = sharedObject
2746+
.getNewDataWffId(ACCESS_OBJECT);
2747+
addAttributes(false, newDataWffId);
2748+
dataWffId = newDataWffId;
2749+
}
2750+
}
2751+
} else {
2752+
throw new WffRuntimeException("dataWffId already exists");
2753+
}
2754+
}
2755+
27422756
/**
27432757
* @return the dataWffId
27442758
*/

0 commit comments

Comments
 (0)