1. Christian Krebs
  2. dragonfly-stp-1-cross-browser

Commits

Christian Krebs  committed b147d8b Merge

Synced with mainline.

  • Participants
  • Parent commits 163669c, 4a6e070
  • Branches default

Comments (0)

Files changed (20)

File src/ecma-debugger/dominspection/actions.js

View file
       {
         nav_target.blur();
       }
-      selection.collapse(view_container, 0);
+      selection.removeAllRanges();
       nav_target = new_target;
       raw_delta = new_target.getBoundingClientRect().top - view_container.getBoundingClientRect().top; 
       // delta positive overflow of the container
   this.blur = function(event)
   {
     if (selection)
-      selection.collapse(document.documentElement, 0);
+      selection.removeAllRanges();
     view_container = null;
     view_container_first_child = null;
     nav_target = null;
   {
     var selection = getSelection();
     var range = document.createRange();
-    selection.collapse(view_container, 0);
+    selection.removeAllRanges();
     range.selectNodeContents(view_container);
     selection.addRange(range);
   }

File src/ecma-debugger/dominspection/attrandtextditor.js

View file
     max_content_length = 
       Math.max.apply(null, this.textarea.value.split('\r\n').map(function(item){return item.length})),
     width = this.char_width * max_content_length;
-
-    //this.textarea.style.height = '0px';
-    this.textarea.style.width = ( width < this.max_width ? width : this.max_width )+ "px";
+    this.textarea.style.height = '0px';
+    this.textarea.style.width = ( width < this.max_width ? (width || 1) : this.max_width )+ "px";
     this.textarea.style.height = this.textarea.scrollHeight + 'px';
   }
 

File src/ecma-debugger/dominspection/templates.js

View file
 
   this._inspected_dom_node_markup_style= function(model, target, editable)
   {
-
     var data = model.getData();
     var tree = "<div class='padding table-cell dom'" +
                (editable ? " edit-handler='edit-dom'" : "") + 
                       " style='margin-left:" + 16 * node[DEPTH] + "px;' " +
                       "ref-id='" + node[ID] + "' handler='spotlight-node'>" +
                       (node[CHILDREN_LENGTH] ?
-                          "<input handler='get-children' type='button' class='open'>" : '') +
+                          "<input handler='get-children' type='button' class='open' />" : '') +
                           "<node>&lt;" + node_name + attrs + "&gt;</node>" +
                       (is_debug && (" <d>[" + node[ID] + "]</d>" ) || "") +
                       "</div>";
                       " style='margin-left:" + 16 * node[DEPTH] + "px;' " +
                       "ref-id='" + node[ID] + "' handler='spotlight-node'>" +
                       (children_length ?
-                          "<input handler='get-children' type='button' class='close'>" : '') +
+                          "<input handler='get-children' type='button' class='close' />" : '') +
                           "<node>&lt;" + node_name + attrs + (children_length ? '' : '/') + "&gt;</node>" +
                       (is_debug && (" <d>[" + node[ID] + "]</d>" ) || "") +
                       "</div>";
                     " style='margin-left:" + 16 * node[DEPTH] + "px;' " +
                     "ref-id='"+node[ID] + "' handler='spotlight-node'>" +
                     (children_length && !has_only_one_child ?
-                      "<input handler='get-children' type='button' class='open'>" : '') +
+                      "<input handler='get-children' type='button' class='open' />" : '') +
                     "<node>" + node_name + attrs + "</node>" +
                     "</div>";
           }
                     " style='margin-left:" + 16 * node[DEPTH] + "px;' " +
                     "ref-id='"+node[ID] + "' handler='spotlight-node'>" +
                     (node[CHILDREN_LENGTH] ?
-                      "<input handler='get-children' type='button' class='close'>" : '') +
+                      "<input handler='get-children' type='button' class='close' />" : '') +
                     "<node>" + node_name + attrs + "</node>" +
                     "</div>";
           }

File src/ecma-debugger/js-source-view.js

View file
       id: 'test-line-height',
       property: 'lineHeight',
       target: 'line-height',
-      getValue: function(){return parseInt(document.getElementById(this.id).currentStyle[this.property])}
+      getValue: function(){return parseInt(window.getComputedStyle(document.getElementById(this.id), null).getPropertyValue(this.property))}
     },
     {
       id: 'test-scrollbar-width',

File src/ecma-debugger/objectinspection.6.0/inspectablejsobject.js

View file
 
   this.handle_get_objects = function(status, message, rt_id, type)
   {
-    const STATUS = 0, OBJECT_VALUE = 3, OBJECT_ID = 0;
+    const STATUS = 0,
+    OBJECT_CHAIN_LIST = 0,
+    OBJECT_LIST = 0,
+    PROPERTY_LIST = 1,
+    OBJECT_VALUE = 3,
+    OBJECT_ID = 0;
+    
     if (status)
       opera.postError(ui_strings.DRAGONFLY_INFO_MESSAGE +
                       "static method InspectableJSObject.handle_create_filter failed, " +
                       status + ', ' + JSON.stringify(message));
     else
     {
-      const
-      OBJECT_CHAIN_LIST = 0,
-      OBJECT_LIST = 0,
-      PROPERTY_LIST = 1,
-      OBJECT_VALUE = 3,
-      OBJECT_ID = 0;
-
       var obj_list = (message &&
         (message = message[OBJECT_CHAIN_LIST]) &&
         (message = message[0]) &&
     NAME = 0,
     PROPERTY_TYPE = 1,
     PROPERTY_VALUE = 2,
-    OBJECT_VALUE = 3;
+    OBJECT_VALUE = 3,
+    FILTERED_PROPS = 1;
 
     var
     object = null,
           filters.push([class_name, filter]);
       }
     }
-    const NAME = 0, FILTERED_PROPS = 1;
     // filter out Element
     var is_equal = function(a, b)
     {

File src/ecma-debugger/objectinspection.6.0/templates.js

View file
   OBJECT_VALUE = 3,
   // added fields
   MAX_VALUE_LENGTH = 30,
-  STYLE_EXPANDED = "style='background-position: 0px -11px') ";
+  STYLE_EXPANDED = "style='background-position: 0px -11px' ";
 
   /* private */
 

File src/lib/http_interface.js

View file
       var status = parseInt(xhr.getResponseHeader("X-Scope-Message-Status"));
       var tag = parseInt(xhr.getResponseHeader("X-Scope-Message-Tag"));
       var message = eval(xhr.responseText);
-      try
-      {
-        _receive_callback(service, message, command, status, tag);
-      }
-      catch(e)
-      {
-        opera.postError(
-          'failed to handle message\n' +
-          '  service: ' + service + '\n' +
-          '  command: ' + command + '\n' +
-          '  message: ' + JSON.stringify(message) + '\n' +
-          '  ------------------------------------\n' +
-          '  error message: ' + e.message + '\n' +
-          '  ------------------------------------\n' +
-          '  error stacktrace: \n' + e.stacktrace + '\n' +
-          '  ------------------------------------\n'
-          )
-      }
+      _receive_callback(service, message, command, status, tag);
     }
     _proxy.GET( "/get-message?time=" + new Date().getTime(), _receive_dragonkeeper);
   }
     // message format: "[" SERVICE "," COMMAND_ID "," STATUS "," TAG "," PAYLOAD "]"
     const SERVICE = 0, COMMAND_ID = 1, STATUS = 2, TAG = 3, PAYLOAD = 4;
     message = JSON.parse(message.data);
-    try
-    {
-      _receive_callback(message[SERVICE], 
-                        message[PAYLOAD], 
-                        message[COMMAND_ID], 
-                        message[STATUS], 
-                        message[TAG]);
-    }
-    catch(e)
-    {
-      opera.postError(
-        'failed to handle message\n' +
-        '  service: ' + message[SERVICE] + '\n' +
-        '  command: ' + message[COMMAND_ID] + '\n' +
-        '  message: ' + JSON.stringify(message[PAYLOAD]) + '\n' +
-        '  ------------------------------------\n' +
-        '  error message: ' + e.message + '\n' +
-        '  ------------------------------------\n' +
-        '  error stacktrace: \n' + e.stacktrace + '\n' +
-        '  ------------------------------------\n'
-        )
-    }
+    _receive_callback(message[SERVICE], 
+                      message[PAYLOAD], 
+                      message[COMMAND_ID], 
+                      message[STATUS], 
+                      message[TAG]);
   }
 
   var _scopeTransmit_STP_0 = function(service, message, command_id, tag)
     self.scopeTransmit = _scopeTransmit_STP_1;
     _finalize_on_stp_version();
   }
-  
+
   var _setup_stp_1_web_socket = function()
   {
     _socket = new WebSocket("ws://" + window.location.host + "/stp-1-channel");

File src/lib/test_framework.js

View file
             "<textarea rows='10' id='proto-message'>[]</textarea>" +
             "<p class='right-aligned'><input type='button' value='send' data-service='" + this._selected_service + "'" +
             " data-command='" + event.target.textContent + 
-            "' id = 'test-send-command' ></p>" +
+            "' id = 'test-send-command' /></p>" +
             "<h3>response</h3><pre class='definition'></pre>" +
               "<p class='right-aligned'><label>pretty print message " +
                 "<input type='checkbox'" +
                   (cookies.get('pretty-print-message') == 'true' ? " checked='checked' " : "" ) +
-                  " id='pretty-print-message'>" +
+                  " id='pretty-print-message' />" +
                 "</label></p>";
           var pres = message_container.getElementsByTagName('pre');
           var service = window.services[this._dashed_name(this._selected_service)];

File src/scripts/dom.js

View file
-/**
+if (!window.opera)
+{
+  window.opera = 
+  {
+    postError: function(a){console.log(a);},
+    stpVersion: true
+  };
+  // switch keypress with keydown for other browsers
+  (function(add_event_listener)
+  {
+    Node.prototype.addEventListener = function(name, listener, is_capturing)
+    {
+      add_event_listener.call(this, 
+                              name == 'keypress' ? 'keydown' : name, 
+                              listener, is_capturing);
+    }
+  })(Node.prototype.addEventListener);
+}
+
+if (document.createElementNS && 
+    document.createElement('div').namespaceURI != 'http://www.w3.org/1999/xhtml')
+{  
+  Document.prototype.createElement = document.createElement = function(name)
+  {
+    return this.createElementNS('http://www.w3.org/1999/xhtml', name);
+  };
+}
+
+if (!Element.prototype.contains)
+{
+  Element.prototype.contains = function(ele)
+  {
+    if (ele == this)
+      return true;
+    var all = this.getElementsByTagName('*'), i = 0, cur = null;
+    for (; (cur = all[i]) && cur != ele; i++);
+    return Boolean(cur);
+  }
+}
+
+/**
  * @fileoverview
  * Helper function prototypes related to DOM objects and the DOM
  * <strong>fixme: Christian should document the template syntax</strong>
 'PlaceholderFeature',
 'AutoScrollHeightFeature');
 
+

File src/style/element_style.js

View file
   ORIGIN = 0,
   INDEX_LIST = 1,
   VALUE_LIST = 2,
-  PRIORITY_LIST = 3,
   STATUS_LIST = 4,
   SELECTOR = 5,
   SPECIFICITY = 6,

File src/style/stylesheets.js

View file
   ORIGIN = 0,
   INDEX_LIST = 1,
   VALUE_LIST = 2,
-  PRIORITY_LIST = 3,
   STATUS_LIST = 4,
   SELECTOR = 5,
   SPECIFICITY = 6,
                  (!is_disabled ? " checked='checked'" : "") +
                  " handler='enable-disable'" +
                  " data-property='" + prop + "'" +
-                 " data-rule-id='" + rule_id + "'>"
+                 " data-rule-id='" + rule_id + "' />"
                : "") +
            "<key>" + prop + "</key>: " + // TODO: rename "key" to "property"
            "<value>" + value + (is_important ? MARKUP_IMPORTANT : "") + 

File src/ui-scripts/colorpicker.js

View file
   {
     var color = this._cs.xyz(this._cur_x, this._cur_y, this._cur_z);
     this._ele_sample_color.style.backgroundColor = 
-      this._has_alpha ? color.rgba : color.hex;
+      this._has_alpha ? color.rgba : color.hhex;
   }
 
   // update the position of the slider foe the lpha value

File src/ui-scripts/colorpickertemplates.js

View file
     return (
     ['svg:svg',
       this.svg_gradient(x, y, width, height, colors, rotate, mask),
-      'viewBox', '0 0 100% 100%'
+      'width', '100%',
+      'height', '100%',
+      'version', '1.1'
     ]);
   };
   
     ['svg:svg',
       this.svg_gradient(x, y, width, height, top_colors),
       this.svg_gradient(x, y, width, height, bottom_colors, false, true),
-      'viewBox', '0 0 100% 100%'
+      'width', '100%',
+      'height', '100%',
+      'version', '1.1'
     ]);
   };
   
           'fill', '#fff', 
         ],
         'viewBox', '0 0 100px 36px',
+        'version', '1.1',
         'class', 'color-sample-alpha-bg'
       ] : [],
       ['div', 
           'stroke', '#000', 
           'stroke-width', '1'
         ],
-      'viewBox', rotate ? '0 0 20 80' : '0 0 80 20'
+      'viewBox', rotate ? '0 0 20 80' : '0 0 80 20',
+      'version', '1.1'
     ]);
   }
   
         'hsl(0, 0%, 20%)', 
         'stroke-width', '1'
       ],
-      'viewBox', '0 0 20 20'
+      'viewBox', '0 0 20 20',
+      'version', '1.1'
     ]);
   }
   

File src/ui-scripts/keyboard_handler.js

View file
       {
         // in the keypress events the which property for function keys is set to 0
         // this check lets pass e.g. '(' on a AZERTY keyboard
-        if( event.which != 0 /* && event.which < 0xE000 */ )
+        if (!is_function_key(event))
         {
           break;
         }
             ( event.ctrlKey ? '1' : '0' ) +
             ( event.altKey ? '1' : '0' ) +
             keyCode.toString();
-        if (key_id in action_map
-            && !__key_handler[action_id = action_map[key_id]](event, action_id))
+        action_id = action_map[key_id];
+        if (action_id && !__key_handler[action_id](event, action_id))
         {
           event.preventDefault();
           event.stopPropagation();
       }
     }
   };
+  
+  var is_function_key = function(event)
+  {
+    return event.which === 0;
+  };
+  
+  if (window.chrome)
+    is_function_key = function(event)
+    {
+      return event.keyIdentifier.indexOf('U+') != 0;
+    };
 
   var clear_current_handler = function()
   {

File src/ui-scripts/slider.js

View file
 
   this._onmousemove = function(event)
   {
-    this._focus_catcher.focus();
     var value = 0, box = this._ref_element.getBoundingClientRect();
     if (this._has_x)
     {
       document.addEventListener('mouseup', this._onmouseup_bound, false);
       this._interval = window.setInterval(this._onmousemoveinterval_bound, UPDATE_INTERVAL);
       this._is_active = true;
+      event.preventDefault();
     }
   }
 
     {
       this._ref_element.removeEventListener('mousedown', this._onmousedown_bound, false);
       document.removeEventListener('DOMNoderemoved', this._onremove_bound, false);
-      this._focus_catcher.parentNode.removeChild(this._focus_catcher);
-      this._focus_catcher = null;
       this._ref_element = null;
       this._element = null;
       this._onmousedown_bound = null;
       container.render(window.templates.slider(slider_base_class, slider_class, config.slider_template));
       this._ref_element = container.getElementsByClassName(slider_base_class)[0];
       this._element = container.getElementsByClassName(slider_class)[0];
-      this._focus_catcher = document.documentElement.render(window.templates.slider_focus_catcher());
       box = this._ref_element.getBoundingClientRect();
       
       if (config.onxy)

File src/ui-scripts/ui_framework.js

View file
   [
     {
       id: 'test-line-height',
-      property: 'lineHeight',
+      property: 'line-height',
       target: 'js-source-line-height',
-      getValue: function(){return parseInt(document.getElementById(this.id).currentStyle[this.property])}
+      getValue: function()
+      {
+        return parseInt(window.getComputedStyle(document.getElementById(this.id), null).getPropertyValue(this.property));
+      }
     },
     {
       id: 'test-scrollbar-width',

File src/ui-scripts/window.js

View file
         current_target = ui_windows[event.target.parentNode.id] || {};
         document.addEventListener('mousemove', store_event, false);
         document.addEventListener('mouseup', mouseup, false);
+        event.preventDefault();
       }
     }
   },

File src/ui-style/debugger_style.css

View file
 .test-messages textarea
 {
   box-sizing: border-box;
+  -webkit-box-sizing: border-box;
   display: block;
   width: 100%;
   margin: 0;

File src/ui-style/ui.css

View file
 
 
 /* editing */
+textarea
+{
+   resize: none;
+}
 
 textarea-container {
   display: block;

File test-scripts/test-scripts/get-next-with-filter.html

View file
   margin: 0;
   margin-left: 20px;
 }
+
 ::selection
 {
   background-color: #0f0;
 }
+
 </style>
-<script src="../../src/scripts/dom.js"/>
+<script src="../../src/scripts/dom.js"></script>
 <script>
 
-onload = function()
+window.onload = function()
 {
   window.selection = getSelection();
   window.range = document.createRange();
 
 var selectEle = function(ele)
 {
-  selection.collapse(document.body, 0)
+  if (!selection.isCollapsed)
+    selection.removeAllRanges();
   range.selectNodeContents(ele.firstChild);
   selection.addRange(range);
   active_ele = ele;
 
 var filter = function(ele){ return true }; // "div" == ele.nodeName.toLowerCase();
 
-document.onkeypress = function(event)
+document.addEventListener('keypress', function(event)
 {
   switch(event.keyCode)
   {
       break;
     }
   }
-}
+}, false);
 
 </script>