/* * CPPlatformString.j * AppKit * * Created by Francisco Tolmasky. * Copyright 2010, 280 North, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "../CoreGraphics/CGGeometry.h" var DOMFixedWidthSpanElement = nil, DOMFlexibleWidthSpanElement = nil, DOMIFrameElement = nil, DefaultFont = nil; @implementation CPPlatformString : CPBasePlatformString { } + (void)bootstrap { [self createDOMElements]; } + (void)createDOMElements { var style; DOMIFrameElement = document.createElement("iframe"); // necessary for Safari caching bug: DOMIFrameElement.name = "iframe_" + FLOOR(RAND() * 10000); DOMIFrameElement.className = "cpdontremove"; style = DOMIFrameElement.style; style.position = "absolute"; style.left = "-100px"; style.top = "-100px"; style.width = "1px"; style.height = "1px"; style.borderWidth = "0px"; style.overflow = "hidden"; style.zIndex = 100000000000; var bodyElement = [CPPlatform mainBodyElement]; bodyElement.appendChild(DOMIFrameElement); var DOMIFrameDocument = (DOMIFrameElement.contentDocument || DOMIFrameElement.contentWindow.document); DOMIFrameDocument.write(''+ '
'); DOMIFrameDocument.close(); // IE needs this wide