Closed Bug 274486 Opened 20 years ago Closed 13 years ago

'Bookmark This Link...' fails to gather link text from nested elements for bookmark title

Categories

(Firefox :: Bookmarks & History, defect)

defect
Not set
minor

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: ncrfgs, Unassigned)

References

()

Details

Attachments

(1 file, 2 obsolete files)

123456789_123456789_123456789_123456789_123456789_123456789_
Usually when in a page there is a string, in this case, 
"Traffic Shaping with Linux", that is a link and I try to 
use "Bookmark This Link..." on it, the string suggested as 
a "Name:" is the same as the one of the link.

But when I try to use "Bookmark This Link..." on the 
"Traffic Shaping with Linux" link in the page I reported 
(it's about the twentyfifth link in the page, at the end of 
the first message), the string suggested as a "Name:" is 
different from "Traffic Shaping with Linux", namely just 
"Traffic".
Confirmed in 1.0 and 20041209 trunk: we stop when we get the first text node
that's in a grandchild of the <a>, rather than just in a child.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Linux → All
Hardware: Macintosh → All
Version: 1.0 Branch → Trunk
Attached file testcase
Bookmark This Link gives "mozilla dot" rather than "mozilla dot org" as a
suggested name.
Assignee: vladimir+bm → nobody
sorry for bugspam, long-overdue mass reassign of ancient QA contact bugs, filter on "beltznerLovesGoats" to get rid of this mass change
QA Contact: mconnor → bookmarks
Attached patch Fix v.1 (obsolete) — Splinter Review
Assignee: nobody → philringnalda
Status: NEW → ASSIGNED
Attachment #254397 - Flags: review?(gavin.sharp)
Comment on attachment 254397 [details] [diff] [review]
Fix v.1

Mmm, no. Image alt attributes ought to be handled better, concatenating them with the rest of the text, not completely forgotten.
Attachment #254397 - Attachment is obsolete: true
Attachment #254397 - Flags: review?(gavin.sharp)
Attached patch Fix v.2 (obsolete) — Splinter Review
Well, if we're going to do anything smarter than this, we need to find a smart owner for the bug.
Attachment #259762 - Flags: review?(gavin.sharp)
Summary: weird behaviour of "Bookmark This Link..." → 'Bookmark This Link...' fails to gather link text from nested elements for bookmark title
Attachment #259762 - Attachment is obsolete: true
Attachment #259762 - Flags: review?(gavin.sharp)
Actually, not smarter, just more persistent. Using a documentencoder's fairly easy, something like

+  const kEncoderCIDbase = "@mozilla.org/layout/documentEncoder;1?type=";
+  var doc = root.ownerDocument;
+
+  if ((kEncoderCIDbase + doc.contentType) in Components.classes) {
+    const nsIDocumentEncoder = Components.interfaces.nsIDocumentEncoder;
+    var encoder = Components.classes[kEncoderCIDbase + doc.contentType]
+                            .createInstance(nsIDocumentEncoder);
+    var flags = encoder.OutputNoScriptContent | encoder.OutputNoFramesContent;
+    encoder.init(doc, "text/plain", flags);
+    encoder.setNode(root);
+    return encoder.encodeToString().replace(/^\s+|\s+$/g, "")
+                                   .replace(/\s+/g, " ");

(with an else, and maybe a try, too), but since that involves using two essentially untested things, documentencoder and plaintextserializer, someone's going to be in for a whole lot of test writing to land it.
Assignee: philringnalda → nobody
Status: ASSIGNED → NEW
The testcase here works fine for me (fixed in bug 710878?), I'll move comment 8 into the remaining filed bug about this (bug 306937).
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: