Title: [113440] trunk/Source/WebCore
Revision
113440
Author
[email protected]
Date
2012-04-06 08:30:18 -0700 (Fri, 06 Apr 2012)

Log Message

Web Inspector: CodeGeneratorInspector.py: completely switch all domains to 'strict' mode
https://bugs.webkit.org/show_bug.cgi?id=83332

Patch by Peter Rybin <[email protected]> on 2012-04-06
Reviewed by Pavel Feldman.

Hardcoded list of domains is removed from generator. Partial domain sorting is dropped as unneeded.
Types with open propery list are introduced: validator allows undocumented properties for them.

Timeline domain code is patched to do runtimeCast in the last moment because true switching to
type-safe interfaces should take significant time and should be done separately.

* inspector/CodeGeneratorInspector.py:
(Generator.go):
(Generator.process_event):
(Generator.process_command):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::willSendResourceRequest):
(WebCore::InspectorTimelineAgent::innerAddRecordToTimeline):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (113439 => 113440)


--- trunk/Source/WebCore/ChangeLog	2012-04-06 15:29:10 UTC (rev 113439)
+++ trunk/Source/WebCore/ChangeLog	2012-04-06 15:30:18 UTC (rev 113440)
@@ -1,5 +1,26 @@
 2012-04-06  Peter Rybin  <[email protected]>
 
+        Web Inspector: CodeGeneratorInspector.py: completely switch all domains to 'strict' mode
+        https://bugs.webkit.org/show_bug.cgi?id=83332
+
+        Reviewed by Pavel Feldman.
+
+        Hardcoded list of domains is removed from generator. Partial domain sorting is dropped as unneeded.
+        Types with open propery list are introduced: validator allows undocumented properties for them.
+
+        Timeline domain code is patched to do runtimeCast in the last moment because true switching to
+        type-safe interfaces should take significant time and should be done separately.
+
+        * inspector/CodeGeneratorInspector.py:
+        (Generator.go):
+        (Generator.process_event):
+        (Generator.process_command):
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::willSendResourceRequest):
+        (WebCore::InspectorTimelineAgent::innerAddRecordToTimeline):
+
+2012-04-06  Peter Rybin  <[email protected]>
+
         Web Inspector: CodeGeneratorInspector.py: stop accepting raw InspectorObject in generated setters
         https://bugs.webkit.org/show_bug.cgi?id=83327
 
@@ -72,6 +93,63 @@
         (.diff-container .webkit-removed-line.webkit-line-number):
         (.diff-container .webkit-changed-line.webkit-line-number):
 
+2012-04-06  Peter Rybin  <[email protected]>
+
+        Web Inspector: CodeGeneratorInspector.py: stop accepting raw InspectorObject in generated setters
+        https://bugs.webkit.org/show_bug.cgi?id=83327
+
+        Reviewed by Pavel Feldman.
+
+        Generator fixed to have strict types in generated setter methods.
+
+        Client code is switched from InspectorObject's and String's to generated types where
+        needed.
+
+        * inspector/CodeGeneratorInspector.py:
+        (AdHocTypeContext):
+        (format_setter_value_expression):
+        * inspector/ConsoleMessage.cpp:
+        (WebCore::messageSourceValue):
+        (WebCore::messageTypeValue):
+        (WebCore::messageLevelValue):
+        (WebCore::ConsoleMessage::addToFrontend):
+        * inspector/InspectorApplicationCacheAgent.cpp:
+        (WebCore::InspectorApplicationCacheAgent::buildArrayForApplicationCacheResources):
+        (WebCore::InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource):
+        * inspector/InspectorApplicationCacheAgent.h:
+        (InspectorApplicationCacheAgent):
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::asInspectorStyleSheet):
+        (WebCore::InspectorCSSAgent::viaInspectorStyleSheet):
+        (WebCore::InspectorCSSAgent::detectOrigin):
+        * inspector/InspectorCSSAgent.h:
+        (InspectorCSSAgent):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::buildObjectForNode):
+        * inspector/InspectorIndexedDBAgent.cpp:
+        (WebCore):
+        * inspector/InspectorMemoryAgent.cpp:
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::buildObjectForFrameTree):
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::buildObjectForTiming):
+        (WebCore::buildObjectForCachedResource):
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyle::buildObjectForStyle):
+        (WebCore::InspectorStyleSheet::create):
+        (WebCore::InspectorStyleSheet::InspectorStyleSheet):
+        (WebCore::InspectorStyleSheet::buildObjectForRule):
+        (WebCore::InspectorStyleSheet::resourceStyleSheetText):
+        (WebCore::InspectorStyleSheet::buildArrayForRuleList):
+        (WebCore::InspectorStyleSheetForInlineStyle::create):
+        (WebCore::InspectorStyleSheetForInlineStyle::InspectorStyleSheetForInlineStyle):
+        * inspector/InspectorStyleSheet.h:
+        (InspectorCSSId):
+        (WebCore::InspectorCSSId::asProtocolValue): method is made template as now it returns 2 formally different types.
+        (InspectorStyleSheet):
+        (WebCore::InspectorStyleSheet::canBind):
+        (InspectorStyleSheetForInlineStyle):
+
 2012-04-06  Pavel Feldman  <[email protected]>
 
         Web Inspector: highlight diff in the gutter, not in the line content.
@@ -91,6 +169,23 @@
 
 2012-04-06  Pavel Feldman  <[email protected]>
 
+        Web Inspector: highlight diff in the gutter, not in the line content.
+        https://bugs.webkit.org/show_bug.cgi?id=83371
+
+        Reviewed by Yury Semikhatsky.
+
+        Now that the editing mode is enabled by default, diff highlighting gets annoying.
+        I am moving it to the gutter (same decoration as before, but now coloring gutter only).
+
+        * inspector/front-end/TextViewer.js:
+        (WebInspector.TextEditorGutterPanel.prototype.textChanged):
+        * inspector/front-end/textViewer.css:
+        (.diff-container .webkit-added-line.webkit-line-number):
+        (.diff-container .webkit-removed-line.webkit-line-number):
+        (.diff-container .webkit-changed-line.webkit-line-number):
+
+2012-04-06  Pavel Feldman  <[email protected]>
+
         Web Inspector: remove url from the saved urls map before the save action.
         https://bugs.webkit.org/show_bug.cgi?id=83364
 

Modified: trunk/Source/WebCore/inspector/CodeGeneratorInspector.py (113439 => 113440)


--- trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2012-04-06 15:29:10 UTC (rev 113439)
+++ trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2012-04-06 15:30:18 UTC (rev 113440)
@@ -57,15 +57,12 @@
 
 
 TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.PropertyDescriptor",
-                                         "Debugger.FunctionDetails", "Debugger.CallFrame"])
+                                         "Debugger.FunctionDetails", "Debugger.CallFrame",
+                                         # This should be a temporary hack. TimelineEvent should be created via generated C++ API.
+                                         "Timeline.TimelineEvent"])
 
-STRICT_ENABLED_DOMAINS = ["Console", "DOMDebugger",
-                          "CSS", "Debugger", "DOM", "Network", "Page", "Runtime",
-                          "Inspector", "Memory", "Database",
-                          "IndexedDB", "DOMStorage", "ApplicationCache",
-                          "FileSystem", "Profiler", "Worker"]
+TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset(["Timeline.TimelineEvent"])
 
-
 cmdline_parser = optparse.OptionParser()
 cmdline_parser.add_option("--output_h_dir")
 cmdline_parser.add_option("--output_cpp_dir")
@@ -1289,6 +1286,8 @@
                                     writer.newline("    static void assertCorrectValue(InspectorValue* value);\n")
                                     writer.append("#endif  // %s\n" % VALIDATOR_IFDEF_NAME)
 
+                                    closed_field_set = (context_domain_name + "." + class_name) not in TYPES_WITH_OPEN_FIELD_LIST_SET
+
                                     validator_writer = generate_context.validator_writer
                                     validator_writer.newline("void %s%s::assertCorrectValue(InspectorValue* value)\n" % (helper.full_name_prefix_for_impl, class_name))
                                     validator_writer.newline("{\n")
@@ -1304,7 +1303,8 @@
                                         validator_writer.newline("        %s(%s->second.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name))
                                         validator_writer.newline("    }\n")
 
-                                    validator_writer.newline("    int foundPropertiesCount = %s;\n" % len(resolve_data.main_properties))
+                                    if closed_field_set:
+                                        validator_writer.newline("    int foundPropertiesCount = %s;\n" % len(resolve_data.main_properties))
 
                                     for prop_data in resolve_data.optional_properties:
                                         validator_writer.newline("    {\n")
@@ -1313,11 +1313,13 @@
                                         validator_writer.newline("        %s = object->find(\"%s\");\n" % (it_name, prop_data.p["name"]))
                                         validator_writer.newline("        if (%s != object->end()) {\n" % it_name)
                                         validator_writer.newline("            %s(%s->second.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name))
-                                        validator_writer.newline("            ++foundPropertiesCount;\n")
+                                        if closed_field_set:
+                                            validator_writer.newline("            ++foundPropertiesCount;\n")
                                         validator_writer.newline("        }\n")
                                         validator_writer.newline("    }\n")
 
-                                    validator_writer.newline("    ASSERT(foundPropertiesCount == object->size());\n")
+                                    if closed_field_set:
+                                        validator_writer.newline("    ASSERT(foundPropertiesCount == object->size());\n")
                                     validator_writer.newline("}\n\n\n")
 
                                 writer.newline("};\n\n")
@@ -2429,7 +2431,6 @@
 global_forward_listener = resolve_all_types()
 
 
-
 def get_annotated_type_text(raw_type, annotated_type):
     if annotated_type != raw_type:
         return "/*%s*/ %s" % (annotated_type, raw_type)
@@ -2484,10 +2485,12 @@
             Generator.frontend_domain_class_lines,
             Generator.frontend_method_list,
             Generator.method_handler_list,
-            Generator.method_name_enum_list]
+            Generator.method_name_enum_list,
+            Generator.backend_constructor_init_list,
+            Generator.backend_virtual_setters_list,
+            Generator.backend_setters_list,
+            Generator.backend_field_list]
 
-        strict_enabled_domains_unused = set(STRICT_ENABLED_DOMAINS)
-
         for json_domain in json_api["domains"]:
             domain_name = json_domain["domain"]
             domain_name_lower = domain_name.lower()
@@ -2530,46 +2533,15 @@
             Generator.backend_agent_interface_list.append("        virtual ~%s() { }\n" % agent_interface_name)
             Generator.backend_agent_interface_list.append("    };\n\n")
 
-            if domain_guard:
-                for l in reversed(first_cycle_guardable_list_list):
-                    domain_guard.generate_close(l)
-            Generator.backend_js_domain_initializer_list.append("\n")
-
-            strict_enabled_domains_unused.discard(domain_name)
-
-        if strict_enabled_domains_unused:
-            raise Exception("Unknown domains listed: %s" % strict_enabled_domains_unused)
-
-        sorted_json_domains = list(json_api["domains"])
-        sorted_json_domains.sort(key=lambda o: o["domain"])
-
-        sorted_cycle_guardable_list_list = [
-            Generator.backend_constructor_init_list,
-            Generator.backend_virtual_setters_list,
-            Generator.backend_setters_list,
-            Generator.backend_field_list]
-
-        for json_domain in sorted_json_domains:
-            domain_name = json_domain["domain"]
-
-            domain_fixes = DomainNameFixes.get_fixed_data(domain_name)
-            domain_guard = domain_fixes.get_guard()
-
-            if domain_guard:
-                for l in sorted_cycle_guardable_list_list:
-                    domain_guard.generate_open(l)
-
-            agent_interface_name = Capitalizer.lower_camel_case_to_upper(domain_name) + "CommandHandler"
-
-            agent_field_name = domain_fixes.agent_field_name
             Generator.backend_constructor_init_list.append("        , m_%s(0)" % agent_field_name)
             Generator.backend_virtual_setters_list.append("    virtual void registerAgent(%s* %s) = 0;" % (agent_interface_name, agent_field_name))
             Generator.backend_setters_list.append("    virtual void registerAgent(%s* %s) { ASSERT(!m_%s); m_%s = %s; }" % (agent_interface_name, agent_field_name, agent_field_name, agent_field_name, agent_field_name))
             Generator.backend_field_list.append("    %s* m_%s;" % (agent_interface_name, agent_field_name))
 
             if domain_guard:
-                for l in reversed(sorted_cycle_guardable_list_list):
+                for l in reversed(first_cycle_guardable_list_list):
                     domain_guard.generate_close(l)
+            Generator.backend_js_domain_initializer_list.append("\n")
 
         RawTypes.generate_validate_methods(Writer(Generator.validator_impl_raw_types_list, ""))
 
@@ -2577,8 +2549,6 @@
     def process_event(json_event, domain_name, frontend_method_declaration_lines):
         event_name = json_event["name"]
 
-        strict_mode = domain_name in STRICT_ENABLED_DOMAINS
-
         parameter_list = []
         method_line_list = []
         backend_js_event_param_list = []
@@ -2605,14 +2575,8 @@
                     type_model = type_model.get_optional()
                     raw_type_model = raw_type_model.get_optional()
 
-                if strict_mode:
-                    # All types are strict.
-                    annotated_type = type_model.get_input_param_type_text()
-                    mode_type_binding = param_type_binding
-                else:
-                    # All types are raw.
-                    annotated_type = get_annotated_type_text(raw_type_model.get_input_param_type_text(), type_model.get_input_param_type_text())
-                    mode_type_binding = raw_type_binding
+                annotated_type = type_model.get_input_param_type_text()
+                mode_type_binding = param_type_binding
 
                 parameter_list.append("%s %s" % (annotated_type, parameter_name))
 
@@ -2642,8 +2606,6 @@
     def process_command(json_command, domain_name, agent_field_name, agent_interface_name):
         json_command_name = json_command["name"]
 
-        strict_mode = domain_name in STRICT_ENABLED_DOMAINS
-
         Generator.method_name_enum_list.append("        k%s_%sCmd," % (domain_name, json_command["name"]))
         Generator.method_handler_list.append("            &InspectorBackendDispatcherImpl::%s_%s," % (domain_name, json_command_name))
         Generator.backend_method_declaration_list.append("    void %s_%s(long callId, InspectorObject* requestMessageObject);" % (domain_name, json_command_name))
@@ -2732,43 +2694,21 @@
                 if optional:
                     type_model = type_model.get_optional()
 
-                if strict_mode:
-                    # All types are strict. Values do not have default values.
-                    code = "    %s out_%s;\n" % (type_model.get_command_return_pass_model().get_return_var_type(), json_return_name)
-                    param = ", %sout_%s" % (type_model.get_command_return_pass_model().get_output_argument_prefix(), json_return_name)
-                    var_name = "out_%s" % json_return_name
-                    setter_argument = type_model.get_command_return_pass_model().get_output_to_raw_expression() % var_name
-                    if return_type_binding.get_setter_value_expression_pattern():
-                        setter_argument = return_type_binding.get_setter_value_expression_pattern() % setter_argument
+                code = "    %s out_%s;\n" % (type_model.get_command_return_pass_model().get_return_var_type(), json_return_name)
+                param = ", %sout_%s" % (type_model.get_command_return_pass_model().get_output_argument_prefix(), json_return_name)
+                var_name = "out_%s" % json_return_name
+                setter_argument = type_model.get_command_return_pass_model().get_output_to_raw_expression() % var_name
+                if return_type_binding.get_setter_value_expression_pattern():
+                    setter_argument = return_type_binding.get_setter_value_expression_pattern() % setter_argument
 
-                    cook = "            result->set%s(\"%s\", %s);\n" % (setter_type, json_return_name,
-                                                                     setter_argument)
+                cook = "            result->set%s(\"%s\", %s);\n" % (setter_type, json_return_name,
+                                                                 setter_argument)
 
-                    set_condition_pattern = type_model.get_command_return_pass_model().get_set_return_condition()
-                    if set_condition_pattern:
-                        cook = ("            if (%s)\n    " % (set_condition_pattern % var_name)) + cook
-                    annotated_type = type_model.get_command_return_pass_model().get_output_parameter_type()
-                else:
-                    # All types are raw. Values always have default values.
-                    raw_type_model = return_type_binding.get_type_model()
-                    if optional:
-                        raw_type_model = raw_type_model.get_optional()
+                set_condition_pattern = type_model.get_command_return_pass_model().get_set_return_condition()
+                if set_condition_pattern:
+                    cook = ("            if (%s)\n    " % (set_condition_pattern % var_name)) + cook
+                annotated_type = type_model.get_command_return_pass_model().get_output_parameter_type()
 
-                    code = "    %s out_%s = %s;\n" % (raw_type.get_raw_type_model().get_command_return_pass_model().get_return_var_type(), json_return_name, initializer)
-                    param = ", %sout_%s" % (raw_type.get_output_pass_model().get_argument_prefix(), json_return_name)
-                    cook = "            result->set%s(\"%s\", out_%s);\n" % (setter_type, json_return_name, json_return_name)
-                    if optional:
-                        # FIXME: support optional properly. Probably an additional output parameter should be in each case.
-                        # FIXME: refactor this condition; it's a hack now.
-                        var_type_text = raw_type.get_raw_type_model().get_command_return_pass_model().get_return_var_type()
-                        if var_type_text == "bool" or var_type_text.startswith("RefPtr<"):
-                            cook = ("            if (out_%s)\n    " % json_return_name) + cook
-                        else:
-                            cook = "            // FIXME: support optional here.\n" + cook
-
-                    annotated_type = get_annotated_type_text(raw_type.get_raw_type_model().get_command_return_pass_model().get_return_var_type() + raw_type.get_output_pass_model().get_parameter_type_suffix(),
-                                                             type_model.get_command_return_pass_model().get_output_parameter_type())
-
                 param_name = "out_%s" % json_return_name
                 if optional:
                     param_name = "opt_" + param_name

Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp (113439 => 113440)


--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2012-04-06 15:29:10 UTC (rev 113439)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2012-04-06 15:30:18 UTC (rev 113440)
@@ -305,11 +305,13 @@
 void InspectorTimelineAgent::willSendResourceRequest(unsigned long identifier, const ResourceRequest& request)
 {
     pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(timestamp(), m_maxCallStackDepth);
+    RefPtr<InspectorObject> recordRaw = TimelineRecordFactory::createGenericRecord(timestamp(), m_maxCallStackDepth);
     String requestId = IdentifiersFactory::requestId(identifier);
-    record->setObject("data", TimelineRecordFactory::createResourceSendRequestData(requestId, request));
-    record->setString("type", TimelineRecordType::ResourceSendRequest);
-    setHeapSizeStatistic(record.get());
+    recordRaw->setObject("data", TimelineRecordFactory::createResourceSendRequestData(requestId, request));
+    recordRaw->setString("type", TimelineRecordType::ResourceSendRequest);
+    setHeapSizeStatistic(recordRaw.get());
+    // FIXME: runtimeCast is a hack. We do it because we can't build TimelineEvent directly now.
+    RefPtr<TypeBuilder::Timeline::TimelineEvent> record = TypeBuilder::Timeline::TimelineEvent::runtimeCast(recordRaw.release());
     m_frontend->eventRecorded(record.release());
 }
 
@@ -391,9 +393,11 @@
     RefPtr<InspectorObject> record(prpRecord);
     record->setString("type", type);
     setHeapSizeStatistic(record.get());
-    if (m_recordStack.isEmpty())
-        m_frontend->eventRecorded(record.release());
-    else {
+    if (m_recordStack.isEmpty()) {
+        // FIXME: runtimeCast is a hack. We do it because we can't build TimelineEvent directly now.
+        RefPtr<TypeBuilder::Timeline::TimelineEvent> recordChecked = TypeBuilder::Timeline::TimelineEvent::runtimeCast(record.release());
+        m_frontend->eventRecorded(recordChecked.release());
+    } else {
         TimelineRecordEntry parent = m_recordStack.last();
         parent.children->pushObject(record.release());
     }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to