mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-06 00:52:58 +00:00
Merge branch 'jake' of git://github.com/280north/cappuccino into jake
This commit is contained in:
commit
1488f3ed58
3 files changed
+48
-17
No files matched your search
@@ -333,6 +333,8 @@
|
||||
while (count--)
|
||||
{
|
||||
[[_items[count] view] removeFromSuperview];
|
||||
[_items[count] setSelected:NO];
|
||||
|
||||
_cachedItems.push(_items[count]);
|
||||
}
|
||||
|
||||
@@ -351,7 +353,11 @@
|
||||
|
||||
[self addSubview:[_items[index] view]];
|
||||
}
|
||||
|
||||
|
||||
index = CPNotFound;
|
||||
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound)
|
||||
[_items[index] setSelected:YES];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
CPPlatformDidClearBodyElementNotification = @"CPPlatformDidClearBodyElementNotification";
|
||||
CPPlatformWillClearBodyElementNotification = @"CPPlatformWillClearBodyElementNotification";
|
||||
|
||||
var screenNeedsInitialization = NO,
|
||||
mainBodyElement = nil;
|
||||
@@ -91,6 +92,10 @@ var screenNeedsInitialization = NO,
|
||||
|
||||
screenNeedsInitialization = NO;
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPPlatformWillClearBodyElementNotification
|
||||
object:self];
|
||||
|
||||
var bodyElement = [self mainBodyElement];
|
||||
|
||||
// Get rid of any of the original contents of the page.
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
#include "../CoreGraphics/CGGeometry.h"
|
||||
|
||||
|
||||
var DOMSpanElement = nil,
|
||||
DOMIFrameElement = nil,
|
||||
DefaultFont = nil;
|
||||
|
||||
@implementation CPPlatformString : CPBasePlatformString
|
||||
@@ -39,11 +39,20 @@ var DOMSpanElement = nil,
|
||||
selector:@selector(platformDidClearBodyElement:)
|
||||
name:CPPlatformDidClearBodyElementNotification
|
||||
object:CPPlatform];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(platformWillClearBodyElement:)
|
||||
name:CPPlatformWillClearBodyElementNotification
|
||||
object:CPPlatform];
|
||||
}
|
||||
|
||||
+ (void)createDOMElements
|
||||
{
|
||||
var DOMIFrameElement = document.createElement("iframe");
|
||||
if (DOMIFrameElement)
|
||||
return;
|
||||
|
||||
DOMIFrameElement = document.createElement("iframe");
|
||||
// necessary for Safari caching bug:
|
||||
DOMIFrameElement.name = "iframe_" + FLOOR(RAND() * 10000);
|
||||
DOMIFrameElement.style.position = "absolute";
|
||||
@@ -80,11 +89,27 @@ var DOMSpanElement = nil,
|
||||
DOMDivElement.appendChild(DOMSpanElement);
|
||||
}
|
||||
|
||||
+ (void)removeDOMElements
|
||||
{
|
||||
var iframe = DOMIFrameElement,
|
||||
bodyElement = [CPPlatform mainBodyElement];
|
||||
|
||||
DOMIFrameElement = nil;
|
||||
DOMSpanElement = nil;
|
||||
|
||||
bodyElement.removeChild(iframe);
|
||||
}
|
||||
|
||||
+ (void)platformDidClearBodyElement:(CPNotification)aNotification
|
||||
{
|
||||
[self createDOMElements];
|
||||
}
|
||||
|
||||
+ (void)platformWillClearBodyElement:(CPNotification)aNotification
|
||||
{
|
||||
[self removeDOMElements];
|
||||
}
|
||||
|
||||
+ (CGSize)sizeOfString:(CPString)aString withFont:(CPFont)aFont forWidth:(float)aWidth
|
||||
{
|
||||
if (!aFont)
|
||||
@@ -95,35 +120,30 @@ var DOMSpanElement = nil,
|
||||
aFont = DefaultFont;
|
||||
}
|
||||
|
||||
if (!DOMIFrameElement)
|
||||
[self createDOMElements];
|
||||
|
||||
var style = DOMSpanElement.style;
|
||||
|
||||
if (aWidth === NULL)
|
||||
if (!aWidth)
|
||||
{
|
||||
style.width = "";
|
||||
style.whiteSpace = "pre";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
style.width = ROUND(aWidth) + "px";
|
||||
|
||||
if (document.attachEvent)
|
||||
style.wordWrap = "break-word";
|
||||
|
||||
else
|
||||
{
|
||||
style.whiteSpace = "-o-pre-wrap";
|
||||
style.whiteSpace = "-pre-wrap";
|
||||
style.whiteSpace = "-moz-pre-wrap";
|
||||
style.whiteSpace = "pre-wrap";
|
||||
}
|
||||
style.wordWrap = "break-word";
|
||||
style.whiteSpace = "-o-pre-wrap";
|
||||
style.whiteSpace = "-pre-wrap";
|
||||
style.whiteSpace = "-moz-pre-wrap";
|
||||
style.whiteSpace = "pre-wrap";
|
||||
}
|
||||
|
||||
style.font = [aFont cssString];
|
||||
|
||||
if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature))
|
||||
DOMSpanElement.innerText = aString;
|
||||
|
||||
else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature))
|
||||
DOMSpanElement.textContent = aString;
|
||||
|
||||
|
||||
Reference in new issue
Block a user