Success! Looks like we've fixed this one. According to our records the fix was applied for EXTGWT-2648 in 3.0.6.
  1. #1
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    139
    Vote Rating
    4
    jvahabzadeh is on a distinguished road

      0  

    Default GXT 3.0.2 - InvalidArgument (fontWeight) in the JS, but only in IE8? Is it a bug?

    GXT 3.0.2 - InvalidArgument (fontWeight) in the JS, but only in IE8? Is it a bug?


    All,

    I have some code that I've been developing, and all looks good in Chrome, Firefox, and IE9.

    In IE8, however, I've come across something, and judging by what I'm seeing in the Javascript, it's related to the TextMetrics class.

    The full error message from IE8 is:
    Code:
    Webpage error details
    
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;  Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR  3.5.30729; InfoPath.1)
    Timestamp: Mon, 3 Dec 2012 17:42:23 UTC
    
    
    Message: Could not get the fontWeight property. Invalid argument.
    Line: 35308
    Char: 5
    Code: 0
    URI: http://192.168.0.107/<projectdir>/<projectdiralllowercase>/4E5525A9E3906BCEAAA9FB551C2F9A63.cache.html
    I went into the server in the appropriate directory and looked at that cache.html file. Line 35308 is the last line in the following block (that starts with this$static.com_sencha... etc):
    PHP Code:

    com_sencha_gxt_core_client_util_Size_Size__IIV.prototype =  com_sencha_gxt_core_client_util_Size.prototype = new java_lang_Object;
    _.equals__Ljava_lang_Object_2Z$ = function com_sencha_gxt_core_client_util_Size_equals__Ljava_lang_Object_2Z(obj){
      return 
    com_sencha_gxt_core_client_util_Size_$equals__Lcom_sencha_gxt_core_client_util_Size_2Ljava_lang_Object_2Z(thisobj);
    }
    ;
    _.getClass__Ljava_lang_Class_2$ = function com_sencha_gxt_core_client_util_Size_getClass__Ljava_lang_Class_2(){
      return 
    com_google_gwt_lang_ClassLiteralHolder_Lcom_1sencha_1gxt_1core_1client_1util_1Size_12_1classLit;
    }
    ;
    _.hashCode__I$ = function com_sencha_gxt_core_client_util_Size_hashCode__I(){
      var 
    result;
      
    result 31 this.com_sencha_gxt_core_client_util_Size_height;
      
    result 31 result this.com_sencha_gxt_core_client_util_Size_width;
      return 
    result;
    }
    ;
    _.toString__Ljava_lang_String_2$ = function com_sencha_gxt_core_client_util_Size_toString__Ljava_lang_String_2(){
      return 
    $intern_492 this.com_sencha_gxt_core_client_util_Size_width +  ', height: ' this.com_sencha_gxt_core_client_util_Size_height;
    }
    ;
    _.java_lang_Object_castableTypeMap$ = makeCastMap([Q$com_sencha_gxt_core_client_util_Size]);
    _.com_sencha_gxt_core_client_util_Size_height 0;
    _.com_sencha_gxt_core_client_util_Size_width 0;
    function  
    com_sencha_gxt_core_client_util_TextMetrics_$bind__Lcom_sencha_gxt_core_client_util_TextMetrics_2Lcom_sencha_gxt_core_client_dom_XElement_2V(this$static,  el){
      var 
    keykey$iteratorlmap;
      
    com_google_gwt_dom_client_Element_$addClassName__Lcom_google_gwt_dom_client_Element_2Ljava_lang_String_2V(el,  (!com_sencha_gxt_core_client_resources_CommonStyles_instance &&  (com_sencha_gxt_core_client_resources_CommonStyles_instance = new  com_sencha_gxt_core_client_resources_CommonStyles_CommonStyles__V) ,  $intern_553));
      
    com_google_gwt_core_client_impl_SchedulerImpl_$scheduleDeferred__Lcom_google_gwt_core_client_impl_SchedulerImpl_2Lcom_google_gwt_core_client_Scheduler$ScheduledCommand_2V((com_google_gwt_core_client_impl_SchedulerImpl_$clinit__V()  , com_google_gwt_core_client_impl_SchedulerImpl_INSTANCE), new  com_sencha_gxt_core_client_dom_XElement$2_XElement$2__Lcom_sencha_gxt_core_client_dom_XElement_2V(el));
      
    = new java_util_ArrayList_ArrayList__V;
      
    com_google_gwt_lang_Array_setCheck__Lcom_google_gwt_lang_Array_2ILjava_lang_Object_2Ljava_lang_Object_2(l.java_util_ArrayList_array,  l.java_util_ArrayList_size++, $intern_558);
      
    com_google_gwt_lang_Array_setCheck__Lcom_google_gwt_lang_Array_2ILjava_lang_Object_2Ljava_lang_Object_2(l.java_util_ArrayList_array,  l.java_util_ArrayList_size++, 'fontWeight');
      
    com_google_gwt_lang_Array_setCheck__Lcom_google_gwt_lang_Array_2ILjava_lang_Object_2Ljava_lang_Object_2(l.java_util_ArrayList_array,  l.java_util_ArrayList_size++, 'fontStyle');
      
    com_google_gwt_lang_Array_setCheck__Lcom_google_gwt_lang_Array_2ILjava_lang_Object_2Ljava_lang_Object_2(l.java_util_ArrayList_array,  l.java_util_ArrayList_size++, 'fontFamily');
      
    com_google_gwt_lang_Array_setCheck__Lcom_google_gwt_lang_Array_2ILjava_lang_Object_2Ljava_lang_Object_2(l.java_util_ArrayList_array,  l.java_util_ArrayList_size++, $intern_559);
      
    com_google_gwt_lang_Array_setCheck__Lcom_google_gwt_lang_Array_2ILjava_lang_Object_2Ljava_lang_Object_2(l.java_util_ArrayList_array,  l.java_util_ArrayList_size++, 'textTransform');
      
    com_google_gwt_lang_Array_setCheck__Lcom_google_gwt_lang_Array_2ILjava_lang_Object_2Ljava_lang_Object_2(l.java_util_ArrayList_array,  l.java_util_ArrayList_size++, 'letterSpacing');
      
    map =  com_sencha_gxt_core_client_dom_impl_ComputedStyleImplIE_$getStyleAttribute__Lcom_sencha_gxt_core_client_dom_impl_ComputedStyleImplIE_2Lcom_google_gwt_dom_client_Element_2Ljava_util_List_2Lcom_sencha_gxt_core_shared_FastMap_2((com_sencha_gxt_core_client_dom_XElement$FieldHolder_$clinit__V()  , com_sencha_gxt_core_client_dom_XElement$FieldHolder_computedStyle),  ell);
      for (
    key$iterator =  com_sencha_gxt_core_shared_FastMap$JsMap_$keySet__Lcom_sencha_gxt_core_shared_FastMap$JsMap_2Ljava_util_List_2((new   com_sencha_gxt_core_shared_FastMap$2_FastMap$2__Lcom_sencha_gxt_core_shared_FastMap_2V(map)).com_sencha_gxt_core_shared_FastMap$2_this$0.com_sencha_gxt_core_shared_FastMap_map).iterator__Ljava_util_Iterator_2();  key$iterator.hasNext__Z();) {
        
    key =  com_google_gwt_lang_Cast_dynamicCast__Ljava_lang_Object_2ILjava_lang_Object_2(key$iterator.next__Ljava_lang_Object_2(),  Q$java_lang_String);
         
    this$static.com_sencha_gxt_core_client_util_TextMetrics_el.style[key] =   com_google_gwt_lang_Cast_dynamicCast__Ljava_lang_Object_2ILjava_lang_Object_2(map.com_sencha_gxt_core_shared_FastMap_map[$intern_84  key], Q$java_lang_String);
      }

    How do I get around this?

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    This sounds like an issue. I will open a ticket and move this thread to the proper forums. Thanks for reporting

  3. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Are you able to reproduce this in Dev Mode, perhaps with a working stack trace? It seems probable that this TextMetrics.bind call is being invoked on some invisible object, and IE objects to measuring it, or that it is being bound to something not permitted to have font attributes (say, VML or some other atypical tag).

    In lieu of that, do you know roughly what actions your code is performing when this issue occurs?

    TextMetrics.bind is only internally invoked by XElement.getTextWidth, which in turn is only used by tooltip appearance code. Some initial IE8 testing on the last nightly build at http://staging.sencha.com:8080/examples-dev/ fails to cause this issue, so either it has been fixed in 3.0.3 (available from the support portal), or something more specific is required to cause the issue.

  4. #4
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    139
    Vote Rating
    4
    jvahabzadeh is on a distinguished road

      0  

    Default


    Unfortunately, I don't have a development machine available with IE8 on it at this time, though I'm looking into seeing if I can get a setup like that somewhere. Will post again when I can get such a stack trace, or if I am unable to do so, then I will create a mini test project to deploy so that I can have a sort of bare minimum code to demonstrate this.

  5. #5
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    139
    Vote Rating
    4
    jvahabzadeh is on a distinguished road

      0  

    Default


    Colin,

    I wasn't (yet) able to run in Dev mode on a machine with IE8. I have, however, created some test code, mimicing the original as closely as possible, hopefully without anything missing. Admittedly, it's longer than I'd like for a test example.

    The following code, when GWT compiled and run in a production-type environment, causes the same type of JS error in IE8, with the complaint about fontWeight.

    Here is the code for the main EntryPoint class, LoginScreenIE8Issue.java:
    PHP Code:
    public class LoginScreenIE8Issue implements EntryPoint {

      public static final 
    int SEPARATOR_SIZE textWidthPixels(new FieldLabel().getLabelSeparator() + " ");
      public static final 
    int DEFAULT_COLUMN_LABEL_SIZE textWidthPixels("Username") + SEPARATOR_SIZE;
      List<
    FieldLabelfieldLabelList;
      private 
    int columnLabelSize DEFAULT_COLUMN_LABEL_SIZE;

      protected 
    TextField username = new TextField();
      protected 
    PasswordField password = new PasswordField();
      protected 
    TextButton loginButton = new TextButton("Login");

      public static class 
    LoginLoadHandler implements LoadHandler {
        private 
    CenterLayoutContainer centerLayoutContainer;
        private 
    ContentPanel contentPanel;
        private 
    Image banner;
        private 
    Container loginWidget;
        private 
    Container messageWidget;

        public 
    LoginLoadHandler(CenterLayoutContainer centerLayoutContainerContentPanel contentPanelImage bannerContainer loginWidget,
                                
    Container messageWidget) {
          if((
    centerLayoutContainer == null) || (contentPanel == null) || (banner == null) || (loginWidget == null)) {
            throw new 
    NullPointerException();
          }
          
    this.centerLayoutContainer centerLayoutContainer;
          
    this.contentPanel contentPanel;
          
    this.banner banner;
          
    this.loginWidget loginWidget;
          
    this.messageWidget messageWidget;
        }

        @
    Override
        
    public void onLoad(LoadEvent event) {
          
    contentPanel.setWidth(banner.getWidth() + "px");
          
    int finalHeight = (int)(loginWidget.getOffsetHeight() * 1.2);
          if(
    messageWidget != null) {
            
    int messageLinesHeightPreferred heightEmsToPixels(6messageWidget);
            
    finalHeight finalHeight messageLinesHeightPreferred finalHeight messageLinesHeightPreferred;
            
    messageWidget.setHeight(finalHeight);
          }
          
    loginWidget.getParent().setHeight(finalHeight "px");
          
    centerLayoutContainer.forceLayout();
        }
      }

      public 
    LoginScreenIE8Issue() {
        
    fieldLabelList = new ArrayList<FieldLabel>();
        
    fieldLabelList.add(setupFieldLabel(username"Username"0columnLabelSizetruefalse));
        
    fieldLabelList.add(setupFieldLabel(password"Password"0columnLabelSizetruefalse));
      }

      @
    Override
      
    public void onModuleLoad() {
        
    Viewport viewport = new Viewport();
        
    BorderLayoutContainer borderLayoutContainer = new BorderLayoutContainer();
        
    ContentPanel mainContentPanel = new ContentPanel();
        
    mainContentPanel.add(getWidget());
        
    borderLayoutContainer.setNorthWidget(new Label("header area"));
        
    borderLayoutContainer.setCenterWidget(mainContentPanel);
        
    viewport.add(borderLayoutContainer);
        
    RootPanel.get().add(viewport);
      }

      private 
    Widget getWidget() {
        final 
    CenterLayoutContainer centerLayoutContainer = new CenterLayoutContainer();
        final 
    ContentPanel contentPanel = new ContentPanel(new LoginScreenContentPanelAppearance());
        
    contentPanel.setHeaderVisible(false);
        
    contentPanel.getButtonBar().setPack(BoxLayoutPack.START);
        final 
    VerticalLayoutContainer innerContainer = new VerticalLayoutContainer();
        final 
    Container loginWidget getLoginWidget();
        final 
    VerticalLayoutContainer messageWidget getMessageWidget();
        final 
    Image banner = new Image();
        
    banner.getElement().getStyle().setVerticalAlign(VerticalAlign.TOP);
        
    Widget captionWidget getBannerCaptionWidget();
        
    innerContainer.add(getAssembledBannerAndCaptionWidget(bannercaptionWidget), new VerticalLayoutData(1, -1));
        
    innerContainer.add(getAssembledLoginAndMessageWidget(loginWidgetmessageWidget), new VerticalLayoutData(1, -1));
        
    contentPanel.add(innerContainer);
        
    centerLayoutContainer.add(contentPanel);
        
    banner.addLoadHandler(new LoginLoadHandler(centerLayoutContainercontentPanelbannerloginWidgetmessageWidget));
        
    banner.setUrl("http://www.google.com/logos/2012/thanksgiving12-hp.jpg");
        return 
    centerLayoutContainer;
      }

      private 
    Container getLoginWidget() {
        
    ContentPanel container = new ContentPanel(new LoginInnerContentPanelAppearance());
        
    container.getButtonBar().setPack(BoxLayoutPack.CENTER);
        
    container.setHeaderVisible(false);
        
    VerticalLayoutContainer innerContainer = new VerticalLayoutContainer();
        
    equalizeLabelSizes(fieldLabelList);
        for(
    FieldLabel fieldLabel fieldLabelList) {
          
    innerContainer.add(fieldLabel);
        }
        
    container.add(innerContainer);
        for(
    TextButton button getButtons()) {
          
    container.getButtonBar().add(button);
        }
        return 
    container;
      }

      protected List<
    TextButtongetButtons() {
        List<
    TextButtonresults = new ArrayList<TextButton>();
        
    results.add(loginButton);
        return 
    results;
      }

      protected 
    VerticalLayoutContainer getMessageWidget() {
        
    VerticalLayoutContainer container null;
        
    String message "Some sort of long message here, which will probably require wrapping of lines, but I'm too darn lazy to make it long enough to require scrolling";
        
    boolean hasMessage = ((message != null) && !message.isEmpty());
        if(
    hasMessage) {
          
    container = new VerticalLayoutContainer();
          
    Label messageLabel = new Label(message);
          
    container.add(messageLabel);
          
    container.setScrollMode(ScrollMode.AUTOY);
        }
        return 
    container;
      }

      private 
    Widget getBannerCaptionWidget() {
        
    Label caption = new Label("Insert caption here");
        
    FlowLayoutContainer captionContainer = new FlowLayoutContainer();
        
    captionContainer.add(caption);
        return 
    captionContainer;
      }

      private 
    Widget getAssembledBannerAndCaptionWidget(Image bannerWidget captionWidget) {
        
    VerticalLayoutContainer container = new VerticalLayoutContainer();
        
    container.add(banner, new VerticalLayoutData(-1, -1));
        
    container.add(captionWidget, new VerticalLayoutData(1, -1));
        return 
    container;
      }

      private 
    Widget getAssembledLoginAndMessageWidget(Widget loginWidgetWidget messageWidget) {
        
    HorizontalLayoutContainer container = new HorizontalLayoutContainer();
        
    HorizontalLayoutData data = new HorizontalLayoutData(.5, -1, new Margins(5));
        
    container.add(loginWidgetdata);
        if(
    messageWidget != null) {
          
    container.add(messageWidgetdata);
        }
        return 
    container;
      }

      public static 
    void equalizeLabelSizes(List<FieldLabelfieldLabelList) {
        
    int longestLabel 0;
        
    int tmp;
        for(
    FieldLabel fieldLabel fieldLabelList) {
          
    tmp textWidthPixels(fieldLabel.getText());
          
    longestLabel = (tmp longestLabel) ? tmp longestLabel;
        }
        for(
    FieldLabel fieldLabel fieldLabelList) {
          
    fieldLabel.setLabelWidth(longestLabel);
        }
      }

      public static 
    int widthEmsToPixels(int ems) {
        return 
    widthEmsToPixels(ems, (Element)null);
      }

      public static 
    int heightEmsToPixels(int ems) {
        return 
    heightEmsToPixels(ems, (Element)null);
      }

      public static 
    int widthEmsToPixels(int emsWidget widget) {
        return 
    widthEmsToPixels(emswidget == null ? (Element)null widget.getElement());
      }

      public static 
    int heightEmsToPixels(int emsWidget widget) {
        return 
    heightEmsToPixels(emswidget == null ? (Element)null widget.getElement());
      }

      public static 
    int widthEmsToPixels(int emsElement element) {
        
    TextMetrics.get().bind(element == null XElement.createElement("div") : element);
        
    StringBuilder builder = new StringBuilder("m");
        for(
    int i 0emsi++) {
          
    builder.append("m");
        }
        return 
    TextMetrics.get().getWidth(builder.toString());
      }

      public static 
    int heightEmsToPixels(int emsElement element) {
        
    TextMetrics.get().bind(element == null XElement.createElement("div") : element);
        return (
    ems 1) * TextMetrics.get().getHeight("M");
      }

      public static 
    int textWidthPixels(String text) {
        return 
    textWidthPixels(textfalse, (Element)null);
      }

      public static 
    int textWidthPixels(String textboolean add1em) {
        return 
    textWidthPixels(textadd1em, (Element)null);
      }

      public static 
    int textWidthPixels(String textWidget widget) {
        return 
    textWidthPixels(textfalsewidget == null ? (Element)null widget.getElement());
      }

      public static 
    int textWidthPixels(String textboolean add1emWidget widget) {
        return 
    textWidthPixels(textadd1emwidget == null ? (Element)null widget.getElement());
      }

      public static 
    int textWidthPixels(String textElement element) {
        
    TextMetrics.get().bind(element == null XElement.createElement("div") : element);
        return (int)(
    TextMetrics.get().getWidth(text) * 1.3);
      }

      public static 
    int textWidthPixels(String textboolean add1emElement element) {
        return 
    textWidthPixels(text + (add1em "m" ""), element);
      }

      public static 
    FieldLabel setupFieldLabel(Widget fieldString labelint fieldWidthint labelWidthboolean isFieldWidthInEms,
                                               
    boolean isLabelWidthInEms) {
        
    FieldLabel fieldLabel = new FieldLabel(fieldlabel);
        if(
    labelWidth 0) {
          
    fieldLabel.setLabelWidth(isLabelWidthInEms widthEmsToPixels(labelWidth) : labelWidth);
        }
        if(
    fieldWidth 0) {
          
    field.setPixelSize(isFieldWidthInEms widthEmsToPixels(fieldWidthfield) : fieldWidthfield.getOffsetHeight());
        }
        return 
    fieldLabel;
      }

    LoginInnerContentPanelAppearance.java:
    PHP Code:
    public class LoginInnerContentPanelAppearance extends ContentPanelBaseAppearance {
      public interface 
    LoginInnerContentPanelResources extends ContentPanelResources {

        @
    Source({"com/sencha/gxt/theme/base/client/panel/ContentPanel.css""LoginInnerContentPanel.css"})
        @
    Override
        LoginInnerContentPanelStyle style
    ();

      }

      public interface 
    LoginInnerContentPanelStyle extends ContentPanelStyle {

      }

      public 
    LoginInnerContentPanelAppearance() {
        
    super(GWT.<LoginInnerContentPanelResourcescreate(LoginInnerContentPanelResources.class));
      }

      @
    Override
      
    public HeaderAppearance getHeaderAppearance() {
        return new 
    BlueHeaderAppearance();
      }

    LoginInnerContentPanel.css:
    PHP Code:
    .panel {
      
    bordernone;
    }

    .
    noHeader {
        
    bordernone;
    }
    .
    body {
        
    bordernone;

    LoginScreenContentPanelAppearance.java:
    PHP Code:
    public class LoginScreenContentPanelAppearance extends BlueContentPanelAppearance {

      public interface 
    LoginScreenContentPanelResources extends BlueContentPanelResources {

        @
    Source({"com/sencha/gxt/theme/base/client/panel/ContentPanel.css""com/sencha/gxt/theme/blue/client/panel/BlueContentPanel.css",
                 
    "LoginScreenContentPanel.css"})
        @
    Override
        LoginScreenContentPanelStyle style
    ();

      }

      public interface 
    LoginScreenContentPanelStyle extends BlueContentPanelStyle {

      }

      public 
    LoginScreenContentPanelAppearance() {
        
    super(GWT.<LoginScreenContentPanelResourcescreate(LoginScreenContentPanelResources.class));
      }

    LoginScreenContentPanel.css
    PHP Code:
    .panel {
      
    border-colorwhite;
      
    border-width2em;
      
    border-radius1em;
    }

    .
    body {
        
    bordernone;

    When/if I can get a development environment set up on a machine running IE8, I will try running it in debug mode there as well, but I don't know for sure if I'll be able to get such a setup.

  6. #6
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      1  

    Default


    The best suggestion I have at the moment is that you are trying to get values from a node that isn't attached to the dom, so has none of any of these values:
    Code:
        TextMetrics.get().bind(element == null ? XElement.createElement("div") : element);
    I suspect that if this div were attached, or if you used Document.get().getBody() instead, you'd have better luck.

    It may also be that whatever is being passed in to each of these functions ('element' in that block of code) is not attached, and IE is complaining about that. Drawing first might make this easier.

    That said, I haven't debugged this code myself yet either.

  7. #7
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    139
    Vote Rating
    4
    jvahabzadeh is on a distinguished road

      0  

    Default


    Well, while 3.0.3 did not alleviate the situation, what you'd mentioned about not being attached pointed me in the right direction.

    In the various static methods where I do sizing, I needed to not just create the DIV Xelement, but also attach it. I got the idea of creating the DIV Xelement from the code in TextMetrics, but didn't follow up with the attaching of the element, also in TextMetrics.

    So, I changed from this, for example, in widthEmsToPixels:
    PHP Code:
      public static int widthEmsToPixels(int emsElement element) {
        
    TextMetrics.get().bind(element == null XElement.createElement("div") : element);
        
    StringBuilder builder = new StringBuilder("m");
        for(
    int i 0emsi++) {
          
    builder.append("m");
        }
        return 
    TextMetrics.get().getWidth(builder.toString());
      } 
    to this:
    PHP Code:
      public static int widthEmsToPixels(int emsElement element) {
        
    XElement el element == null XElement.createElement("div") : XElement.as(element);
        if(
    element == null) {
          
    Document.get().getBody().appendChild(el);
          
    el.makePositionable(true);
          
    el.setLeftTop(-10000, -10000);
          
    el.getStyle().setVisibility(Visibility.HIDDEN);
        }
        
    TextMetrics.get().bind(el);
        
    StringBuilder builder = new StringBuilder("m");
        for(
    int i 0emsi++) {
          
    builder.append("m");
        }
        
    int result TextMetrics.get().getWidth(builder.toString());
        if(
    element == null) {
          
    Document.get().getBody().removeChild(el);
        }
        return 
    result;
      } 
    (the Xelement.as was done because I was originally going to attach to the body even if it was NOT null, but was also NOT attached - however, I discarded this idea for the time being)


    Given that this does not cause errors in IE9, Chrome, or Firefox, I guess it might be a bug - but I guess it's a bug that means Sencha needs to work around a peculiar behavior specific to IE8? Not really sure how to classify this anymore...

  8. #8
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    We can add an assertion that the element is attached and visible (has offsetParent), but I don't believe we'll do this attaching for you - this is a case where the div doesn't have the properties you want it to, simply because it isn't attached. Since it isn't attached, and you haven't assigned those properties, IE gets confused (and so throws exceptions for some ungodly reason) when you request those properties.

    So that presents a second fix to this issue - assign values to the element for the styles the textmetrics code needs to do its job.

    We could possibly add a try/catch around this, but that increases compiled code size and causes JITs to not work as hard on code. We also wouldn't be able to reliably report this 'error', since other browsers will just return random guesses for those fonts.

    The real fix is that when you use the bind(element) method, mean it - have something worth binding to. I think you can avoid bind entirely if you don't want to make sure there is something to bind to - this will make this code more efficient anyway, since it won't need to look up those styles (which don't exist anyway)/.

  9. #9
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    It turns out that this wasn't just an error in setup after all, but a case that probably should work, and has been fixed in SVN and the nightly builds. This will be available in the next release.

    The issue was that we were reading a null value out for the font-weight of the un-attached dom element, since no style had been explicitly set for that element. If it had been attached, it would have inherited the setting from the parent. The fix was to interpret the null value as an empty string, and to likewise clear out the setting on the testing element internally.

    As has already been discussed here, it is a viable workaround to simply attach the element to the dom, measure the text, then detach again.

Thread Participants: 2