show(), hide(), visible. font-light, normal, medium, semibold, bold, extrabold, black. protocol connection pooling. fetch() with GURT. DNS from HTTP to GURT.

This commit is contained in:
Face
2025-08-18 17:45:46 +03:00
parent 3ed49fae0d
commit a8313ec3d8
38 changed files with 2123 additions and 2059 deletions

View File

@@ -462,9 +462,33 @@ static func parse_utility_class_internal(rule: CSSRule, utility_name: String) ->
return
# Handle font weight
if utility_name == "font-thin":
rule.properties["font-thin"] = true
return
if utility_name == "font-extralight":
rule.properties["font-extralight"] = true
return
if utility_name == "font-light":
rule.properties["font-light"] = true
return
if utility_name == "font-normal":
rule.properties["font-normal"] = true
return
if utility_name == "font-medium":
rule.properties["font-medium"] = true
return
if utility_name == "font-semibold":
rule.properties["font-semibold"] = true
return
if utility_name == "font-bold":
rule.properties["font-bold"] = true
return
if utility_name == "font-extrabold":
rule.properties["font-extrabold"] = true
return
if utility_name == "font-black":
rule.properties["font-black"] = true
return
# Handle font family
if utility_name == "font-sans":
@@ -478,7 +502,7 @@ static func parse_utility_class_internal(rule: CSSRule, utility_name: String) ->
rule.properties["font-mono"] = true
return
var reserved_font_styles = ["font-sans", "font-serif", "font-mono", "font-bold", "font-italic"]
var reserved_font_styles = ["font-sans", "font-serif", "font-mono", "font-thin", "font-extralight", "font-light", "font-normal", "font-medium", "font-semibold", "font-bold", "font-extrabold", "font-black", "font-italic"]
# Handle custom font families like font-roboto
if utility_name.begins_with("font-") and not utility_name in reserved_font_styles:
var font_name = utility_name.substr(5) # after 'font-'
@@ -521,8 +545,8 @@ static func parse_utility_class_internal(rule: CSSRule, utility_name: String) ->
val = val.substr(1, val.length() - 2)
rule.properties["width"] = SizeUtils.parse_size(val)
return
# Height
if utility_name.begins_with("h-"):
# Height, but h-full is temporarily disabled since it fucks with Yoga layout engine
if utility_name.begins_with("h-") and utility_name != "h-full":
var val = utility_name.substr(2)
if val.begins_with("[") and val.ends_with("]"):
val = val.substr(1, val.length() - 2)

View File

@@ -412,47 +412,69 @@ func apply_element_styles(node: Control, element: HTMLElement, parser: HTMLParse
label.text = text
static func apply_element_bbcode_formatting(element: HTMLElement, styles: Dictionary, content: String, parser: HTMLParser = null) -> String:
# Apply general styling first (color, font-weight) for all elements
var formatted_content = content
# Apply font weight (bold/semibold/etc)
if styles.has("font-bold") and styles["font-bold"]:
formatted_content = "[b]" + formatted_content + "[/b]"
elif styles.has("font-semibold") and styles["font-semibold"]:
formatted_content = "[b]" + formatted_content + "[/b]" # BBCode doesn't have semibold, use bold
# Apply italic
if styles.has("font-italic") and styles["font-italic"]:
formatted_content = "[i]" + formatted_content + "[/i]"
# Apply underline
if styles.has("underline") and styles["underline"]:
formatted_content = "[u]" + formatted_content + "[/u]"
# Apply color
if styles.has("color"):
var color = styles["color"]
if typeof(color) == TYPE_COLOR:
color = "#" + color.to_html(false)
else:
color = str(color)
formatted_content = "[color=%s]%s[/color]" % [color, formatted_content]
# Apply tag-specific formatting
match element.tag_name:
"b":
if styles.has("font-bold") and styles["font-bold"]:
return "[b]" + content + "[/b]"
if not (styles.has("font-bold") and styles["font-bold"]):
formatted_content = "[b]" + formatted_content + "[/b]"
"i":
if styles.has("font-italic") and styles["font-italic"]:
return "[i]" + content + "[/i]"
if not (styles.has("font-italic") and styles["font-italic"]):
formatted_content = "[i]" + formatted_content + "[/i]"
"u":
if styles.has("underline") and styles["underline"]:
return "[u]" + content + "[/u]"
if not (styles.has("underline") and styles["underline"]):
formatted_content = "[u]" + formatted_content + "[/u]"
"small":
if styles.has("font-size"):
return "[font_size=%d]%s[/font_size]" % [styles["font-size"], content]
formatted_content = "[font_size=%d]%s[/font_size]" % [styles["font-size"], formatted_content]
else:
return "[font_size=20]%s[/font_size]" % content
formatted_content = "[font_size=20]%s[/font_size]" % formatted_content
"mark":
if styles.has("bg"):
var color = styles["bg"]
if typeof(color) == TYPE_COLOR:
color = color.to_html(false)
return "[bgcolor=#%s]%s[/bgcolor]" % [color, content]
var bg_color = styles["bg"]
if typeof(bg_color) == TYPE_COLOR:
bg_color = bg_color.to_html(false)
formatted_content = "[bgcolor=#%s]%s[/bgcolor]" % [bg_color, formatted_content]
else:
return "[bgcolor=#FFFF00]%s[/bgcolor]" % content
formatted_content = "[bgcolor=#FFFF00]%s[/bgcolor]" % formatted_content
"code":
if styles.has("font-size"):
return "[font_size=%d][code]%s[/code][/font_size]" % [styles["font-size"], content]
formatted_content = "[font_size=%d][code]%s[/code][/font_size]" % [styles["font-size"], formatted_content]
else:
return "[font_size=20][code]%s[/code][/font_size]" % content
formatted_content = "[font_size=20][code]%s[/code][/font_size]" % formatted_content
"a":
var href = element.get_attribute("href")
var color = "#1a0dab"
if styles.has("color"):
var c = styles["color"]
if typeof(c) == TYPE_COLOR:
color = "#" + c.to_html(false)
else:
color = str(c)
if href.length() > 0:
# Pass raw href - URL resolution happens in handle_link_click
return "[color=%s][url=%s]%s[/url][/color]" % [color, href, content]
return content
formatted_content = "[url=%s]%s[/url]" % [href, formatted_content]
return formatted_content
static func get_bbcode_with_styles(element: HTMLElement, styles: Dictionary, parser: HTMLParser) -> String:
var text = ""

View File

@@ -661,18 +661,43 @@ func _handle_text_setting(operation: Dictionary):
if dom_node:
var text_node = get_dom_node(dom_node, "text")
if text_node:
if text_node.has_method("set_text"):
if text_node is RichTextLabel:
var formatted_text = element.get_bbcode_formatted_text(dom_parser)
formatted_text = "[font_size=24]%s[/font_size]" % formatted_text
text_node.text = formatted_text
text_node.call_deferred("_auto_resize_to_content")
elif text_node.has_method("set_text"):
text_node.set_text(text)
elif "text" in text_node:
text_node.text = text
if text_node.has_method("_auto_resize_to_content"):
text_node.call_deferred("_auto_resize_to_content")
else:
var rich_text_label = _find_rich_text_label_recursive(dom_node)
if rich_text_label:
var formatted_text = element.get_bbcode_formatted_text(dom_parser)
formatted_text = "[font_size=24]%s[/font_size]" % formatted_text
rich_text_label.text = formatted_text
rich_text_label.call_deferred("_auto_resize_to_content")
func _find_rich_text_label_recursive(node: Node) -> RichTextLabel:
if node is RichTextLabel:
return node
for child in node.get_children():
var result = _find_rich_text_label_recursive(child)
if result:
return result
return null
func _handle_text_getting(operation: Dictionary):
var selector: String = operation.selector
var element = SelectorUtils.find_first_matching(selector, dom_parser.parse_result.all_elements)
if element:
# Return the element's cached text content from the HTML element
# This avoids the need for a callback system since we have the text cached
return element.text_content
return ""