Bloom.Browser.SaveCustomizedCssRules C# (CSharp) Method

SaveCustomizedCssRules() private method

private SaveCustomizedCssRules ( GeckoStyleSheet userModifiedStyleSheet ) : void
userModifiedStyleSheet GeckoStyleSheet
return void
        private void SaveCustomizedCssRules(GeckoStyleSheet userModifiedStyleSheet)
        {
            try
            {
                /* why are we bothering to walk through the rules instead of just copying the html of the style tag? Because that doesn't
                 * actually get updated when the javascript edits the stylesheets of the page. Well, the <style> tag gets created, but
                 * rules don't show up inside of it. So
                 * this won't work: _editDom.GetElementsByTagName("head")[0].InnerText = userModifiedStyleSheet.OwnerNode.OuterHtml;
                 */
                var styles = new StringBuilder();
                styles.AppendLine("<style title='userModifiedStyles' type='text/css'>");
                foreach (var cssRule in userModifiedStyleSheet.CssRules)
                {
                    styles.AppendLine(cssRule.CssText);
                }
                styles.AppendLine("</style>");
                //Debug.WriteLine("*User Modified Stylesheet in browser:" + styles);
                _pageEditDom.GetElementsByTagName("head")[0].InnerXml = styles.ToString();
            }
            catch (GeckoJavaScriptException jsex)
            {
                /* We are attempting to catch and ignore all JavaScript errors encountered here,
                 * specifically addEventListener errors and JSError (BL-279, BL-355, et al.).
                 */
                Logger.WriteEvent("GeckoJavaScriptException (" + jsex.Message + "). We're swallowing it but listing it here in the log.");
                Debug.Fail("GeckoJavaScriptException(" + jsex.Message + "). In Release version, this would not show.");
            }
        }