Fix wrong hint label in case of scrolling.
authorDaniel Carl <danielcarl@gmx.de>
Mon, 6 Aug 2018 21:38:29 +0000 (23:38 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 6 Aug 2018 21:38:29 +0000 (23:38 +0200)
Also moved style for hintcontainer from user style to hints.js because
there is no styling set at the moment the user should change.

src/scripts/hints.css
src/scripts/hints.js
src/setting.c
tests/manual/hints/label-positioning.html
tests/manual/hints/wrapped.html [new file with mode: 0644]

index 34e5bda..1b51117 100644 (file)
@@ -1,6 +1,3 @@
-div[vimbhint='container']{
-    position:static
-}
 span[vimbhint^='label']{
     -webkit-transform:translate(-4px,-4px);
     background-color:#fff;
@@ -25,5 +22,4 @@ span[vimbhint^='label']{
 }
 span[vimbhint='label focus']{
     opacity:1;
-    z-index:225000
 }
index 9e245e0..7d7b379 100644 (file)
@@ -170,8 +170,8 @@ var hints = Object.freeze((function(){
                 label.setAttribute(
                     "style", [
                         "display:none;",
-                        "left:", Math.max((rect.left + offsetX), offsetX), "px;",
-                        "top:", Math.max((rect.top + offsetY), offsetY), "px;"
+                        "left:", rect.left, "px;",
+                        "top:", rect.top, "px;"
                     ].join("")
                 );
 
@@ -220,6 +220,7 @@ var hints = Object.freeze((function(){
             /* append the fragment to the document */
             var hDiv = doc.createElement("div");
             hDiv.setAttribute(attr, "container");
+            hDiv.setAttribute("style", "position:fixed;top:0;left:0;z-index:225000;");
             hDiv.appendChild(fragment);
             if (doc.body) {
                 doc.body.appendChild(hDiv);
index d6c69b6..02f59fb 100644 (file)
@@ -700,7 +700,7 @@ static int user_style(Client *c, const char *name, DataType type, void *value, v
     /* Inject the global styles with author level to allow restyling by user
      * style sheets. */
     style = webkit_user_style_sheet_new(CSS_HINTS,
-            WEBKIT_USER_CONTENT_INJECT_TOP_FRAME,
+            WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
             WEBKIT_USER_STYLE_LEVEL_AUTHOR, NULL, NULL);
     webkit_user_content_manager_add_style_sheet(ucm, style);
     webkit_user_style_sheet_unref(style);
index 04d0a53..6c54a29 100644 (file)
         <a href="#one">one</a><br/>
         <a href="#two">two</a>
     </p>
+    <p>
+        To test the hints within iFrame
+        <code>allow-universal-access-from-file-urls</code> must be enabled.
+        And the page reloaded.
+        <iframe src="./wrapped.html" style="margin: 5px 50px; width: 400px; heigth: 200px;"></iframe>
+    </p>
 </body>
 </html>
diff --git a/tests/manual/hints/wrapped.html b/tests/manual/hints/wrapped.html
new file mode 100644 (file)
index 0000000..d6176f0
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Simple Links</title>
+</head>
+<body>
+    <a href="#one">one</a>
+    <br/>
+    <!-- link should not be visible without scrolling -->
+    <a href="#two" style="position: absolute; top: 200px;">two</a>
+</body>
+</html>
+