 	COLOR_RESOURCE_REQUEST =
 		property: 'color'
 
+	CONTAINS_HTML_RE = /<|&#x/
+
 	DATA =
 		stylesheet: null
 		autoWidth: true
 		autoHeight: true
 		innerElem: null
 		innerElemStyle: null
-		sizeChecks: 0
-		pendingSize: false
-		pendingContent: false
 		uid: 0
+		contentUpdatePending: false
+		containsHTML: false
 
 	exports =
 	DATA: DATA

			auto = @_impl.autoHeight = height is 0
			innerElemStyle.height = if auto then 'auto' else "#{height}px"
			if @_impl.autoWidth or @_impl.autoHeight
				updateSize @
		return

	SHEET = """

			@_impl.innerElemStyle.fontFamily = @_impl.innerElemStyle.fontFamily
		return

	sizeUpdatePending = false

	updateSize = do ->
		windowLoadQueue = []

		textImpl.onFontReady ->
			while elem = windowLoadQueue.pop()
				updateSize elem
			return

		(item) ->
			data = item._impl
			{innerElem} = data

			if not data.autoWidth and not data.autoHeight
				return

			if not isFontReady
				windowLoadQueue.push item

			sizeUpdatePending = true

			if data.autoWidth
				item.width = innerElem.offsetWidth
			if data.autoHeight
				item.height = innerElem.offsetHeight

			sizeUpdatePending = false

			if innerElem.parentNode is hatchery
				implUtils.prependElement data.elem, innerElem
			else
				if item._height is 0
					hatchery.appendChild data.innerElem
					updateSize item
			return

	updateContent = do ->
		pending = false
		queue = []

		updateItem = (item) ->
			data = item._impl
			if data.containsHTML
				data.innerElem.innerHTML = item._text
			else
				data.innerElem.textContent = item._text
			updateSize item
			return

		updateAll = ->
			while item = queue.pop()
				item._impl.contentUpdatePending = false
				updateItem item
			pending = false
			return

		(item) ->
			data = item._impl
			if data.contentUpdatePending
				return

			queue.push item
			data.contentUpdatePending = true

			unless pending
				setImmediate updateAll
				pending = false
			return

	onWidthChange = ->
