Browse Source

LibHTML: Hide debugging output unless HTML_DEBUG is defined

Sergey Bugaev 5 năm trước cách đây
mục cha
commit
6491493e26

+ 4 - 0
Libraries/LibHTML/CSS/StyleResolver.cpp

@@ -45,10 +45,14 @@ NonnullRefPtrVector<StyleRule> StyleResolver::collect_matching_rules(const Eleme
             }
         }
     }
+
+#ifdef HTML_DEBUG
     printf("Rules matching Element{%p}\n", &element);
     for (auto& rule : matching_rules) {
         dump_rule(rule);
     }
+#endif
+
     return matching_rules;
 }
 

+ 2 - 0
Libraries/LibHTML/Dump.h

@@ -9,3 +9,5 @@ void dump_tree(const Node&);
 void dump_tree(const LayoutNode&);
 void dump_sheet(const StyleSheet&);
 void dump_rule(const StyleRule&);
+
+#undef HTML_DEBUG

+ 4 - 0
Libraries/LibHTML/Layout/LayoutBlock.cpp

@@ -48,15 +48,19 @@ void LayoutBlock::compute_width()
     auto padding_left = style_properties.length_or_fallback("padding-left", zero_value);
     auto padding_right = style_properties.length_or_fallback("padding-right", zero_value);
 
+#ifdef HTML_DEBUG
     dbg() << " Left: " << margin_left << "+" << border_left << "+" << padding_left;
     dbg() << "Right: " << margin_right << "+" << border_right << "+" << padding_right;
+#endif
 
     int total_px = 0;
     for (auto& value : { margin_left, border_left, padding_left, width, padding_right, border_right, margin_right }) {
         total_px += value.to_px();
     }
 
+#ifdef HTML_DEBUG
     dbg() << "Total: " << total_px;
+#endif
 
     // 10.3.3 Block-level, non-replaced elements in normal flow
     // If 'width' is not 'auto' and 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' (plus any of 'margin-left' or 'margin-right' that are not 'auto') is larger than the width of the containing block, then any 'auto' values for 'margin-left' or 'margin-right' are, for the following rules, treated as zero.

+ 4 - 0
Libraries/LibHTML/Layout/LayoutText.cpp

@@ -60,7 +60,11 @@ void LayoutText::load_font()
         dbg() << "My text is " << node().data();
         ASSERT_NOT_REACHED();
     }
+
+#ifdef HTML_DEBUG
     dbg() << "Found font " << file_name << " for family " << font_family << " weight " << font_weight;
+#endif
+
     m_font = Font::load_from_file(String::format("/res/fonts/%s", file_name.characters()));
 }