From ca3a4f9b9c4bdcee0bfb329349b8dd0f2c713ce9 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Wed, 15 Aug 2012 18:12:53 +0100 Subject: [PATCH] Fixed: text field font size while editing was wrong in Internet Explorer. Tested in Internet Explorer 8 and 9. --- AppKit/CPCompatibility.j | 7 +++++++ AppKit/CPTextField.j | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/AppKit/CPCompatibility.j b/AppKit/CPCompatibility.j index 1b05ed895..1791b3567 100644 --- a/AppKit/CPCompatibility.j +++ b/AppKit/CPCompatibility.j @@ -67,6 +67,9 @@ CPHTML5DragAndDropSourceYOffBy1 = 1 << 26; CPSOPDisabledFromFileURLs = 1 << 27; +// element.style.font can be set for an element not in the DOM. +CPInputSetFontOutsideOfDOM = 1 << 28; + var USER_AGENT = "", PLATFORM_ENGINE = CPUnknownBrowserEngine, PLATFORM_FEATURES = 0; @@ -74,6 +77,7 @@ var USER_AGENT = "", // default these features to true PLATFORM_FEATURES |= CPInputTypeCanBeChangedFeature; +PLATFORM_FEATURES |= CPInputSetFontOutsideOfDOM; if (typeof window !== "undefined" && typeof window.navigator !== "undefined") USER_AGENT = window.navigator.userAgent; @@ -99,6 +103,9 @@ else if (typeof window !== "undefined" && window.attachEvent) // Must follow Ope PLATFORM_FEATURES |= CPOpacityRequiresFilterFeature; PLATFORM_FEATURES &= ~CPInputTypeCanBeChangedFeature; + + // Tested in Internet Explore 8 and 9. + PLATFORM_FEATURES &= ~CPInputSetFontOutsideOfDOM; } // WebKit diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 8c7bab766..47f2511ee 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -509,7 +509,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); element.value = _stringValue; element.style.color = [[self currentValueForThemeAttribute:@"text-color"] cssString]; - element.style.font = [font cssString]; + if (CPFeatureIsCompatible(CPInputSetFontOutsideOfDOM)) + element.style.font = [font cssString]; element.style.zIndex = 1000; switch ([self alignment]) @@ -552,6 +553,10 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); _DOMElement.appendChild(element); + // The font change above doesn't work for some browsers if the element isn't already .appendChild'ed. + if (!CPFeatureIsCompatible(CPInputSetFontOutsideOfDOM)) + element.style.font = [font cssString]; + window.setTimeout(function() { element.focus();