@breakside/jskit 2022.22.1 → 2022.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Frameworks/DOM.jsframework/Info.json +2 -2
- package/Frameworks/DOM.jsframework/JS/XMLSerializer.js +9 -4
- package/Frameworks/DOM.jsframework/io.breakside.JSKit.DOM-bundle.js +2 -2
- package/Frameworks/DOM.jsframework/sources.json +10 -3
- package/Frameworks/FontKit.jsframework/Info.json +2 -2
- package/Frameworks/FontKit.jsframework/io.breakside.JSKit.FontKit-bundle.js +2 -2
- package/Frameworks/FontKit.jsframework/sources.json +34 -2
- package/Frameworks/Foundation.jsframework/Info.json +2 -2
- package/Frameworks/Foundation.jsframework/JS/JSAttributedString.js +213 -20
- package/Frameworks/Foundation.jsframework/JS/JSFont.js +39 -15
- package/Frameworks/Foundation.jsframework/JS/JSFontDescriptor+HTML.js +8 -0
- package/Frameworks/Foundation.jsframework/JS/JSFontDescriptor.js +105 -27
- package/Frameworks/Foundation.jsframework/JS/JSTextAttachment.js +6 -1
- package/Frameworks/Foundation.jsframework/JS/JSTextRun.js +3 -0
- package/Frameworks/Foundation.jsframework/JS/String+JS.js +34 -0
- package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
- package/Frameworks/Foundation.jsframework/sources.json +167 -8
- package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
- package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
- package/Frameworks/SecurityKit.jsframework/sources.json +43 -2
- package/Info.json +2 -2
- package/Node/Builder.js +20 -9
- package/Node/FrameworkBuilder.js +22 -2
- package/Node/Project.js +22 -2
- package/Node/io.breakside.jskit-bundle.js +2 -2
- package/Node/jskit +7 -7
- package/Root/Frameworks/APIKit/Info.yaml +1 -1
- package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/AuthKit/Info.yaml +1 -1
- package/Root/Frameworks/CSSOM/Info.yaml +1 -1
- package/Root/Frameworks/ChartKit/Info.yaml +1 -1
- package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
- package/Root/Frameworks/DBKit/Info.yaml +1 -1
- package/Root/Frameworks/DOM/Info.yaml +1 -1
- package/Root/Frameworks/DOM/XMLSerializer.js +9 -4
- package/Root/Frameworks/Dispatch/Info.yaml +1 -1
- package/Root/Frameworks/FontKit/Info.yaml +1 -1
- package/Root/Frameworks/Foundation/Info.yaml +1 -1
- package/Root/Frameworks/Foundation/JSAttributedString.js +213 -20
- package/Root/Frameworks/Foundation/JSFont.js +39 -15
- package/Root/Frameworks/Foundation/JSFontDescriptor+HTML.js +8 -0
- package/Root/Frameworks/Foundation/JSFontDescriptor.js +105 -27
- package/Root/Frameworks/Foundation/JSTextAttachment.js +6 -1
- package/Root/Frameworks/Foundation/JSTextRun.js +3 -0
- package/Root/Frameworks/Foundation/String+JS.js +34 -0
- package/Root/Frameworks/ImageKit/Info.yaml +1 -1
- package/Root/Frameworks/MediaKit/Info.yaml +1 -1
- package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
- package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
- package/Root/Frameworks/PDFKit/Info.yaml +1 -1
- package/Root/Frameworks/QRKit/Info.yaml +1 -1
- package/Root/Frameworks/SearchKit/Info.yaml +1 -1
- package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
- package/Root/Frameworks/ServerKit/Info.yaml +1 -1
- package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/TestKit/Info.yaml +1 -1
- package/Root/Frameworks/UIKit/Info.yaml +1 -1
- package/Root/Frameworks/UIKit/UIHTMLTextFrame.js +3 -0
- package/Root/Frameworks/UIKit/UIHTMLTextRun.js +3 -1
- package/Root/Frameworks/UIKit/UIHTMLTextTypesetter.js +14 -0
- package/Root/Frameworks/UIKit/UILabel.js +43 -10
- package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
- package/package.json +1 -1
|
@@ -49,7 +49,7 @@ JSClass("JSFont", JSObject, {
|
|
|
49
49
|
var weight;
|
|
50
50
|
var style;
|
|
51
51
|
var size;
|
|
52
|
-
var defaults =
|
|
52
|
+
var defaults = JSFontDescriptor.system;
|
|
53
53
|
// if ('descriptor' in values){
|
|
54
54
|
// values = values.descriptor;
|
|
55
55
|
// }
|
|
@@ -78,7 +78,7 @@ JSClass("JSFont", JSObject, {
|
|
|
78
78
|
size = JSFont.Size.normal;
|
|
79
79
|
}
|
|
80
80
|
if (family){
|
|
81
|
-
var descriptor =
|
|
81
|
+
var descriptor = JSFontDescriptor.descriptorWithFamily(family, weight, style);
|
|
82
82
|
if (descriptor !== null){
|
|
83
83
|
return JSFont.initWithDescriptor(descriptor, size);
|
|
84
84
|
}
|
|
@@ -86,6 +86,30 @@ JSClass("JSFont", JSObject, {
|
|
|
86
86
|
return null;
|
|
87
87
|
},
|
|
88
88
|
|
|
89
|
+
initFromDictionary: function(dictionary){
|
|
90
|
+
var descriptor = JSFontDescriptor.descriptorWithFamily(dictionary.family, dictionary.weight, dictionary.style);
|
|
91
|
+
if (descriptor === null){
|
|
92
|
+
if (dictionary.url){
|
|
93
|
+
descriptor = JSURLFontDescriptor.initWithURL(JSURL.initWithString(dictionary.url), dictionary.family, dictionary.weight, dictionary.style);
|
|
94
|
+
JSFontDescriptor.registerDescriptor(descriptor);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (descriptor !== null){
|
|
98
|
+
return JSFont.initWithDescriptor(descriptor, dictionary.size);
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
dictionaryRepresentation: function(){
|
|
104
|
+
return {
|
|
105
|
+
url: this.descriptor instanceof JSURLFontDescriptor ? this._descriptor.url : undefined,
|
|
106
|
+
family: this._descriptor.family,
|
|
107
|
+
weight: this._descriptor.weight,
|
|
108
|
+
style: this._descriptor.style,
|
|
109
|
+
size: this.pointSize
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
|
|
89
113
|
getFullName: function(){
|
|
90
114
|
return this._descriptor.name;
|
|
91
115
|
},
|
|
@@ -187,7 +211,7 @@ JSClass("JSFont", JSObject, {
|
|
|
187
211
|
});
|
|
188
212
|
|
|
189
213
|
JSFont.fontWithFamily = function(family, pointSize, weight, style){
|
|
190
|
-
var descriptor =
|
|
214
|
+
var descriptor = JSFontDescriptor.descriptorWithFamily(family, weight || JSFont.Weight.regular, style || JSFont.Style.normal);
|
|
191
215
|
return JSFont.initWithDescriptor(descriptor, pointSize);
|
|
192
216
|
};
|
|
193
217
|
|
|
@@ -204,12 +228,12 @@ JSFont.registerBundleFonts = function(bundle){
|
|
|
204
228
|
|
|
205
229
|
JSFont._registerFontResource = function(bundle, metadata){
|
|
206
230
|
var descriptor = JSResourceFontDescriptor.initWithMetadata(bundle, metadata);
|
|
231
|
+
JSFontDescriptor.registerDescriptor(descriptor);
|
|
207
232
|
return descriptor;
|
|
208
233
|
};
|
|
209
234
|
|
|
210
|
-
JSFont.
|
|
211
|
-
|
|
212
|
-
JSFont.registerSystemFontResource = function(name){
|
|
235
|
+
JSFont.registerSystemFontResource = function(name, bundle){
|
|
236
|
+
bundle = bundle || JSBundle.mainBundle;
|
|
213
237
|
var ext;
|
|
214
238
|
var extIndex = name.lastIndexOf('.');
|
|
215
239
|
var i, l;
|
|
@@ -221,33 +245,33 @@ JSFont.registerSystemFontResource = function(name){
|
|
|
221
245
|
extGuessed = true;
|
|
222
246
|
ext = "ttf";
|
|
223
247
|
}
|
|
224
|
-
var metadata =
|
|
248
|
+
var metadata = bundle.metadataForResourceName(name, ext);
|
|
225
249
|
if (extGuessed && metadata === null){
|
|
226
250
|
ext = "otf";
|
|
227
|
-
metadata =
|
|
251
|
+
metadata = bundle.metadataForResourceName(name, ext);
|
|
228
252
|
}
|
|
229
|
-
|
|
253
|
+
JSFontDescriptor.system = JSResourceFontDescriptor.descriptorsByName[metadata.font.unique_identifier];
|
|
230
254
|
};
|
|
231
255
|
|
|
232
256
|
JSFont.registerSystemFont = function(familyName, weight, style){
|
|
233
|
-
|
|
257
|
+
JSFontDescriptor.system = JSFontDescriptor.descriptorWithFamily(familyName, weight || JSFont.Weight.regular, style || JSFont.Style.normal);
|
|
234
258
|
};
|
|
235
259
|
|
|
236
260
|
JSFont.registerSystemFontDescriptor = function(descriptor){
|
|
237
|
-
|
|
261
|
+
JSFontDescriptor.system = descriptor;
|
|
238
262
|
};
|
|
239
263
|
|
|
240
264
|
JSFont.unregisterAllFonts = function(){
|
|
241
|
-
|
|
265
|
+
JSFontDescriptor.descriptorsByFamily = {};
|
|
242
266
|
JSResourceFontDescriptor.descriptorsByName = {};
|
|
243
|
-
|
|
267
|
+
JSFontDescriptor.system = null;
|
|
244
268
|
};
|
|
245
269
|
|
|
246
270
|
JSFont.systemFontOfSize = function(pointSize){
|
|
247
|
-
if (
|
|
271
|
+
if (JSFontDescriptor.system === null){
|
|
248
272
|
return null;
|
|
249
273
|
}
|
|
250
|
-
return JSFont.initWithDescriptor(
|
|
274
|
+
return JSFont.initWithDescriptor(JSFontDescriptor.system, pointSize);
|
|
251
275
|
};
|
|
252
276
|
|
|
253
277
|
JSFont.Size = {
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
// #import "UnicodeChar.js"
|
|
19
19
|
// #import "Zlib.js"
|
|
20
20
|
// #import "CoreTypes.js"
|
|
21
|
+
// #import "JSURLSession.js"
|
|
22
|
+
/* global JSFont */
|
|
21
23
|
'use strict';
|
|
22
24
|
|
|
23
25
|
(function(){
|
|
@@ -38,11 +40,11 @@ JSClass("JSFontDescriptor", JSObject, {
|
|
|
38
40
|
unitsPerEM: JSReadOnlyProperty('_unitsPerEM', 0),
|
|
39
41
|
|
|
40
42
|
descriptorWithWeight: function(weight){
|
|
41
|
-
return this;
|
|
43
|
+
return JSFontDescriptor.descriptorWithFamily(this.family, weight, this.style) || this;
|
|
42
44
|
},
|
|
43
45
|
|
|
44
46
|
descriptorWithStyle: function(style){
|
|
45
|
-
return this;
|
|
47
|
+
return JSFontDescriptor.descriptorWithFamily(this.family, this.weight, style) || this;
|
|
46
48
|
},
|
|
47
49
|
|
|
48
50
|
glyphForCharacter: function(character){
|
|
@@ -89,6 +91,29 @@ JSClass("JSFontDescriptor", JSObject, {
|
|
|
89
91
|
|
|
90
92
|
});
|
|
91
93
|
|
|
94
|
+
JSFontDescriptor.system = null;
|
|
95
|
+
|
|
96
|
+
JSFontDescriptor.descriptorsByFamily = {
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
JSFontDescriptor.registerDescriptor = function(descriptor){
|
|
100
|
+
if (!(descriptor._family in JSFontDescriptor.descriptorsByFamily)){
|
|
101
|
+
JSFontDescriptor.descriptorsByFamily[descriptor._family] = {};
|
|
102
|
+
}
|
|
103
|
+
if (!(descriptor._weight in JSFontDescriptor.descriptorsByFamily[descriptor._family])){
|
|
104
|
+
JSFontDescriptor.descriptorsByFamily[descriptor._family][descriptor._weight] = {};
|
|
105
|
+
}
|
|
106
|
+
if (!(descriptor._style in JSFontDescriptor.descriptorsByFamily[descriptor._family][descriptor._weight])){
|
|
107
|
+
JSFontDescriptor.descriptorsByFamily[descriptor._family][descriptor._weight][descriptor._style] = descriptor;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
JSFontDescriptor.descriptorWithFamily = function(family, weight, style){
|
|
112
|
+
var weights = JSFontDescriptor.descriptorsByFamily[family] || {};
|
|
113
|
+
var styles = weights[weight] || {};
|
|
114
|
+
return styles[style] || null;
|
|
115
|
+
};
|
|
116
|
+
|
|
92
117
|
JSClass("JSDataFontDescriptor", JSFontDescriptor, {
|
|
93
118
|
|
|
94
119
|
data: null,
|
|
@@ -131,23 +156,6 @@ JSClass("JSResourceFontDescriptor", JSFontDescriptor, {
|
|
|
131
156
|
widths: null,
|
|
132
157
|
};
|
|
133
158
|
JSResourceFontDescriptor.descriptorsByName[metadata.font.unique_identifier] = this;
|
|
134
|
-
if (!(this._family in JSResourceFontDescriptor.descriptorsByFamily)){
|
|
135
|
-
JSResourceFontDescriptor.descriptorsByFamily[this._family] = {};
|
|
136
|
-
}
|
|
137
|
-
if (!(this._weight in JSResourceFontDescriptor.descriptorsByFamily[this._family])){
|
|
138
|
-
JSResourceFontDescriptor.descriptorsByFamily[this._family][this._weight] = {};
|
|
139
|
-
}
|
|
140
|
-
if (!(this._style in JSResourceFontDescriptor.descriptorsByFamily[this._family][this._weight])){
|
|
141
|
-
JSResourceFontDescriptor.descriptorsByFamily[this._family][this._weight][this._style] = this;
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
descriptorWithWeight: function(weight){
|
|
146
|
-
return JSResourceFontDescriptor.descriptorWithFamily(this.family, weight, this.style) || this;
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
descriptorWithStyle: function(style){
|
|
150
|
-
return JSResourceFontDescriptor.descriptorWithFamily(this.family, this.weight, style) || this;
|
|
151
159
|
},
|
|
152
160
|
|
|
153
161
|
glyphForCharacter: function(character){
|
|
@@ -228,17 +236,87 @@ JSClass("JSResourceFontDescriptor", JSFontDescriptor, {
|
|
|
228
236
|
|
|
229
237
|
});
|
|
230
238
|
|
|
231
|
-
JSResourceFontDescriptor.
|
|
232
|
-
var weights = JSResourceFontDescriptor.descriptorsByFamily[family] || {};
|
|
233
|
-
var styles = weights[weight] || {};
|
|
234
|
-
return styles[style];
|
|
239
|
+
JSResourceFontDescriptor.descriptorsByName = {
|
|
235
240
|
};
|
|
236
241
|
|
|
237
|
-
|
|
238
|
-
};
|
|
242
|
+
JSClass("JSURLFontDescriptor", JSFontDescriptor, {
|
|
239
243
|
|
|
240
|
-
|
|
241
|
-
|
|
244
|
+
url: null,
|
|
245
|
+
|
|
246
|
+
initWithURL: function(url, family, weight, style){
|
|
247
|
+
this.url = url;
|
|
248
|
+
this._family = family;
|
|
249
|
+
this._weight = weight;
|
|
250
|
+
this._style = style;
|
|
251
|
+
this._postScriptName = "%s-%s".sprintf(family.replace(" ", ""), this.face.replce(" ", ""));
|
|
252
|
+
// this._ascender
|
|
253
|
+
// this._descender
|
|
254
|
+
// this._unitsPerEM
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
getData: function(completion, target){
|
|
258
|
+
if (!completion){
|
|
259
|
+
completion = Promise.completion(Promise.rejectNonNullSecondArgument);
|
|
260
|
+
}
|
|
261
|
+
var session = JSURLSession.shared;
|
|
262
|
+
var task = session.dataTaskWithURL(this.url, function(error){
|
|
263
|
+
if (error !== null){
|
|
264
|
+
completion.call(target, null, error);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
try{
|
|
268
|
+
task.response.assertSuccess();
|
|
269
|
+
}catch (e){
|
|
270
|
+
completion.call(target, null, e);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
completion.call(target, task.response.data, null);
|
|
274
|
+
});
|
|
275
|
+
task.resume();
|
|
276
|
+
return completion.promise;
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
face: JSLazyInitProperty(function(){
|
|
280
|
+
if (this.weight === JSFont.Weight.regular){
|
|
281
|
+
if (this.style === JSFont.Style.italic){
|
|
282
|
+
return "Italic";
|
|
283
|
+
}
|
|
284
|
+
return "Regular";
|
|
285
|
+
}
|
|
286
|
+
var name = "";
|
|
287
|
+
switch (this.weight){
|
|
288
|
+
case JSFont.Weight.ultraLight:
|
|
289
|
+
name = "UltraLight";
|
|
290
|
+
break;
|
|
291
|
+
case JSFont.Weight.thin:
|
|
292
|
+
name = "Thin";
|
|
293
|
+
break;
|
|
294
|
+
case JSFont.Weight.light:
|
|
295
|
+
name = "Light";
|
|
296
|
+
break;
|
|
297
|
+
case JSFont.Weight.medium:
|
|
298
|
+
name = "Medium";
|
|
299
|
+
break;
|
|
300
|
+
case JSFont.Weight.semibold:
|
|
301
|
+
name = "SemiBold";
|
|
302
|
+
break;
|
|
303
|
+
case JSFont.Weight.bold:
|
|
304
|
+
name = "Bold";
|
|
305
|
+
break;
|
|
306
|
+
case JSFont.Weight.heavy:
|
|
307
|
+
name = "Heavy";
|
|
308
|
+
break;
|
|
309
|
+
case JSFont.Weight.black:
|
|
310
|
+
name = "Black";
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
if (this.style === JSFont.Style.italic){
|
|
314
|
+
name += " Italic";
|
|
315
|
+
}
|
|
316
|
+
return name;
|
|
317
|
+
}),
|
|
318
|
+
|
|
319
|
+
});
|
|
242
320
|
|
|
243
321
|
var CMap = function(format, data){
|
|
244
322
|
if (this === undefined){
|
|
@@ -55,7 +55,12 @@ JSClass("JSTextAttachment", JSObject, {
|
|
|
55
55
|
},
|
|
56
56
|
|
|
57
57
|
drawInContextAtPoint: function(context, point){
|
|
58
|
-
|
|
58
|
+
var rect = JSRect(point, this._size);
|
|
59
|
+
if (this._image.renderMode === JSImage.RenderMode.template){
|
|
60
|
+
context.fillMaskedRect(rect, this._image);
|
|
61
|
+
}else{
|
|
62
|
+
context.drawImage(this._image, rect);
|
|
63
|
+
}
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
});
|
|
@@ -61,7 +61,10 @@ JSClass("JSTextRun", JSObject, {
|
|
|
61
61
|
// context.fillEllipseInRect(JSRect(this.origin.x - 2.5, this.origin.y - 2.5, 5, 5));
|
|
62
62
|
// context.restore();
|
|
63
63
|
if (this.attachment){
|
|
64
|
+
context.save();
|
|
65
|
+
context.setFillColor(this.attributes.textColor);
|
|
64
66
|
this.attachment.drawInContextAtPoint(context, point);
|
|
67
|
+
context.restore();
|
|
65
68
|
}else{
|
|
66
69
|
context.save();
|
|
67
70
|
context.translateBy(point.x, point.y + this.font.ascender);
|
|
@@ -359,6 +359,34 @@ Object.defineProperties(String.prototype, {
|
|
|
359
359
|
}
|
|
360
360
|
},
|
|
361
361
|
|
|
362
|
+
utf16be: {
|
|
363
|
+
configurable: true,
|
|
364
|
+
enumerable: false,
|
|
365
|
+
value: function String_utf16be(){
|
|
366
|
+
var utf16 = JSData.initWithLength(this.length * 2);
|
|
367
|
+
var dataView = utf16.dataView();
|
|
368
|
+
var j = 0;
|
|
369
|
+
for (var i = 0, l = this.length; i < l; ++i, j += 2){
|
|
370
|
+
dataView.setUint16(j, this.charCodeAt(i));
|
|
371
|
+
}
|
|
372
|
+
return utf16;
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
utf16le: {
|
|
377
|
+
configurable: true,
|
|
378
|
+
enumerable: false,
|
|
379
|
+
value: function String_utf16le(){
|
|
380
|
+
var utf16 = JSData.initWithLength(this.length * 2);
|
|
381
|
+
var dataView = utf16.dataView();
|
|
382
|
+
var j = 0;
|
|
383
|
+
for (var i = 0, l = this.length; i < l; ++i, j += 2){
|
|
384
|
+
dataView.setUint16(j, this.charCodeAt(i), true);
|
|
385
|
+
}
|
|
386
|
+
return utf16;
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
|
|
362
390
|
latin1: {
|
|
363
391
|
enumerable: false,
|
|
364
392
|
value: function String_latin1(){
|
|
@@ -387,6 +415,12 @@ Object.defineProperties(String.prototype, {
|
|
|
387
415
|
if (encoding == String.Encoding.latin1){
|
|
388
416
|
return this.latin1();
|
|
389
417
|
}
|
|
418
|
+
if (encoding == String.Encoding.utf16be){
|
|
419
|
+
return this.utf16be();
|
|
420
|
+
}
|
|
421
|
+
if (encoding == String.Encoding.utf16le){
|
|
422
|
+
return this.utf16le();
|
|
423
|
+
}
|
|
390
424
|
return null;
|
|
391
425
|
}
|
|
392
426
|
},
|
|
@@ -151,7 +151,10 @@ JSClass("UIHTMLTextFrame", JSTextFrame, {
|
|
|
151
151
|
if (attachmentInfo.context.element.parentNode !== attachmentInfo.run.element){
|
|
152
152
|
attachmentInfo.run.element.appendChild(attachmentInfo.context.element);
|
|
153
153
|
}
|
|
154
|
+
attachmentInfo.context.save();
|
|
155
|
+
attachmentInfo.context.setFillColor(attachmentInfo.run.attributes.textColor);
|
|
154
156
|
attachmentInfo.attachment.drawInContextAtPoint(attachmentInfo.context, JSPoint.Zero);
|
|
157
|
+
attachmentInfo.context.restore();
|
|
155
158
|
}
|
|
156
159
|
}else{
|
|
157
160
|
UIHTMLTextFrame.$super.drawInContextAtPoint.call(this, context, point);
|
|
@@ -37,7 +37,9 @@ JSClass("UIHTMLTextRun", JSTextRun, {
|
|
|
37
37
|
// not enough room for a line even when there really is.
|
|
38
38
|
// NOTE: we do NOT want to measure the html element here and cause an expensive layout.
|
|
39
39
|
// Only the UIHTMLTextFrame does the final measuring.
|
|
40
|
-
this.
|
|
40
|
+
if (!this.attachment){
|
|
41
|
+
this._size.height = font.displayLineHeight;
|
|
42
|
+
}
|
|
41
43
|
if (element.childNodes.length > 0 && element.firstChild.nodeType === element.TEXT_NODE){
|
|
42
44
|
this.textNode = element.firstChild;
|
|
43
45
|
}
|
|
@@ -434,6 +434,20 @@ UIHTMLTextTypesetterRunDescriptor.prototype = {
|
|
|
434
434
|
this.span.style.color = '';
|
|
435
435
|
this.span.style.backgroundColor = '';
|
|
436
436
|
this.span.style.pointerEvents = 'all';
|
|
437
|
+
|
|
438
|
+
// Cursor
|
|
439
|
+
var cursor = this.attributes[JSAttributedString.Attribute.cursor];
|
|
440
|
+
if (cursor){
|
|
441
|
+
var cssCursorStrings = cursor.cssStrings();
|
|
442
|
+
for (var i = 0, l = cssCursorStrings.length; i < l; ++i){
|
|
443
|
+
this.span.style.cursor = cssCursorStrings[i];
|
|
444
|
+
if (this.span.style.cursor !== ''){
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}else{
|
|
449
|
+
this.span.style.cursor = '';
|
|
450
|
+
}
|
|
437
451
|
}else{
|
|
438
452
|
this.span.style.display = '';
|
|
439
453
|
this.span.style.width = '';
|
|
@@ -174,11 +174,14 @@ JSClass('UILabel', UIView, {
|
|
|
174
174
|
var attributes = this.attributedText.attributesAtIndex(index);
|
|
175
175
|
this._didDrag = false;
|
|
176
176
|
if (attributes.link){
|
|
177
|
-
var range = this.attributedText.
|
|
178
|
-
var layer =
|
|
179
|
-
layer.
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
var range = this.attributedText.longestRangeOfAttributeAtIndex("link", index);
|
|
178
|
+
var layer = UILabelLinkLayer.init();
|
|
179
|
+
layer.pathColor = (attributes.textColor || this.textColor).colorWithAlpha(0.2);
|
|
180
|
+
var rects = this.layer.textLayoutManager.rectsForCharacterRange(range);
|
|
181
|
+
var i, l;
|
|
182
|
+
for (i = 0, l = rects.length; i < l; ++i){
|
|
183
|
+
layer.addRect(rects[i]);
|
|
184
|
+
}
|
|
182
185
|
this.layer.addSublayer(layer);
|
|
183
186
|
this._mouseDownAction = {
|
|
184
187
|
link: attributes.link,
|
|
@@ -271,11 +274,14 @@ JSClass('UILabel', UIView, {
|
|
|
271
274
|
var index = this.layer.textLayoutManager.characterIndexAtPoint(location);
|
|
272
275
|
var attributes = this.attributedText.attributesAtIndex(index);
|
|
273
276
|
if (attributes.link){
|
|
274
|
-
var range = this.attributedText.
|
|
275
|
-
var layer =
|
|
276
|
-
layer.
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
var range = this.attributedText.longestRangeOfAttributeAtIndex("link", index);
|
|
278
|
+
var layer = UILabelLinkLayer.init();
|
|
279
|
+
layer.pathColor = (attributes.textColor || this.textColor).colorWithAlpha(0.2);
|
|
280
|
+
var rects = this.layer.textLayoutManager.rectsForCharacterRange(range);
|
|
281
|
+
var i, l;
|
|
282
|
+
for (i = 0, l = rects.length; i < l; ++i){
|
|
283
|
+
layer.addRect(rects[i]);
|
|
284
|
+
}
|
|
279
285
|
this.layer.addSublayer(layer);
|
|
280
286
|
this._touchAction = {
|
|
281
287
|
link: attributes.link,
|
|
@@ -379,4 +385,31 @@ JSClass('UILabel', UIView, {
|
|
|
379
385
|
|
|
380
386
|
});
|
|
381
387
|
|
|
388
|
+
JSClass("UILabelLinkLayer", UILayer, {
|
|
389
|
+
|
|
390
|
+
pathColor: null,
|
|
391
|
+
|
|
392
|
+
init: function(){
|
|
393
|
+
UILabelLinkLayer.$super.init.call(this);
|
|
394
|
+
this.path = JSPath.init();
|
|
395
|
+
this.pathColor = JSColor.black;
|
|
396
|
+
this.setNeedsDisplay();
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
addRect: function(rect){
|
|
400
|
+
this.path.addRoundedRect(rect.rectWithInsets(JSInsets(-1, -2)), 2);
|
|
401
|
+
this.frame = this.path.boundingRect;
|
|
402
|
+
},
|
|
403
|
+
|
|
404
|
+
drawInContext: function(context){
|
|
405
|
+
context.save();
|
|
406
|
+
context.translateBy(-this.path.boundingRect.origin.x, -this.path.boundingRect.origin.y);
|
|
407
|
+
context.setFillColor(this.pathColor);
|
|
408
|
+
context.addPath(this.path);
|
|
409
|
+
context.fillPath();
|
|
410
|
+
context.restore();
|
|
411
|
+
},
|
|
412
|
+
|
|
413
|
+
});
|
|
414
|
+
|
|
382
415
|
UILabel.layerClass = UITextLayer;
|