зеркало из https://github.com/mozilla/gecko-dev.git
Make <style> elements notice text content changes. Bug 367612, r+sr=sicking
This commit is contained in:
Родитель
b38b5e7e7c
Коммит
fcd7e069de
|
@ -53,7 +53,8 @@
|
|||
|
||||
class nsHTMLStyleElement : public nsGenericHTMLElement,
|
||||
public nsIDOMHTMLStyleElement,
|
||||
public nsStyleLinkElement
|
||||
public nsStyleLinkElement,
|
||||
public nsStubMutationObserver
|
||||
{
|
||||
public:
|
||||
nsHTMLStyleElement(nsINodeInfo *aNodeInfo);
|
||||
|
@ -74,9 +75,6 @@ public:
|
|||
// nsIDOMHTMLStyleElement
|
||||
NS_DECL_NSIDOMHTMLSTYLEELEMENT
|
||||
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
PRBool aCompileEventHandlers);
|
||||
|
@ -98,6 +96,22 @@ public:
|
|||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
// nsIMutationObserver
|
||||
virtual void CharacterDataChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent,
|
||||
CharacterDataChangeInfo* aInfo);
|
||||
virtual void ContentAppended(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer);
|
||||
virtual void ContentInserted(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
virtual void ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
|
||||
protected:
|
||||
void GetStyleSheetURL(PRBool* aIsInline,
|
||||
nsIURI** aURI);
|
||||
|
@ -114,6 +128,7 @@ NS_IMPL_NS_NEW_HTML_ELEMENT(Style)
|
|||
nsHTMLStyleElement::nsHTMLStyleElement(nsINodeInfo *aNodeInfo)
|
||||
: nsGenericHTMLElement(aNodeInfo)
|
||||
{
|
||||
AddMutationObserver(this);
|
||||
}
|
||||
|
||||
nsHTMLStyleElement::~nsHTMLStyleElement()
|
||||
|
@ -130,6 +145,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLStyleElement, nsGenericHTMLElement)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLStyleElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMLinkStyle)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStyleSheetLinkingElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLStyleElement)
|
||||
NS_HTML_CONTENT_INTERFACE_MAP_END
|
||||
|
||||
|
@ -175,27 +191,38 @@ nsHTMLStyleElement::SetDisabled(PRBool aDisabled)
|
|||
NS_IMPL_STRING_ATTR(nsHTMLStyleElement, Media, media)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLStyleElement, Type, type)
|
||||
|
||||
nsresult
|
||||
nsHTMLStyleElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify)
|
||||
void
|
||||
nsHTMLStyleElement::CharacterDataChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent,
|
||||
CharacterDataChangeInfo* aInfo)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::InsertChildAt(aKid, aIndex, aNotify);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
UpdateStyleSheet();
|
||||
}
|
||||
|
||||
return rv;
|
||||
UpdateStyleSheet();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLStyleElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
void
|
||||
nsHTMLStyleElement::ContentAppended(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::RemoveChildAt(aIndex, aNotify);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
UpdateStyleSheet();
|
||||
}
|
||||
UpdateStyleSheet();
|
||||
}
|
||||
|
||||
return rv;
|
||||
void
|
||||
nsHTMLStyleElement::ContentInserted(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
UpdateStyleSheet();
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLStyleElement::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
UpdateStyleSheet();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style> * { color: red } </style>
|
||||
<style id="t">* { color: green }</style>
|
||||
</head>
|
||||
<body>
|
||||
<span class="test">This text should be green</span>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style> * { color: red } </style>
|
||||
<style id="t"></style>
|
||||
</head>
|
||||
<body>
|
||||
<span class="test">This text should be green</span>
|
||||
<script>
|
||||
document.getElementById("t").
|
||||
appendChild(document.createTextNode("* { color: green }"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style> * { color: red } </style>
|
||||
<style id="t"></style>
|
||||
</head>
|
||||
<body>
|
||||
<span class="test">This text should be green</span>
|
||||
<script>
|
||||
document.getElementById("t").
|
||||
appendChild(document.createTextNode("* { color: "));
|
||||
document.getElementById("t").
|
||||
appendChild(document.createTextNode("green }"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style> * { color: red } </style>
|
||||
<style id="t"></style>
|
||||
</head>
|
||||
<body>
|
||||
<span class="test">This text should be green</span>
|
||||
<script>
|
||||
document.getElementById("t").
|
||||
appendChild(document.createTextNode("* { color: "));
|
||||
// Flush reflow
|
||||
document.body.offsetWidth;
|
||||
document.getElementById("t").
|
||||
appendChild(document.createTextNode("green }"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style> * { color: red } </style>
|
||||
<style id="t"></style>
|
||||
</head>
|
||||
<body>
|
||||
<span class="test">This text should be green</span>
|
||||
<script>
|
||||
document.getElementById("t").appendChild(document.createTextNode(""));
|
||||
document.getElementById("t").firstChild.data = "* { color: green }";
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style> * { color: red } </style>
|
||||
<style id="t"></style>
|
||||
</head>
|
||||
<body>
|
||||
<span class="test">This text should be green</span>
|
||||
<script>
|
||||
document.getElementById("t").
|
||||
appendChild(document.createTextNode("* { color: "));
|
||||
document.getElementById("t").
|
||||
appendChild(document.createTextNode("green }"));
|
||||
document.getElementById("t").normalize();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style> * { color: red } </style>
|
||||
<style id="t"></style>
|
||||
</head>
|
||||
<body>
|
||||
<span class="test">This text should be green</span>
|
||||
<script>
|
||||
document.getElementById("t").
|
||||
appendChild(document.createTextNode("* { color: green }"));
|
||||
document.getElementById("t").
|
||||
appendChild(document.createTextNode("* { color: red }"));
|
||||
// Flush reflow
|
||||
document.body.offsetWidth;
|
||||
document.getElementById("t").
|
||||
removeChild(document.getElementById("t").lastChild);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style> * { color: red } </style>
|
||||
</head>
|
||||
<body>
|
||||
<span class="test">This text should be green</span>
|
||||
</body>
|
||||
</html>
|
|
@ -87,6 +87,13 @@ f== bugs/351641-2b.html bugs/351641-2-ref.html # bug 358433 (2006-10-19)
|
|||
== bugs/300691-1d.html bugs/300691-1-ref.html
|
||||
== bugs/300691-1e.html bugs/300691-1-ref.html
|
||||
== bugs/300691-1f.html bugs/300691-1-ref.html
|
||||
== bugs/367612-1a.html bugs/367612-1-ref.html
|
||||
== bugs/367612-1b.html bugs/367612-1-ref.html
|
||||
== bugs/367612-1c.html bugs/367612-1-ref.html
|
||||
== bugs/367612-1d.html bugs/367612-1-ref.html
|
||||
== bugs/367612-1e.html bugs/367612-1-ref.html
|
||||
== bugs/367612-1f.html bugs/367612-1-ref.html
|
||||
!= bugs/367612-1g.html bugs/367612-1-ref.html
|
||||
|
||||
# table-dom/
|
||||
== table-dom/appendCells1.html table-dom/appendCells1-ref.html
|
||||
|
|
Загрузка…
Ссылка в новой задаче