Skip to content

Commit 4a85a12

Browse files
authored
make GWT epub friendly (#10148)
GWT is a great tool to bring interactivity in ebooks to a whole new level. Unfortunately, the epub v3 specs are still based on XHTML... even though the newer bells and whistles of HTML5 are acceptable too. With respect to GWT, issue arise solely due to the ` ` character entity, which is undefined in `XHTML`. Once replaced by ` ` GWT works like a charm inside any epub (and javascript capable reader). This PR does just that by replacing those characters but only where it matters, e.g. no replacements under the `test` or `samples` directories.
1 parent 66fc6ff commit 4a85a12

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

user/src/com/google/gwt/layout/client/LayoutImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class LayoutImpl {
5454

5555
protected static DivElement createRuler(Unit widthUnit, Unit heightUnit) {
5656
DivElement ruler = Document.get().createDivElement();
57-
ruler.setInnerHTML(" ");
57+
// use ePub/XHTML friendly  
58+
ruler.setInnerHTML(" ");
5859
Style style = ruler.getStyle();
5960
style.setPosition(Position.ABSOLUTE);
6061
style.setZIndex(-32767);

user/src/com/google/gwt/logging/client/HtmlLogFormatter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ private String getColor(int logLevel) {
102102
private String getEscaped(String text) {
103103
text = text.replaceAll("<", "&lt;");
104104
text = text.replaceAll(">", "&gt;");
105-
text = text.replaceAll("\t", "&nbsp;&nbsp;&nbsp;");
105+
// use ePub/XHTML friendly &nbsp;
106+
text = text.replaceAll("\t", "&#xA0;&#xA0;&#xA0;");
106107
return text;
107108
}
108109

user/src/com/google/gwt/user/client/ui/Grid.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public class Grid extends HTMLTable {
7575
*/
7676
private static native void addRows(Element table, int rows, int columns) /*-{
7777
var td = $doc.createElement("td");
78-
td.innerHTML = "&nbsp;";
78+
// use ePub/XHTML friendly &nbsp;
79+
td.innerHTML = "&#xA0;";
7980
var row = $doc.createElement("tr");
8081
for(var cellNum = 0; cellNum < columns; cellNum++) {
8182
var cell = td.cloneNode(true);
@@ -130,7 +131,8 @@ public Grid(int rows, int columns) {
130131
public boolean clearCell(int row, int column) {
131132
Element td = getCellFormatter().getElement(row, column);
132133
boolean b = internalClearCell(td, false);
133-
td.setInnerHTML("&nbsp;");
134+
// use ePub/XHTML friendly &nbsp;
135+
td.setInnerHTML("&#xA0;");
134136
return b;
135137
}
136138

@@ -269,9 +271,9 @@ public void resizeRows(int rows) {
269271
protected com.google.gwt.user.client.Element createCell() {
270272
Element td = super.createCell();
271273

272-
// Add a non-breaking space to the TD. This ensures that the cell is
273-
// displayed.
274-
td.setInnerHTML("&nbsp;");
274+
// Add an ePub/XHTML friendly non-breaking space to the TD. This ensures that
275+
// the cell is displayed.
276+
td.setInnerHTML("&#xA0;");
275277
return DOM.asOld(td);
276278
}
277279

user/src/com/google/gwt/user/client/ui/TabBar.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ public TabBar() {
208208

209209
panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
210210

211-
HTML first = new HTML("&nbsp;", true), rest = new HTML("&nbsp;", true);
211+
// use ePub/XHTML friendly &nbsp;
212+
HTML first = new HTML("&#xA0;", true), rest = new HTML("&#xA0;", true);
212213
first.setStyleName("gwt-TabBarFirst");
213214
rest.setStyleName("gwt-TabBarRest");
214215
first.setHeight("100%");

0 commit comments

Comments
 (0)