shithub: mycel

Download patch

ref: dfa9164394dc393c5956104cc7e2efce6b8bf041
parent: 8e75b098a0689018b0a0e4061f6e6c8cb4e5461f
author: Philip Silva <philip.silva@protonmail.com>
date: Fri May 7 16:11:55 EDT 2021

Quickfix boxed input fields

- sometimes both elements overlap and the input field cannot be used
- also add support for br tag

--- a/browser/browser.go
+++ b/browser/browser.go
@@ -350,6 +350,11 @@
 		p.Bottom = 0
 	}
 
+	// TODO: make sure input fields can be put into a box
+	if n.Data() =="input" {
+		return nil, false
+	}
+
 	if w == 0 && h == 0 && mw == 0 && i == nil && m == zs && p == zs {
 		return nil, false
 	}
@@ -392,6 +397,13 @@
 	if el == nil {
 		return
 	}
+
+	// TODO: constrain field width as long as boxing them is deactivated
+	_, ok := el.UI.(*duit.Field)
+	if ok && sizeAvail.X > dui.Scale(300) {
+		sizeAvail.X = dui.Scale(300)
+	}
+
 	// Make boxes use full size for image backgrounds
 	box, ok := el.UI.(*Box)
 	if ok && box.Width > 0 && box.Height > 0 {
@@ -1090,6 +1102,10 @@
 			href := n.Attr("href")
 			el = InnerNodesToBox(r+1, b, n)
 			el.makeLink(href)
+		case "br":
+			ui := NewLabel("", n)
+
+			return NewElement(ui, n)
 		case "noscript":
 			if *ExperimentalJsInsecure || !*EnableNoScriptTag {
 				return
--- a/style/stylesheets.go
+++ b/style/stylesheets.go
@@ -31,7 +31,7 @@
 
 const AddOnCSS = `
 /* https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements */
-a, abbr, acronym, audio, b, bdi, bdo, big, br, button, canvas, cite, code, data, datalist, del, dfn, em, embed, i, iframe, img, input, ins, kbd, label, map, mark, meter, noscript, object, output, picture, progress, q, ruby, s, samp, script, select, slot, small, span, strong, sub, sup, svg, template, textarea, time, u, tt, var, video, wbr {
+a, abbr, acronym, audio, b, bdi, bdo, big, /*br,*/ button, canvas, cite, code, data, datalist, del, dfn, em, embed, i, iframe, img, input, ins, kbd, label, map, mark, meter, noscript, object, output, picture, progress, q, ruby, s, samp, script, select, slot, small, span, strong, sub, sup, svg, template, textarea, time, u, tt, var, video, wbr {
   display: inline;
 }
 
@@ -47,6 +47,10 @@
 /* https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements */
 address, article, aside, blockquote, details, dialog, dd, div, dl, dt, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, li, main, nav, ol, p, pre, section, table, ul {
   display: block;
+}
+
+br {
+	display: block;
 }
 
 a {