summaryrefslogtreecommitdiff
path: root/javax/swing/text/html/HTMLDocument.java
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-12-01 23:20:28 +0000
committerRoman Kennke <roman@kennke.org>2006-12-01 23:20:28 +0000
commit5b46b46ff3fdcc16a7420b55fb57b804fb1eb3e3 (patch)
tree9f58c640a500e2ca3d5b32bf156de925184fb253 /javax/swing/text/html/HTMLDocument.java
parentbe31fc91967c4a8d6e62a36b303498563dabc67a (diff)
downloadclasspath-5b46b46ff3fdcc16a7420b55fb57b804fb1eb3e3.tar.gz
2006-12-01 Roman Kennke <kennke@aicas.com>
* javax/swing/text/html/HTML.java (Attribute.DYNAMIC_CLASS): New field. (Attribute.PSEUDO_CLASS): New field. * javax/swing/text/html/HTMLDocument.java (HTMLReader.CharacterAction.start): Initialize anchor with link pseudo attribute. (updateSpecialClass): New helper method. Updates the dynamic or pseudo class for anchor tags. * javax/swing/text/html/HTMLEditorKit.java (LinkController.lastAnchorElement): New field. For tracking enter/exit of anchors. (LinkController.activateLink): Set pseudo class to 'visited'. (LinkController.mouseMoved): Added support for tracking the 'hover' dynamic class. * javax/swing/text/html/InlineView.java (changedUpdate): Fetch new properties. * javax/swing/text/html/StyleSheet.java (attributeSetToMap): New helper method. (getRule): Also append dynamic and pseudo class to key. (resolveStyle): Resolve style based generally on all attributes. * javax/swing/text/html/TableView.java (RowView.layoutMajorAxis): Make sure the grid is valid. (updateGrid): Made package private. * gnu/javax/swing/text/html/css/Selector.java (calculateSpecificity): Added support for dynamic and pseudo classes. (matches): Changed to operate on general attributes. Added support for dynamic and pseudo classes.
Diffstat (limited to 'javax/swing/text/html/HTMLDocument.java')
-rw-r--r--javax/swing/text/html/HTMLDocument.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/javax/swing/text/html/HTMLDocument.java b/javax/swing/text/html/HTMLDocument.java
index c4f4222ec..8ef4c0e87 100644
--- a/javax/swing/text/html/HTMLDocument.java
+++ b/javax/swing/text/html/HTMLDocument.java
@@ -791,6 +791,10 @@ public class HTMLDocument extends DefaultStyledDocument
// Put the old attribute set on the stack.
pushCharacterStyle();
+ // Initialize with link pseudo class.
+ if (t == HTML.Tag.A)
+ a.addAttribute(HTML.Attribute.PSEUDO_CLASS, "link");
+
// Just add the attributes in <code>a</code>.
charAttr.addAttribute(t, a.copyAttributes());
}
@@ -2117,4 +2121,49 @@ public void setOuterHTML(Element elem, String htmlText)
{
return baseTarget;
}
+
+ /**
+ * Updates the A tag's pseudo class value in response to a hyperlink
+ * action.
+ *
+ * @param el the corresponding element
+ * @param value the new value
+ */
+ void updateSpecialClass(Element el, HTML.Attribute cl, String value)
+ {
+ try
+ {
+ writeLock();
+ DefaultDocumentEvent ev =
+ new DefaultDocumentEvent(el.getStartOffset(), 1,
+ DocumentEvent.EventType.CHANGE);
+ AttributeSet elAtts = el.getAttributes();
+ AttributeSet anchorAtts = (AttributeSet) elAtts.getAttribute(HTML.Tag.A);
+ if (anchorAtts != null)
+ {
+ AttributeSet copy = elAtts.copyAttributes();
+ StyleSheet ss = getStyleSheet();
+ if (value != null)
+ {
+ anchorAtts = ss.addAttribute(anchorAtts, cl, value);
+ }
+ else
+ {
+ anchorAtts = ss.removeAttribute(anchorAtts, cl);
+ }
+ MutableAttributeSet matts = (MutableAttributeSet) elAtts;
+ ev.addEdit(new AttributeUndoableEdit(el, copy, false));
+ matts.removeAttribute(HTML.Tag.A);
+ matts.addAttribute(HTML.Tag.A, anchorAtts);
+ ev.end();
+ fireChangedUpdate(ev);
+ fireUndoableEditUpdate(new UndoableEditEvent(this, ev));
+ }
+ }
+ finally
+ {
+ writeUnlock();
+ }
+ }
+
}