Fixed MAP elements to conform to HTML 4.0. Hooked up attribute changes for MAP, AREA and ANCHOR elements. Added RECONSTRUCT_ALL as a style hint for attribute changes. Modified nsCSSFrameConstructor's ReconstructFrame to only reconstruct the document element hierarchy.

This commit is contained in:
vidur%netscape.com 1999-03-01 16:57:35 +00:00
Родитель 56cfd4410d
Коммит cb48e4047a
38 изменённых файлов: 1060 добавлений и 487 удалений

Просмотреть файл

@ -582,8 +582,8 @@ nsDocument::~nsDocument()
// This notification will occur only after the reference has
// been dropped.
mInDestructor = PR_TRUE;
PRInt32 index, count = mObservers.Count();
for (index = 0; index < count; index++) {
PRInt32 index;
for (index = 0; index < mObservers.Count(); index++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(index);
observer->DocumentWillBeDestroyed(this);
}
@ -1045,8 +1045,7 @@ void nsDocument::AddStyleSheet(nsIStyleSheet* aSheet)
}
// XXX should observers be notified for disabled sheets??? I think not, but I could be wrong
count = mObservers.Count();
for (index = 0; index < count; index++) {
for (index = 0; index < mObservers.Count(); index++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(index);
observer->StyleSheetAdded(this, aSheet);
}
@ -1078,8 +1077,7 @@ void nsDocument::SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
}
}
count = mObservers.Count();
for (index = 0; index < count; index++) {
for (index = 0; index < mObservers.Count(); index++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(index);
observer->StyleSheetDisabledStateChanged(this, aSheet, aDisabled);
}
@ -1150,15 +1148,16 @@ PRBool nsDocument::RemoveObserver(nsIDocumentObserver* aObserver)
NS_IMETHODIMP
nsDocument::BeginLoad()
{
PRInt32 i, count = mObservers.Count();
for (i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*) mObservers[i];
observer->BeginLoad(this);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1167,15 +1166,16 @@ nsDocument::BeginLoad()
NS_IMETHODIMP
nsDocument::EndLoad()
{
PRInt32 i, count = mObservers.Count();
for (i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*) mObservers[i];
observer->EndLoad(this);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1185,15 +1185,16 @@ NS_IMETHODIMP
nsDocument::ContentChanged(nsIContent* aContent,
nsISupports* aSubContent)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentChanged(this, aContent, aSubContent);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1202,15 +1203,16 @@ nsDocument::ContentChanged(nsIContent* aContent,
NS_IMETHODIMP
nsDocument::ContentStateChanged(nsIContent* aContent)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentStateChanged(this, aContent);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1221,15 +1223,16 @@ NS_IMETHODIMP
nsDocument::ContentAppended(nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentAppended(this, aContainer, aNewIndexInContainer);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1240,15 +1243,16 @@ nsDocument::ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentInserted(this, aContainer, aChild, aIndexInContainer);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1260,8 +1264,10 @@ nsDocument::ContentReplaced(nsIContent* aContainer,
nsIContent* aNewChild,
PRInt32 aIndexInContainer)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentReplaced(this, aContainer, aOldChild, aNewChild,
aIndexInContainer);
@ -1269,7 +1275,6 @@ nsDocument::ContentReplaced(nsIContent* aContainer,
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1280,8 +1285,10 @@ nsDocument::ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentRemoved(this, aContainer,
aChild, aIndexInContainer);
@ -1289,7 +1296,6 @@ nsDocument::ContentRemoved(nsIContent* aContainer,
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1300,15 +1306,16 @@ nsDocument::AttributeChanged(nsIContent* aChild,
nsIAtom* aAttribute,
PRInt32 aHint)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->AttributeChanged(this, aChild, aAttribute, aHint);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1319,15 +1326,16 @@ NS_IMETHODIMP
nsDocument::StyleRuleChanged(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule,
PRInt32 aHint)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->StyleRuleChanged(this, aStyleSheet, aStyleRule, aHint);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1336,15 +1344,16 @@ nsDocument::StyleRuleChanged(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRul
NS_IMETHODIMP
nsDocument::StyleRuleAdded(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->StyleRuleAdded(this, aStyleSheet, aStyleRule);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1353,15 +1362,16 @@ nsDocument::StyleRuleAdded(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule)
NS_IMETHODIMP
nsDocument::StyleRuleRemoved(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->StyleRuleRemoved(this, aStyleSheet, aStyleRule);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;

Просмотреть файл

@ -89,10 +89,7 @@ public:
NS_IMETHOD ConstructRootFrame(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame*& aFrameSubTree);
NS_IMETHOD ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree);
NS_IMETHOD ReconstructDocElementHierarchy(nsIPresContext* aPresContext);
NS_IMETHOD ContentAppended(nsIPresContext* aPresContext,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer);
@ -728,13 +725,9 @@ NS_IMETHODIMP StyleSetImpl::ConstructRootFrame(nsIPresContext* aPresContext,
}
NS_IMETHODIMP
StyleSetImpl::ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree)
StyleSetImpl::ReconstructDocElementHierarchy(nsIPresContext* aPresContext)
{
return mFrameConstructor->ReconstructFrames(aPresContext, aContent,
aParentFrame, aFrameSubTree);
return mFrameConstructor->ReconstructDocElementHierarchy(aPresContext);
}
NS_IMETHODIMP StyleSetImpl::ContentAppended(nsIPresContext* aPresContext,

Просмотреть файл

@ -329,6 +329,25 @@ nsHTMLAnchorElement::GetStyleHintForAttributeChange(
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
if ((aAttribute == nsHTMLAtoms::charset) ||
(aAttribute == nsHTMLAtoms::coords) ||
(aAttribute == nsHTMLAtoms::href) ||
(aAttribute == nsHTMLAtoms::hreflang) ||
(aAttribute == nsHTMLAtoms::name) ||
(aAttribute == nsHTMLAtoms::rel) ||
(aAttribute == nsHTMLAtoms::rev) ||
(aAttribute == nsHTMLAtoms::shape) ||
(aAttribute == nsHTMLAtoms::tabindex) ||
(aAttribute == nsHTMLAtoms::target) ||
(aAttribute == nsHTMLAtoms::type)) {
*aHint = NS_STYLE_HINT_NONE;
}
else if (aAttribute == nsHTMLAtoms::accesskey) {
// XXX Notification needs to happen for this attribute
*aHint = NS_STYLE_HINT_NONE;
}
else {
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
}
return NS_OK;
}

Просмотреть файл

@ -189,10 +189,24 @@ nsHTMLAreaElement::HandleDOMEvent(nsIPresContext& aPresContext,
}
NS_IMETHODIMP
nsHTMLAreaElement::GetStyleHintForAttributeChange(
const nsIAtom* aAttribute,
PRInt32 *aHint) const
nsHTMLAreaElement::GetStyleHintForAttributeChange(const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
if ((aAttribute == nsHTMLAtoms::alt) ||
(aAttribute == nsHTMLAtoms::coords) ||
(aAttribute == nsHTMLAtoms::href) ||
(aAttribute == nsHTMLAtoms::nohref) ||
(aAttribute == nsHTMLAtoms::shape) ||
(aAttribute == nsHTMLAtoms::tabindex) ||
(aAttribute == nsHTMLAtoms::target)) {
*aHint = NS_STYLE_HINT_NONE;
}
else if (aAttribute == nsHTMLAtoms::accesskey) {
// XXX Notification needs to happen for this attribute
*aHint = NS_STYLE_HINT_NONE;
}
else {
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
}
return NS_OK;
}

Просмотреть файл

@ -354,9 +354,15 @@ nsHTMLImageElement::GetStyleHintForAttributeChange(
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
if (aAttribute == nsHTMLAtoms::src)
if (aAttribute == nsHTMLAtoms::src) {
*aHint = NS_STYLE_HINT_CONTENT;
else
}
else if ((aAttribute == nsHTMLAtoms::usemap) ||
(aAttribute == nsHTMLAtoms::ismap)) {
*aHint = NS_STYLE_HINT_FRAMECHANGE;
}
else {
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
}
return NS_OK;
}

Просмотреть файл

@ -27,8 +27,12 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "GenericElementCollection.h"
#include "nsIDocument.h"
#include "nsIHTMLDocument.h"
#include "nsCOMPtr.h"
static NS_DEFINE_IID(kIDOMHTMLMapElementIID, NS_IDOMHTMLMAPELEMENT_IID);
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
class nsHTMLMapElement : public nsIDOMHTMLMapElement,
public nsIScriptObjectOwner,
@ -63,7 +67,106 @@ public:
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
// nsIContent
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
NS_IMETHOD GetDocument(nsIDocument*& aResult) const {
return mInner.GetDocument(aResult);
}
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep);
NS_IMETHOD GetParent(nsIContent*& aResult) const {
return mInner.GetParent(aResult);
}
NS_IMETHOD SetParent(nsIContent* aParent) {
return mInner.SetParent(aParent);
}
NS_IMETHOD CanContainChildren(PRBool& aResult) const {
return mInner.CanContainChildren(aResult);
}
NS_IMETHOD ChildCount(PRInt32& aResult) const {
return mInner.ChildCount(aResult);
}
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const {
return mInner.ChildAt(aIndex, aResult);
}
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const {
return mInner.IndexOf(aPossibleChild, aResult);
}
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
PRBool aNotify) {
return mInner.InsertChildAt(aKid, aIndex, aNotify);
}
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
PRBool aNotify) {
return mInner.ReplaceChildAt(aKid, aIndex, aNotify);
}
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) {
return mInner.AppendChildTo(aKid, aNotify);
}
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) {
return mInner.RemoveChildAt(aIndex, aNotify);
}
NS_IMETHOD IsSynthetic(PRBool& aResult) {
return mInner.IsSynthetic(aResult);
}
NS_IMETHOD GetNameSpaceID(PRInt32& aResult) const {
return mInner.GetNameSpaceID(aResult);
}
NS_IMETHOD GetTag(nsIAtom*& aResult) const {
return mInner.GetTag(aResult);
}
NS_IMETHOD ParseAttributeString(const nsString& aStr,
nsIAtom*& aName,
PRInt32& aNameSpaceID) {
return mInner.ParseAttributeString(aStr, aName, aNameSpaceID);
}
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
nsIAtom*& aPrefix) {
return mInner.GetNameSpacePrefix(aNameSpaceID, aPrefix);
}
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsString& aValue, PRBool aNotify) {
return mInner.SetAttribute(aNameSpaceID, aName, aValue, aNotify);
}
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
nsString& aResult) const {
return mInner.GetAttribute(aNameSpaceID, aName, aResult);
}
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool aNotify) {
return mInner.UnsetAttribute(aNameSpaceID, aAttribute, aNotify);
}
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const {
return mInner.GetAttributeNameAt(aIndex, aNameSpaceID, aName);
}
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const {
return mInner.GetAttributeCount(aResult);
}
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const {
return mInner.List(out, aIndent);
}
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const {
return mInner.BeginConvertToXIF(aConverter);
}
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const {
return mInner.ConvertContentToXIF(aConverter);
}
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const {
return mInner.FinishConvertToXIF(aConverter);
}
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus& aEventStatus);
NS_IMETHOD RangeAdd(nsIDOMRange& aRange) {
return mInner.RangeAdd(aRange);
}
NS_IMETHOD RangeRemove(nsIDOMRange& aRange) {
return mInner.RangeRemove(aRange);
}
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const {
return mInner.GetRangeList(aResult);
}
// nsIHTMLContent
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
@ -119,7 +222,37 @@ nsHTMLMapElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
return NS_NOINTERFACE;
}
nsresult
NS_IMETHODIMP
nsHTMLMapElement::SetDocument(nsIDocument* aDocument, PRBool aDeep)
{
nsresult rv;
if (nsnull != mInner.mDocument) {
nsCOMPtr<nsIHTMLDocument> htmlDoc;
rv = mInner.mDocument->QueryInterface(kIHTMLDocumentIID,
getter_AddRefs(htmlDoc));
if (NS_OK == rv) {
htmlDoc->RemoveImageMap(this);
}
}
rv = mInner.SetDocument(aDocument, aDeep);
if (NS_SUCCEEDED(rv) && (nsnull != aDocument)) {
nsCOMPtr<nsIHTMLDocument> htmlDoc;
rv = aDocument->QueryInterface(kIHTMLDocumentIID,
getter_AddRefs(htmlDoc));
if (NS_OK == rv) {
htmlDoc->AddImageMap(this);
}
}
return rv;
}
NS_IMETHODIMP
nsHTMLMapElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
{
nsHTMLMapElement* it = new nsHTMLMapElement(mInner.mTag);
@ -197,10 +330,14 @@ nsHTMLMapElement::HandleDOMEvent(nsIPresContext& aPresContext,
}
NS_IMETHODIMP
nsHTMLMapElement::GetStyleHintForAttributeChange(
const nsIAtom* aAttribute,
PRInt32 *aHint) const
nsHTMLMapElement::GetStyleHintForAttributeChange(const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
if (aAttribute == nsHTMLAtoms::name) {
*aHint = NS_STYLE_HINT_RECONSTRUCT_ALL;
}
else {
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
}
return NS_OK;
}

Просмотреть файл

@ -249,6 +249,7 @@ public:
nsresult ProcessAREATag(const nsIParserNode& aNode);
nsresult ProcessBASETag(const nsIParserNode& aNode);
nsresult ProcessLINKTag(const nsIParserNode& aNode);
nsresult ProcessMAPTag(const nsIParserNode& aNode, nsIHTMLContent* aContent);
nsresult ProcessMETATag(const nsIParserNode& aNode);
nsresult ProcessSCRIPTTag(const nsIParserNode& aNode);
nsresult ProcessSTYLETag(const nsIParserNode& aNode);
@ -980,6 +981,9 @@ SinkContext::OpenContainer(const nsIParserNode& aNode)
case eHTMLTag_table:
mSink->mInMonolithicContainer++;
break;
case eHTMLTag_map:
mSink->ProcessMAPTag(aNode, content);
break;
default:
break;
}
@ -1798,53 +1802,13 @@ HTMLContentSink::CloseFrameset(const nsIParserNode& aNode)
NS_IMETHODIMP
HTMLContentSink::OpenMap(const nsIParserNode& aNode)
{
NS_IF_RELEASE(mCurrentMap);
NS_IF_RELEASE(mCurrentDOMMap);
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
nsIHTMLContent* map;
nsresult rv = CreateContentObject(aNode, nodeType, nsnull, nsnull, &map);
if (NS_FAILED(rv)) {
return rv;
}
// Set the content's document and attributes
map->SetDocument(mDocument, PR_FALSE);
nsIScriptContextOwner* sco = mDocument->GetScriptContextOwner();
rv = AddAttributes(aNode, map, sco);
NS_IF_RELEASE(sco);
if (NS_FAILED(rv)) {
NS_RELEASE(map);
return rv;
}
nsIDOMHTMLMapElement* domMap;
rv = map->QueryInterface(kIDOMHTMLMapElementIID, (void**)&domMap);
if (NS_FAILED(rv)) {
NS_RELEASE(map);
return rv;
}
// Strip out whitespace in the name for navigator compatability
// XXX NAV QUIRK
nsHTMLValue name;
map->GetHTMLAttribute(nsHTMLAtoms::name, name);
if (eHTMLUnit_String == name.GetUnit()) {
nsAutoString tmp;
name.GetStringValue(tmp);
tmp.StripWhitespace();
name.SetStringValue(tmp);
map->SetHTMLAttribute(nsHTMLAtoms::name, name, PR_FALSE);
}
// Add the map to the document
mHTMLDocument->AddImageMap(domMap);
mCurrentMap = map; // holds a reference
mCurrentDOMMap = domMap; // holds a reference
// Add the map content object to the document
rv = mCurrentContext->AddLeaf(map);
return rv;
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenMap", aNode);
// We used to treat MAP elements specially (i.e. they were
// only parent elements for AREAs), but we don't anymore.
// HTML 4.0 says that MAP elements can have block content
// as children.
return mCurrentContext->OpenContainer(aNode);
}
NS_IMETHODIMP
@ -1854,7 +1818,8 @@ HTMLContentSink::CloseMap(const nsIParserNode& aNode)
"HTMLContentSink::CloseMap", aNode);
NS_IF_RELEASE(mCurrentMap);
NS_IF_RELEASE(mCurrentDOMMap);
return NS_OK;
return mCurrentContext->CloseContainer(aNode);
}
NS_IMETHODIMP
@ -2536,6 +2501,42 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
return result;
}
nsresult
HTMLContentSink::ProcessMAPTag(const nsIParserNode& aNode,
nsIHTMLContent* aContent)
{
nsresult rv;
NS_IF_RELEASE(mCurrentMap);
NS_IF_RELEASE(mCurrentDOMMap);
nsIDOMHTMLMapElement* domMap;
rv = aContent->QueryInterface(kIDOMHTMLMapElementIID, (void**)&domMap);
if (NS_FAILED(rv)) {
return rv;
}
// Strip out whitespace in the name for navigator compatability
// XXX NAV QUIRK
nsHTMLValue name;
aContent->GetHTMLAttribute(nsHTMLAtoms::name, name);
if (eHTMLUnit_String == name.GetUnit()) {
nsAutoString tmp;
name.GetStringValue(tmp);
tmp.StripWhitespace();
name.SetStringValue(tmp);
aContent->SetHTMLAttribute(nsHTMLAtoms::name, name, PR_FALSE);
}
// Don't need to add the map to the document here anymore.
// The map adds itself
mCurrentMap = aContent;
NS_ADDREF(aContent);
mCurrentDOMMap = domMap; // holds a reference
return rv;
}
nsresult
HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
{

Просмотреть файл

@ -429,6 +429,19 @@ nsHTMLDocument::AddImageMap(nsIDOMHTMLMapElement* aMap)
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP
nsHTMLDocument::RemoveImageMap(nsIDOMHTMLMapElement* aMap)
{
NS_PRECONDITION(nsnull != aMap, "null ptr");
if (nsnull == aMap) {
return NS_ERROR_NULL_POINTER;
}
if (mImageMaps.RemoveElement((void*)aMap)) {
NS_RELEASE(aMap);
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLDocument::GetImageMap(const nsString& aMapName,
nsIDOMHTMLMapElement** aResult)

Просмотреть файл

@ -59,6 +59,8 @@ public:
NS_IMETHOD AddImageMap(nsIDOMHTMLMapElement* aMap);
NS_IMETHOD RemoveImageMap(nsIDOMHTMLMapElement* aMap);
NS_IMETHOD GetImageMap(const nsString& aMapName,
nsIDOMHTMLMapElement** aResult);

Просмотреть файл

@ -25,6 +25,7 @@ class nsIDOMHTMLCollection;
class nsIDOMHTMLFormElement;
class nsIDOMHTMLMapElement;
class nsIHTMLStyleSheet;
class nsIStyleSheet;
/* b2a848b0-d0a9-11d1-89b1-006008911b81 */
#define NS_IHTMLDOCUMENT_IID \
@ -48,6 +49,8 @@ public:
NS_IMETHOD GetImageMap(const nsString& aMapName,
nsIDOMHTMLMapElement** aResult) = 0;
NS_IMETHOD RemoveImageMap(nsIDOMHTMLMapElement* aMap) = 0;
NS_IMETHOD AddForm(nsIDOMHTMLFormElement* aForm) = 0;
NS_IMETHOD GetForms(nsIDOMHTMLCollection** aForms) = 0;

Просмотреть файл

@ -2899,56 +2899,65 @@ nsCSSFrameConstructor::ConstructFrame(nsIPresContext* aPresContext,
return rv;
}
// XXX we need aFrameSubTree's prev-sibling in order to properly
// place its replacement!
NS_IMETHODIMP
nsCSSFrameConstructor::ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree)
NS_IMETHODIMP
nsCSSFrameConstructor::ReconstructDocElementHierarchy(nsIPresContext* aPresContext)
{
nsresult rv = NS_OK;
nsIDocument* document;
rv = aContent->GetDocument(document);
if (NS_FAILED(rv)) {
return rv;
}
if (nsnull != document) {
nsCOMPtr<nsIPresShell> shell;
rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv)) {
// XXX This API needs changing, because it appears to be designed for
// an arbitrary content element, but yet it always constructs the document
// element's frame. Plus it has the problem noted above in the previous XXX
rv = aParentFrame->RemoveFrame(*aPresContext, *shell,
nsnull, aFrameSubTree);
// XXX Remove any existing fixed items...
if (nsnull != mDocument) {
nsCOMPtr<nsIContent> rootContent(dont_AddRef(mDocument->GetRootContent()));
if (rootContent) {
nsCOMPtr<nsIPresShell> shell;
rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv)) {
nsIFrame* newChild;
nsCOMPtr<nsIStyleContext> rootPseudoStyle;
nsAbsoluteItems fixedItems(nsnull); // XXX FIX ME...
nsIFrame* docElementFrame;
// Get the frame that corresponds to the document element
shell->GetPrimaryFrameFor(rootContent, &docElementFrame);
aParentFrame->GetStyleContext(getter_AddRefs(rootPseudoStyle));
rv = ConstructDocElementFrame(aPresContext, aContent,
aParentFrame, rootPseudoStyle, newChild,
fixedItems);
// XXX Do something with the fixed items...
if (NS_SUCCEEDED(rv)) {
rv = aParentFrame->InsertFrames(*aPresContext, *shell,
nsnull, nsnull, newChild);
if (nsnull != docElementFrame) {
nsIFrame* docParentFrame;
docElementFrame->GetParent(&docParentFrame);
if (nsnull != docParentFrame) {
// Remove the old document element hieararchy
rv = docParentFrame->RemoveFrame(*aPresContext,
*shell,
nsnull,
docElementFrame);
// XXX Remove any existing fixed items...
if (NS_SUCCEEDED(rv)) {
nsIFrame* newChild;
nsCOMPtr<nsIStyleContext> rootPseudoStyle;
nsAbsoluteItems fixedItems(nsnull); // XXX FIX ME...
docParentFrame->GetStyleContext(getter_AddRefs(rootPseudoStyle));
rv = ConstructDocElementFrame(aPresContext, rootContent,
docParentFrame,
rootPseudoStyle, newChild,
fixedItems);
// XXX Do something with the fixed items...
if (NS_SUCCEEDED(rv)) {
rv = docParentFrame->InsertFrames(*aPresContext,
*shell,
nsnull,
nsnull,
newChild);
}
}
}
}
}
}
NS_RELEASE(document);
}
}
return rv;
}
nsIFrame*
nsCSSFrameConstructor::GetFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext,
nsIContent* aContent)
@ -3677,7 +3686,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
nsIFrame* frame;
shell->GetPrimaryFrameFor(aContent, &frame);
PRBool reconstruct = PR_FALSE;
PRBool restyle = PR_FALSE;
PRBool reflow = PR_FALSE;
PRBool reframe = PR_FALSE;
@ -3704,6 +3714,9 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
switch (aHint) {
default:
case NS_STYLE_HINT_RECONSTRUCT_ALL:
reconstruct = PR_TRUE;
break;
case NS_STYLE_HINT_UNKNOWN:
case NS_STYLE_HINT_FRAMECHANGE:
reframe = PR_TRUE;
@ -3720,7 +3733,10 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
}
// apply changes
if (PR_TRUE == reframe) {
if (PR_TRUE == reconstruct) {
ReconstructDocElementHierarchy(aPresContext);
}
else if (PR_TRUE == reframe) {
RecreateFramesForContent(aPresContext, aContent);
}
else if (PR_TRUE == restyle) {

Просмотреть файл

@ -50,10 +50,7 @@ public:
nsIContent* aDocElement,
nsIFrame*& aNewFrame);
NS_IMETHODIMP ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree);
NS_IMETHOD ReconstructDocElementHierarchy(nsIPresContext* aPresContext);
NS_IMETHOD ContentAppended(nsIPresContext* aPresContext,
nsIContent* aContainer,

Просмотреть файл

@ -1568,27 +1568,11 @@ nsresult
PresShell::ReconstructFrames(void)
{
nsresult rv = NS_OK;
if (nsnull != mRootFrame) {
if (nsnull != mDocument) {
nsIContent* rootContent = mDocument->GetRootContent();
if (nsnull != rootContent) {
nsIFrame* docElementFrame;
nsIFrame* parentFrame;
// Get the frame that corresponds to the document element
GetPrimaryFrameFor(rootContent, &docElementFrame);
if (nsnull != docElementFrame) {
docElementFrame->GetParent(&parentFrame);
EnterReflowLock();
rv = mStyleSet->ReconstructFrames(mPresContext, rootContent,
parentFrame, docElementFrame);
ExitReflowLock();
NS_RELEASE(rootContent);
}
}
}
}
EnterReflowLock();
rv = mStyleSet->ReconstructDocElementHierarchy(mPresContext);
ExitReflowLock();
return rv;
}

Просмотреть файл

@ -31,8 +31,9 @@
#define NS_STYLE_HINT_CONTENT 2 // change was contentual (ie: SRC=)
#define NS_STYLE_HINT_VISUAL 3 // change was visual only (ie: COLOR=)
#define NS_STYLE_HINT_REFLOW 4 // change requires reflow (ie: WIDTH=)
#define NS_STYLE_HINT_FRAMECHANGE 5 // change requires frame change (ie: DISPLAY=)
#define NS_STYLE_HINT_MAX NS_STYLE_HINT_FRAMECHANGE
#define NS_STYLE_HINT_FRAMECHANGE 5 // change requires frame change (ie: display:)
#define NS_STYLE_HINT_RECONSTRUCT_ALL 6 // change requires reconstruction of entire document (ie: style sheet change)
#define NS_STYLE_HINT_MAX NS_STYLE_HINT_RECONSTRUCT_ALL
// Indicies into border/padding/margin arrays
#define NS_SIDE_TOP 0

Просмотреть файл

@ -40,14 +40,10 @@ public:
nsIContent* aDocElement,
nsIFrame*& aFrameSubTree) = 0;
// XXX TROY Is this what we want?
// Causes reconstruction of a frame hierarchy rooted by the
// frame aFrameSubTree. This is often called when radical style
// document element frame. This is often called when radical style
// change precludes incremental reflow.
NS_IMETHOD ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree) = 0;
NS_IMETHOD ReconstructDocElementHierarchy(nsIPresContext* aPresContext) = 0;
NS_IMETHOD ContentAppended(nsIPresContext* aPresContext,
nsIContent* aContainer,

Просмотреть файл

@ -92,12 +92,9 @@ public:
nsIFrame*& aFrameSubTree) = 0;
// Causes reconstruction of a frame hierarchy rooted by the
// frame aFrameSubTree. This is often called when radical style
// frame document element frame. This is often called when radical style
// change precludes incremental reflow.
NS_IMETHOD ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree) = 0;
NS_IMETHOD ReconstructDocElementHierarchy(nsIPresContext* aPresContext) = 0;
// Notifications of changes to the content mpodel
NS_IMETHOD ContentAppended(nsIPresContext* aPresContext,

Просмотреть файл

@ -31,8 +31,9 @@
#define NS_STYLE_HINT_CONTENT 2 // change was contentual (ie: SRC=)
#define NS_STYLE_HINT_VISUAL 3 // change was visual only (ie: COLOR=)
#define NS_STYLE_HINT_REFLOW 4 // change requires reflow (ie: WIDTH=)
#define NS_STYLE_HINT_FRAMECHANGE 5 // change requires frame change (ie: DISPLAY=)
#define NS_STYLE_HINT_MAX NS_STYLE_HINT_FRAMECHANGE
#define NS_STYLE_HINT_FRAMECHANGE 5 // change requires frame change (ie: display:)
#define NS_STYLE_HINT_RECONSTRUCT_ALL 6 // change requires reconstruction of entire document (ie: style sheet change)
#define NS_STYLE_HINT_MAX NS_STYLE_HINT_RECONSTRUCT_ALL
// Indicies into border/padding/margin arrays
#define NS_SIDE_TOP 0

Просмотреть файл

@ -582,8 +582,8 @@ nsDocument::~nsDocument()
// This notification will occur only after the reference has
// been dropped.
mInDestructor = PR_TRUE;
PRInt32 index, count = mObservers.Count();
for (index = 0; index < count; index++) {
PRInt32 index;
for (index = 0; index < mObservers.Count(); index++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(index);
observer->DocumentWillBeDestroyed(this);
}
@ -1045,8 +1045,7 @@ void nsDocument::AddStyleSheet(nsIStyleSheet* aSheet)
}
// XXX should observers be notified for disabled sheets??? I think not, but I could be wrong
count = mObservers.Count();
for (index = 0; index < count; index++) {
for (index = 0; index < mObservers.Count(); index++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(index);
observer->StyleSheetAdded(this, aSheet);
}
@ -1078,8 +1077,7 @@ void nsDocument::SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
}
}
count = mObservers.Count();
for (index = 0; index < count; index++) {
for (index = 0; index < mObservers.Count(); index++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(index);
observer->StyleSheetDisabledStateChanged(this, aSheet, aDisabled);
}
@ -1150,15 +1148,16 @@ PRBool nsDocument::RemoveObserver(nsIDocumentObserver* aObserver)
NS_IMETHODIMP
nsDocument::BeginLoad()
{
PRInt32 i, count = mObservers.Count();
for (i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*) mObservers[i];
observer->BeginLoad(this);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1167,15 +1166,16 @@ nsDocument::BeginLoad()
NS_IMETHODIMP
nsDocument::EndLoad()
{
PRInt32 i, count = mObservers.Count();
for (i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*) mObservers[i];
observer->EndLoad(this);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1185,15 +1185,16 @@ NS_IMETHODIMP
nsDocument::ContentChanged(nsIContent* aContent,
nsISupports* aSubContent)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentChanged(this, aContent, aSubContent);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1202,15 +1203,16 @@ nsDocument::ContentChanged(nsIContent* aContent,
NS_IMETHODIMP
nsDocument::ContentStateChanged(nsIContent* aContent)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentStateChanged(this, aContent);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1221,15 +1223,16 @@ NS_IMETHODIMP
nsDocument::ContentAppended(nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentAppended(this, aContainer, aNewIndexInContainer);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1240,15 +1243,16 @@ nsDocument::ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentInserted(this, aContainer, aChild, aIndexInContainer);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1260,8 +1264,10 @@ nsDocument::ContentReplaced(nsIContent* aContainer,
nsIContent* aNewChild,
PRInt32 aIndexInContainer)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentReplaced(this, aContainer, aOldChild, aNewChild,
aIndexInContainer);
@ -1269,7 +1275,6 @@ nsDocument::ContentReplaced(nsIContent* aContainer,
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1280,8 +1285,10 @@ nsDocument::ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->ContentRemoved(this, aContainer,
aChild, aIndexInContainer);
@ -1289,7 +1296,6 @@ nsDocument::ContentRemoved(nsIContent* aContainer,
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1300,15 +1306,16 @@ nsDocument::AttributeChanged(nsIContent* aChild,
nsIAtom* aAttribute,
PRInt32 aHint)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->AttributeChanged(this, aChild, aAttribute, aHint);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1319,15 +1326,16 @@ NS_IMETHODIMP
nsDocument::StyleRuleChanged(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule,
PRInt32 aHint)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->StyleRuleChanged(this, aStyleSheet, aStyleRule, aHint);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1336,15 +1344,16 @@ nsDocument::StyleRuleChanged(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRul
NS_IMETHODIMP
nsDocument::StyleRuleAdded(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->StyleRuleAdded(this, aStyleSheet, aStyleRule);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;
@ -1353,15 +1362,16 @@ nsDocument::StyleRuleAdded(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule)
NS_IMETHODIMP
nsDocument::StyleRuleRemoved(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
PRInt32 i;
// Get new value of count for every iteration in case
// observers remove themselves during the loop.
for (i = 0; i < mObservers.Count(); i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
observer->StyleRuleRemoved(this, aStyleSheet, aStyleRule);
// Make sure that the observer didn't remove itself during the
// notification. If it did, update our index and count.
if (observer != (nsIDocumentObserver*)mObservers[i]) {
i--;
count--;
}
}
return NS_OK;

Просмотреть файл

@ -89,10 +89,7 @@ public:
NS_IMETHOD ConstructRootFrame(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame*& aFrameSubTree);
NS_IMETHOD ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree);
NS_IMETHOD ReconstructDocElementHierarchy(nsIPresContext* aPresContext);
NS_IMETHOD ContentAppended(nsIPresContext* aPresContext,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer);
@ -728,13 +725,9 @@ NS_IMETHODIMP StyleSetImpl::ConstructRootFrame(nsIPresContext* aPresContext,
}
NS_IMETHODIMP
StyleSetImpl::ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree)
StyleSetImpl::ReconstructDocElementHierarchy(nsIPresContext* aPresContext)
{
return mFrameConstructor->ReconstructFrames(aPresContext, aContent,
aParentFrame, aFrameSubTree);
return mFrameConstructor->ReconstructDocElementHierarchy(aPresContext);
}
NS_IMETHODIMP StyleSetImpl::ContentAppended(nsIPresContext* aPresContext,

Просмотреть файл

@ -26,16 +26,20 @@
#include "nsISizeOfHandler.h"
#include "nsTextFragment.h"
#include "nsIContent.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMHTMLMapElement.h"
#include "nsIDOMHTMLAreaElement.h"
#include "nsIDOMHTMLAnchorElement.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIDocument.h"
#include "nsINameSpaceManager.h"
#include "nsHTMLAtoms.h"
class Area {
public:
Area(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress);
PRBool aSuppress, PRBool aHasURL);
virtual ~Area();
void ParseCoords(const nsString& aSpec);
@ -73,14 +77,15 @@ public:
nsString mAltText;
nscoord* mCoords;
PRInt32 mNumCoords;
PRBool mHasURL;
PRBool mSuppressFeedback;
};
Area::Area(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress)
PRBool aSuppress, PRBool aHasURL)
: mBase(aBaseURL), mHREF(aHREF), mTarget(aTarget), mAltText(aAltText),
mSuppressFeedback(aSuppress)
mSuppressFeedback(aSuppress), mHasURL(aHasURL)
{
mCoords = nsnull;
mNumCoords = 0;
@ -372,7 +377,7 @@ class DefaultArea : public Area {
public:
DefaultArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress);
PRBool aSuppress, PRBool aHasURL);
~DefaultArea();
virtual PRBool IsInside(nscoord x, nscoord y);
@ -383,8 +388,8 @@ public:
DefaultArea::DefaultArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress)
PRBool aSuppress, PRBool aHasURL)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress, aHasURL)
{
}
@ -412,7 +417,7 @@ class RectArea : public Area {
public:
RectArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress);
PRBool aSuppress, PRBool aHasURL);
~RectArea();
virtual PRBool IsInside(nscoord x, nscoord y);
@ -423,8 +428,8 @@ public:
RectArea::RectArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress)
PRBool aSuppress, PRBool aHasURL)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress, aHasURL)
{
}
@ -477,7 +482,7 @@ class PolyArea : public Area {
public:
PolyArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress);
PRBool aSuppress, PRBool aHasURL);
~PolyArea();
virtual PRBool IsInside(nscoord x, nscoord y);
@ -488,8 +493,8 @@ public:
PolyArea::PolyArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress)
PRBool aSuppress, PRBool aHasURL)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress, aHasURL)
{
}
@ -588,7 +593,7 @@ class CircleArea : public Area {
public:
CircleArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress);
PRBool aSuppress, PRBool aHasURL);
~CircleArea();
virtual PRBool IsInside(nscoord x, nscoord y);
@ -599,8 +604,8 @@ public:
CircleArea::CircleArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress)
PRBool aSuppress, PRBool aHasURL)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress, aHasURL)
{
}
@ -639,8 +644,8 @@ void CircleArea::Draw(nsIPresContext& aCX, nsIRenderingContext& aRC)
if (radius < 0) {
return;
}
nscoord x = x1 - radius / 2;
nscoord y = y1 - radius / 2;
nscoord x = x1 - radius;
nscoord y = y1 - radius;
nscoord w = 2 * radius;
aRC.DrawEllipse(x, y, w, w);
}
@ -654,7 +659,9 @@ void CircleArea::GetShapeName(nsString& aResult) const
//----------------------------------------------------------------------
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIDOMHTMLElementIID, NS_IDOMHTMLELEMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLAreaElementIID, NS_IDOMHTMLAREAELEMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLAnchorElementIID, NS_IDOMHTMLANCHORELEMENT_IID);
static NS_DEFINE_IID(kIDocumentObserverIID, NS_IDOCUMENT_OBSERVER_IID);
nsImageMap::nsImageMap()
@ -663,6 +670,7 @@ nsImageMap::nsImageMap()
mDomMap = nsnull;
mRefCnt = 1;
mDocument = nsnull;
mContainsBlockContents = PR_FALSE;
}
nsImageMap::~nsImageMap()
@ -712,63 +720,111 @@ nsImageMap::Init(nsIDOMHTMLMapElement* aMap)
return rv;
}
nsresult
nsImageMap::UpdateAreasForBlock(nsIContent* aParent)
{
nsresult rv = NS_OK;
nsIContent* child;
PRInt32 i, n;
aParent->ChildCount(n);
for (i = 0; (i < n) && NS_SUCCEEDED(rv); i++) {
rv = aParent->ChildAt(i, child);
if (NS_SUCCEEDED(rv)) {
nsIDOMHTMLAnchorElement* area;
rv = child->QueryInterface(kIDOMHTMLAnchorElementIID, (void**) &area);
if (NS_SUCCEEDED(rv)) {
rv = AddArea(child);
NS_RELEASE(area);
}
else {
rv = UpdateAreasForBlock(child);
}
NS_RELEASE(child);
}
}
return rv;
}
nsresult
nsImageMap::UpdateAreas()
{
// Get rid of old area data
FreeAreas();
nsIDOMHTMLCollection* col = nsnull;
nsresult rv = mDomMap->GetAreas(&col);
if (NS_FAILED(rv)) {
return rv;
}
if (nsnull != col) {
PRUint32 i, n;
col->GetLength(&n);
for (i = 0; (i < n) && NS_SUCCEEDED(rv); i++) {
nsIDOMNode* node = nsnull;
rv = col->Item(i, &node);
if (NS_SUCCEEDED(rv) && (nsnull != node)) {
nsresult rv;
nsIContent* child;
PRInt32 i, n;
PRBool containsBlock = PR_FALSE, containsArea = PR_FALSE;
mMap->ChildCount(n);
for (i = 0; (i < n) && NS_SUCCEEDED(rv); i++) {
rv = mMap->ChildAt(i, child);
if (NS_SUCCEEDED(rv)) {
// Only look at elements and not text, comments, etc.
nsIDOMHTMLElement* element;
rv = child->QueryInterface(kIDOMHTMLElementIID, (void**)&element);
if (NS_FAILED(rv)) {
rv = NS_OK;
continue;
}
NS_RELEASE(element);
// First check if this map element contains an AREA element.
// If so, we only look for AREA elements
if (!containsBlock) {
nsIDOMHTMLAreaElement* area;
rv = node->QueryInterface(kIDOMHTMLAreaElementIID, (void**) &area);
rv = child->QueryInterface(kIDOMHTMLAreaElementIID, (void**) &area);
if (NS_SUCCEEDED(rv)) {
rv = AddArea(area);
containsArea = PR_TRUE;
rv = AddArea(child);
NS_RELEASE(area);
}
else {
containsBlock = PR_TRUE;
mContainsBlockContents = PR_TRUE;
rv = NS_OK;
}
NS_RELEASE(node);
}
// If the map element doesn't contain an AREA element as its
// first element, we make the assumption that it contains
// block elements and we look for children that are anchors.
if (!containsArea) {
rv = UpdateAreasForBlock(child);
}
NS_RELEASE(child);
}
NS_RELEASE(col);
}
return rv;
}
nsresult
nsImageMap::AddArea(nsIDOMHTMLAreaElement* aArea)
nsImageMap::AddArea(nsIContent* aArea)
{
nsAutoString shape, coords, baseURL, href, target, altText;
aArea->GetShape(shape);
aArea->GetCoords(coords);
aArea->GetHref(href);
aArea->GetTarget(target);
aArea->GetAlt(altText);
nsAutoString shape, coords, baseURL, href, target, altText, noHref;
aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::shape, shape);
aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::coords, coords);
aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::alt, altText);
PRBool hasURL = (PRBool)(NS_CONTENT_ATTR_HAS_VALUE != aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::nohref, noHref));
PRBool suppress = PR_FALSE;/* XXX */
Area* area;
if ((0 == shape.Length()) || shape.EqualsIgnoreCase("rect")) {
area = new RectArea(baseURL, href, target, altText, suppress);
area = new RectArea(baseURL, href, target, altText, suppress, hasURL);
} else if (shape.EqualsIgnoreCase("poly") ||
shape.EqualsIgnoreCase("polygon")) {
area = new PolyArea(baseURL, href, target, altText, suppress);
area = new PolyArea(baseURL, href, target, altText, suppress, hasURL);
} else if (shape.EqualsIgnoreCase("circle")) {
area = new CircleArea(baseURL, href, target, altText, suppress);
area = new CircleArea(baseURL, href, target, altText, suppress, hasURL);
}
else {
area = new DefaultArea(baseURL, href, target, altText, suppress);
area = new DefaultArea(baseURL, href, target, altText, suppress, hasURL);
}
area->ParseCoords(coords);
mAreas.AppendElement(area);
@ -786,7 +842,7 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
PRInt32 i, n = mAreas.Count();
for (i = 0; i < n; i++) {
Area* area = (Area*) mAreas.ElementAt(i);
if (area->IsInside(aX, aY)) {
if (area->IsInside(aX, aY) && area->mHasURL) {
NS_MakeAbsoluteURL(aDocURL, area->mBase, area->mHREF, aAbsURL);
aTarget = area->mTarget;
aAltText = area->mAltText;
@ -883,6 +939,27 @@ nsImageMap::EndReflow(nsIDocument *aDocument, nsIPresShell* aShell)
return NS_OK;
}
PRBool
nsImageMap::IsAncestorOf(nsIContent* aContent,
nsIContent* aAncestorContent)
{
nsIContent* parent;
nsresult rv = aContent->GetParent(parent);
if (NS_SUCCEEDED(rv) && (nsnull != parent)) {
PRBool rBool;
if (parent == aAncestorContent) {
rBool = PR_TRUE;
}
else {
rBool = IsAncestorOf(parent, aAncestorContent);
}
NS_RELEASE(parent);
return rBool;
}
return PR_FALSE;
}
NS_IMETHODIMP
nsImageMap::ContentChanged(nsIDocument *aDocument,
nsIContent* aContent,
@ -893,7 +970,8 @@ nsImageMap::ContentChanged(nsIDocument *aDocument,
nsIContent* parent;
nsresult rv = aContent->GetParent(parent);
if (NS_SUCCEEDED(rv) && (nsnull != parent)) {
if (parent == mMap) {
if ((parent == mMap) ||
(mContainsBlockContents && IsAncestorOf(parent, mMap))) {
UpdateAreas();
}
NS_RELEASE(parent);
@ -920,7 +998,8 @@ nsImageMap::AttributeChanged(nsIDocument *aDocument,
nsIContent* parent;
nsresult rv = aContent->GetParent(parent);
if (NS_SUCCEEDED(rv) && (nsnull != parent)) {
if (parent == mMap) {
if ((parent == mMap) ||
(mContainsBlockContents && IsAncestorOf(parent, mMap))) {
UpdateAreas();
}
NS_RELEASE(parent);
@ -933,7 +1012,8 @@ nsImageMap::ContentAppended(nsIDocument *aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
{
if (mMap == aContainer) {
if ((mMap == aContainer) ||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
UpdateAreas();
}
return NS_OK;
@ -945,7 +1025,8 @@ nsImageMap::ContentInserted(nsIDocument *aDocument,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
if (mMap == aContainer) {
if ((mMap == aContainer) ||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
UpdateAreas();
}
return NS_OK;
@ -958,7 +1039,8 @@ nsImageMap::ContentReplaced(nsIDocument *aDocument,
nsIContent* aNewChild,
PRInt32 aIndexInContainer)
{
if (mMap == aContainer) {
if ((mMap == aContainer) ||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
UpdateAreas();
}
return NS_OK;
@ -970,7 +1052,8 @@ nsImageMap::ContentRemoved(nsIDocument *aDocument,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
if (mMap == aContainer) {
if ((mMap == aContainer) ||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
UpdateAreas();
}
return NS_OK;

Просмотреть файл

@ -24,6 +24,7 @@
#include "nsVoidArray.h"
#include "nsIDocumentObserver.h"
class nsIContent;
class nsIDOMHTMLAreaElement;
class nsIDOMHTMLMapElement;
class nsIPresContext;
@ -121,13 +122,18 @@ protected:
void FreeAreas();
nsresult UpdateAreas();
nsresult UpdateAreasForBlock(nsIContent* aParent);
nsresult AddArea(nsIDOMHTMLAreaElement* aArea);
static PRBool IsAncestorOf(nsIContent* aContent,
nsIContent* aAncestorContent);
nsresult AddArea(nsIContent* aArea);
nsIDocument* mDocument;
nsIDOMHTMLMapElement* mDomMap;
nsIContent* mMap;
nsVoidArray mAreas;
PRBool mContainsBlockContents;
};
#endif /* nsImageMap_h___ */

Просмотреть файл

@ -26,16 +26,20 @@
#include "nsISizeOfHandler.h"
#include "nsTextFragment.h"
#include "nsIContent.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMHTMLMapElement.h"
#include "nsIDOMHTMLAreaElement.h"
#include "nsIDOMHTMLAnchorElement.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIDocument.h"
#include "nsINameSpaceManager.h"
#include "nsHTMLAtoms.h"
class Area {
public:
Area(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress);
PRBool aSuppress, PRBool aHasURL);
virtual ~Area();
void ParseCoords(const nsString& aSpec);
@ -73,14 +77,15 @@ public:
nsString mAltText;
nscoord* mCoords;
PRInt32 mNumCoords;
PRBool mHasURL;
PRBool mSuppressFeedback;
};
Area::Area(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress)
PRBool aSuppress, PRBool aHasURL)
: mBase(aBaseURL), mHREF(aHREF), mTarget(aTarget), mAltText(aAltText),
mSuppressFeedback(aSuppress)
mSuppressFeedback(aSuppress), mHasURL(aHasURL)
{
mCoords = nsnull;
mNumCoords = 0;
@ -372,7 +377,7 @@ class DefaultArea : public Area {
public:
DefaultArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress);
PRBool aSuppress, PRBool aHasURL);
~DefaultArea();
virtual PRBool IsInside(nscoord x, nscoord y);
@ -383,8 +388,8 @@ public:
DefaultArea::DefaultArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress)
PRBool aSuppress, PRBool aHasURL)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress, aHasURL)
{
}
@ -412,7 +417,7 @@ class RectArea : public Area {
public:
RectArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress);
PRBool aSuppress, PRBool aHasURL);
~RectArea();
virtual PRBool IsInside(nscoord x, nscoord y);
@ -423,8 +428,8 @@ public:
RectArea::RectArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress)
PRBool aSuppress, PRBool aHasURL)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress, aHasURL)
{
}
@ -477,7 +482,7 @@ class PolyArea : public Area {
public:
PolyArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress);
PRBool aSuppress, PRBool aHasURL);
~PolyArea();
virtual PRBool IsInside(nscoord x, nscoord y);
@ -488,8 +493,8 @@ public:
PolyArea::PolyArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress)
PRBool aSuppress, PRBool aHasURL)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress, aHasURL)
{
}
@ -588,7 +593,7 @@ class CircleArea : public Area {
public:
CircleArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress);
PRBool aSuppress, PRBool aHasURL);
~CircleArea();
virtual PRBool IsInside(nscoord x, nscoord y);
@ -599,8 +604,8 @@ public:
CircleArea::CircleArea(const nsString& aBaseURL, const nsString& aHREF,
const nsString& aTarget, const nsString& aAltText,
PRBool aSuppress)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress)
PRBool aSuppress, PRBool aHasURL)
: Area(aBaseURL, aHREF, aTarget, aAltText, aSuppress, aHasURL)
{
}
@ -639,8 +644,8 @@ void CircleArea::Draw(nsIPresContext& aCX, nsIRenderingContext& aRC)
if (radius < 0) {
return;
}
nscoord x = x1 - radius / 2;
nscoord y = y1 - radius / 2;
nscoord x = x1 - radius;
nscoord y = y1 - radius;
nscoord w = 2 * radius;
aRC.DrawEllipse(x, y, w, w);
}
@ -654,7 +659,9 @@ void CircleArea::GetShapeName(nsString& aResult) const
//----------------------------------------------------------------------
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIDOMHTMLElementIID, NS_IDOMHTMLELEMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLAreaElementIID, NS_IDOMHTMLAREAELEMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLAnchorElementIID, NS_IDOMHTMLANCHORELEMENT_IID);
static NS_DEFINE_IID(kIDocumentObserverIID, NS_IDOCUMENT_OBSERVER_IID);
nsImageMap::nsImageMap()
@ -663,6 +670,7 @@ nsImageMap::nsImageMap()
mDomMap = nsnull;
mRefCnt = 1;
mDocument = nsnull;
mContainsBlockContents = PR_FALSE;
}
nsImageMap::~nsImageMap()
@ -712,63 +720,111 @@ nsImageMap::Init(nsIDOMHTMLMapElement* aMap)
return rv;
}
nsresult
nsImageMap::UpdateAreasForBlock(nsIContent* aParent)
{
nsresult rv = NS_OK;
nsIContent* child;
PRInt32 i, n;
aParent->ChildCount(n);
for (i = 0; (i < n) && NS_SUCCEEDED(rv); i++) {
rv = aParent->ChildAt(i, child);
if (NS_SUCCEEDED(rv)) {
nsIDOMHTMLAnchorElement* area;
rv = child->QueryInterface(kIDOMHTMLAnchorElementIID, (void**) &area);
if (NS_SUCCEEDED(rv)) {
rv = AddArea(child);
NS_RELEASE(area);
}
else {
rv = UpdateAreasForBlock(child);
}
NS_RELEASE(child);
}
}
return rv;
}
nsresult
nsImageMap::UpdateAreas()
{
// Get rid of old area data
FreeAreas();
nsIDOMHTMLCollection* col = nsnull;
nsresult rv = mDomMap->GetAreas(&col);
if (NS_FAILED(rv)) {
return rv;
}
if (nsnull != col) {
PRUint32 i, n;
col->GetLength(&n);
for (i = 0; (i < n) && NS_SUCCEEDED(rv); i++) {
nsIDOMNode* node = nsnull;
rv = col->Item(i, &node);
if (NS_SUCCEEDED(rv) && (nsnull != node)) {
nsresult rv;
nsIContent* child;
PRInt32 i, n;
PRBool containsBlock = PR_FALSE, containsArea = PR_FALSE;
mMap->ChildCount(n);
for (i = 0; (i < n) && NS_SUCCEEDED(rv); i++) {
rv = mMap->ChildAt(i, child);
if (NS_SUCCEEDED(rv)) {
// Only look at elements and not text, comments, etc.
nsIDOMHTMLElement* element;
rv = child->QueryInterface(kIDOMHTMLElementIID, (void**)&element);
if (NS_FAILED(rv)) {
rv = NS_OK;
continue;
}
NS_RELEASE(element);
// First check if this map element contains an AREA element.
// If so, we only look for AREA elements
if (!containsBlock) {
nsIDOMHTMLAreaElement* area;
rv = node->QueryInterface(kIDOMHTMLAreaElementIID, (void**) &area);
rv = child->QueryInterface(kIDOMHTMLAreaElementIID, (void**) &area);
if (NS_SUCCEEDED(rv)) {
rv = AddArea(area);
containsArea = PR_TRUE;
rv = AddArea(child);
NS_RELEASE(area);
}
else {
containsBlock = PR_TRUE;
mContainsBlockContents = PR_TRUE;
rv = NS_OK;
}
NS_RELEASE(node);
}
// If the map element doesn't contain an AREA element as its
// first element, we make the assumption that it contains
// block elements and we look for children that are anchors.
if (!containsArea) {
rv = UpdateAreasForBlock(child);
}
NS_RELEASE(child);
}
NS_RELEASE(col);
}
return rv;
}
nsresult
nsImageMap::AddArea(nsIDOMHTMLAreaElement* aArea)
nsImageMap::AddArea(nsIContent* aArea)
{
nsAutoString shape, coords, baseURL, href, target, altText;
aArea->GetShape(shape);
aArea->GetCoords(coords);
aArea->GetHref(href);
aArea->GetTarget(target);
aArea->GetAlt(altText);
nsAutoString shape, coords, baseURL, href, target, altText, noHref;
aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::shape, shape);
aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::coords, coords);
aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::alt, altText);
PRBool hasURL = (PRBool)(NS_CONTENT_ATTR_HAS_VALUE != aArea->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::nohref, noHref));
PRBool suppress = PR_FALSE;/* XXX */
Area* area;
if ((0 == shape.Length()) || shape.EqualsIgnoreCase("rect")) {
area = new RectArea(baseURL, href, target, altText, suppress);
area = new RectArea(baseURL, href, target, altText, suppress, hasURL);
} else if (shape.EqualsIgnoreCase("poly") ||
shape.EqualsIgnoreCase("polygon")) {
area = new PolyArea(baseURL, href, target, altText, suppress);
area = new PolyArea(baseURL, href, target, altText, suppress, hasURL);
} else if (shape.EqualsIgnoreCase("circle")) {
area = new CircleArea(baseURL, href, target, altText, suppress);
area = new CircleArea(baseURL, href, target, altText, suppress, hasURL);
}
else {
area = new DefaultArea(baseURL, href, target, altText, suppress);
area = new DefaultArea(baseURL, href, target, altText, suppress, hasURL);
}
area->ParseCoords(coords);
mAreas.AppendElement(area);
@ -786,7 +842,7 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
PRInt32 i, n = mAreas.Count();
for (i = 0; i < n; i++) {
Area* area = (Area*) mAreas.ElementAt(i);
if (area->IsInside(aX, aY)) {
if (area->IsInside(aX, aY) && area->mHasURL) {
NS_MakeAbsoluteURL(aDocURL, area->mBase, area->mHREF, aAbsURL);
aTarget = area->mTarget;
aAltText = area->mAltText;
@ -883,6 +939,27 @@ nsImageMap::EndReflow(nsIDocument *aDocument, nsIPresShell* aShell)
return NS_OK;
}
PRBool
nsImageMap::IsAncestorOf(nsIContent* aContent,
nsIContent* aAncestorContent)
{
nsIContent* parent;
nsresult rv = aContent->GetParent(parent);
if (NS_SUCCEEDED(rv) && (nsnull != parent)) {
PRBool rBool;
if (parent == aAncestorContent) {
rBool = PR_TRUE;
}
else {
rBool = IsAncestorOf(parent, aAncestorContent);
}
NS_RELEASE(parent);
return rBool;
}
return PR_FALSE;
}
NS_IMETHODIMP
nsImageMap::ContentChanged(nsIDocument *aDocument,
nsIContent* aContent,
@ -893,7 +970,8 @@ nsImageMap::ContentChanged(nsIDocument *aDocument,
nsIContent* parent;
nsresult rv = aContent->GetParent(parent);
if (NS_SUCCEEDED(rv) && (nsnull != parent)) {
if (parent == mMap) {
if ((parent == mMap) ||
(mContainsBlockContents && IsAncestorOf(parent, mMap))) {
UpdateAreas();
}
NS_RELEASE(parent);
@ -920,7 +998,8 @@ nsImageMap::AttributeChanged(nsIDocument *aDocument,
nsIContent* parent;
nsresult rv = aContent->GetParent(parent);
if (NS_SUCCEEDED(rv) && (nsnull != parent)) {
if (parent == mMap) {
if ((parent == mMap) ||
(mContainsBlockContents && IsAncestorOf(parent, mMap))) {
UpdateAreas();
}
NS_RELEASE(parent);
@ -933,7 +1012,8 @@ nsImageMap::ContentAppended(nsIDocument *aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
{
if (mMap == aContainer) {
if ((mMap == aContainer) ||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
UpdateAreas();
}
return NS_OK;
@ -945,7 +1025,8 @@ nsImageMap::ContentInserted(nsIDocument *aDocument,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
if (mMap == aContainer) {
if ((mMap == aContainer) ||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
UpdateAreas();
}
return NS_OK;
@ -958,7 +1039,8 @@ nsImageMap::ContentReplaced(nsIDocument *aDocument,
nsIContent* aNewChild,
PRInt32 aIndexInContainer)
{
if (mMap == aContainer) {
if ((mMap == aContainer) ||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
UpdateAreas();
}
return NS_OK;
@ -970,7 +1052,8 @@ nsImageMap::ContentRemoved(nsIDocument *aDocument,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
if (mMap == aContainer) {
if ((mMap == aContainer) ||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
UpdateAreas();
}
return NS_OK;

Просмотреть файл

@ -24,6 +24,7 @@
#include "nsVoidArray.h"
#include "nsIDocumentObserver.h"
class nsIContent;
class nsIDOMHTMLAreaElement;
class nsIDOMHTMLMapElement;
class nsIPresContext;
@ -121,13 +122,18 @@ protected:
void FreeAreas();
nsresult UpdateAreas();
nsresult UpdateAreasForBlock(nsIContent* aParent);
nsresult AddArea(nsIDOMHTMLAreaElement* aArea);
static PRBool IsAncestorOf(nsIContent* aContent,
nsIContent* aAncestorContent);
nsresult AddArea(nsIContent* aArea);
nsIDocument* mDocument;
nsIDOMHTMLMapElement* mDomMap;
nsIContent* mMap;
nsVoidArray mAreas;
PRBool mContainsBlockContents;
};
#endif /* nsImageMap_h___ */

Просмотреть файл

@ -1568,27 +1568,11 @@ nsresult
PresShell::ReconstructFrames(void)
{
nsresult rv = NS_OK;
if (nsnull != mRootFrame) {
if (nsnull != mDocument) {
nsIContent* rootContent = mDocument->GetRootContent();
if (nsnull != rootContent) {
nsIFrame* docElementFrame;
nsIFrame* parentFrame;
// Get the frame that corresponds to the document element
GetPrimaryFrameFor(rootContent, &docElementFrame);
if (nsnull != docElementFrame) {
docElementFrame->GetParent(&parentFrame);
EnterReflowLock();
rv = mStyleSet->ReconstructFrames(mPresContext, rootContent,
parentFrame, docElementFrame);
ExitReflowLock();
NS_RELEASE(rootContent);
}
}
}
}
EnterReflowLock();
rv = mStyleSet->ReconstructDocElementHierarchy(mPresContext);
ExitReflowLock();
return rv;
}

Просмотреть файл

@ -329,6 +329,25 @@ nsHTMLAnchorElement::GetStyleHintForAttributeChange(
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
if ((aAttribute == nsHTMLAtoms::charset) ||
(aAttribute == nsHTMLAtoms::coords) ||
(aAttribute == nsHTMLAtoms::href) ||
(aAttribute == nsHTMLAtoms::hreflang) ||
(aAttribute == nsHTMLAtoms::name) ||
(aAttribute == nsHTMLAtoms::rel) ||
(aAttribute == nsHTMLAtoms::rev) ||
(aAttribute == nsHTMLAtoms::shape) ||
(aAttribute == nsHTMLAtoms::tabindex) ||
(aAttribute == nsHTMLAtoms::target) ||
(aAttribute == nsHTMLAtoms::type)) {
*aHint = NS_STYLE_HINT_NONE;
}
else if (aAttribute == nsHTMLAtoms::accesskey) {
// XXX Notification needs to happen for this attribute
*aHint = NS_STYLE_HINT_NONE;
}
else {
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
}
return NS_OK;
}

Просмотреть файл

@ -189,10 +189,24 @@ nsHTMLAreaElement::HandleDOMEvent(nsIPresContext& aPresContext,
}
NS_IMETHODIMP
nsHTMLAreaElement::GetStyleHintForAttributeChange(
const nsIAtom* aAttribute,
PRInt32 *aHint) const
nsHTMLAreaElement::GetStyleHintForAttributeChange(const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
if ((aAttribute == nsHTMLAtoms::alt) ||
(aAttribute == nsHTMLAtoms::coords) ||
(aAttribute == nsHTMLAtoms::href) ||
(aAttribute == nsHTMLAtoms::nohref) ||
(aAttribute == nsHTMLAtoms::shape) ||
(aAttribute == nsHTMLAtoms::tabindex) ||
(aAttribute == nsHTMLAtoms::target)) {
*aHint = NS_STYLE_HINT_NONE;
}
else if (aAttribute == nsHTMLAtoms::accesskey) {
// XXX Notification needs to happen for this attribute
*aHint = NS_STYLE_HINT_NONE;
}
else {
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
}
return NS_OK;
}

Просмотреть файл

@ -354,9 +354,15 @@ nsHTMLImageElement::GetStyleHintForAttributeChange(
const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
if (aAttribute == nsHTMLAtoms::src)
if (aAttribute == nsHTMLAtoms::src) {
*aHint = NS_STYLE_HINT_CONTENT;
else
}
else if ((aAttribute == nsHTMLAtoms::usemap) ||
(aAttribute == nsHTMLAtoms::ismap)) {
*aHint = NS_STYLE_HINT_FRAMECHANGE;
}
else {
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
}
return NS_OK;
}

Просмотреть файл

@ -27,8 +27,12 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "GenericElementCollection.h"
#include "nsIDocument.h"
#include "nsIHTMLDocument.h"
#include "nsCOMPtr.h"
static NS_DEFINE_IID(kIDOMHTMLMapElementIID, NS_IDOMHTMLMAPELEMENT_IID);
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
class nsHTMLMapElement : public nsIDOMHTMLMapElement,
public nsIScriptObjectOwner,
@ -63,7 +67,106 @@ public:
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner)
// nsIContent
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
NS_IMETHOD GetDocument(nsIDocument*& aResult) const {
return mInner.GetDocument(aResult);
}
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep);
NS_IMETHOD GetParent(nsIContent*& aResult) const {
return mInner.GetParent(aResult);
}
NS_IMETHOD SetParent(nsIContent* aParent) {
return mInner.SetParent(aParent);
}
NS_IMETHOD CanContainChildren(PRBool& aResult) const {
return mInner.CanContainChildren(aResult);
}
NS_IMETHOD ChildCount(PRInt32& aResult) const {
return mInner.ChildCount(aResult);
}
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const {
return mInner.ChildAt(aIndex, aResult);
}
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const {
return mInner.IndexOf(aPossibleChild, aResult);
}
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
PRBool aNotify) {
return mInner.InsertChildAt(aKid, aIndex, aNotify);
}
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
PRBool aNotify) {
return mInner.ReplaceChildAt(aKid, aIndex, aNotify);
}
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) {
return mInner.AppendChildTo(aKid, aNotify);
}
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) {
return mInner.RemoveChildAt(aIndex, aNotify);
}
NS_IMETHOD IsSynthetic(PRBool& aResult) {
return mInner.IsSynthetic(aResult);
}
NS_IMETHOD GetNameSpaceID(PRInt32& aResult) const {
return mInner.GetNameSpaceID(aResult);
}
NS_IMETHOD GetTag(nsIAtom*& aResult) const {
return mInner.GetTag(aResult);
}
NS_IMETHOD ParseAttributeString(const nsString& aStr,
nsIAtom*& aName,
PRInt32& aNameSpaceID) {
return mInner.ParseAttributeString(aStr, aName, aNameSpaceID);
}
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
nsIAtom*& aPrefix) {
return mInner.GetNameSpacePrefix(aNameSpaceID, aPrefix);
}
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsString& aValue, PRBool aNotify) {
return mInner.SetAttribute(aNameSpaceID, aName, aValue, aNotify);
}
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
nsString& aResult) const {
return mInner.GetAttribute(aNameSpaceID, aName, aResult);
}
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool aNotify) {
return mInner.UnsetAttribute(aNameSpaceID, aAttribute, aNotify);
}
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex,
PRInt32& aNameSpaceID,
nsIAtom*& aName) const {
return mInner.GetAttributeNameAt(aIndex, aNameSpaceID, aName);
}
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const {
return mInner.GetAttributeCount(aResult);
}
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const {
return mInner.List(out, aIndent);
}
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const {
return mInner.BeginConvertToXIF(aConverter);
}
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const {
return mInner.ConvertContentToXIF(aConverter);
}
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const {
return mInner.FinishConvertToXIF(aConverter);
}
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus& aEventStatus);
NS_IMETHOD RangeAdd(nsIDOMRange& aRange) {
return mInner.RangeAdd(aRange);
}
NS_IMETHOD RangeRemove(nsIDOMRange& aRange) {
return mInner.RangeRemove(aRange);
}
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const {
return mInner.GetRangeList(aResult);
}
// nsIHTMLContent
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
@ -119,7 +222,37 @@ nsHTMLMapElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
return NS_NOINTERFACE;
}
nsresult
NS_IMETHODIMP
nsHTMLMapElement::SetDocument(nsIDocument* aDocument, PRBool aDeep)
{
nsresult rv;
if (nsnull != mInner.mDocument) {
nsCOMPtr<nsIHTMLDocument> htmlDoc;
rv = mInner.mDocument->QueryInterface(kIHTMLDocumentIID,
getter_AddRefs(htmlDoc));
if (NS_OK == rv) {
htmlDoc->RemoveImageMap(this);
}
}
rv = mInner.SetDocument(aDocument, aDeep);
if (NS_SUCCEEDED(rv) && (nsnull != aDocument)) {
nsCOMPtr<nsIHTMLDocument> htmlDoc;
rv = aDocument->QueryInterface(kIHTMLDocumentIID,
getter_AddRefs(htmlDoc));
if (NS_OK == rv) {
htmlDoc->AddImageMap(this);
}
}
return rv;
}
NS_IMETHODIMP
nsHTMLMapElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
{
nsHTMLMapElement* it = new nsHTMLMapElement(mInner.mTag);
@ -197,10 +330,14 @@ nsHTMLMapElement::HandleDOMEvent(nsIPresContext& aPresContext,
}
NS_IMETHODIMP
nsHTMLMapElement::GetStyleHintForAttributeChange(
const nsIAtom* aAttribute,
PRInt32 *aHint) const
nsHTMLMapElement::GetStyleHintForAttributeChange(const nsIAtom* aAttribute,
PRInt32 *aHint) const
{
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
if (aAttribute == nsHTMLAtoms::name) {
*aHint = NS_STYLE_HINT_RECONSTRUCT_ALL;
}
else {
nsGenericHTMLElement::GetStyleHintForCommonAttributes(this, aAttribute, aHint);
}
return NS_OK;
}

Просмотреть файл

@ -249,6 +249,7 @@ public:
nsresult ProcessAREATag(const nsIParserNode& aNode);
nsresult ProcessBASETag(const nsIParserNode& aNode);
nsresult ProcessLINKTag(const nsIParserNode& aNode);
nsresult ProcessMAPTag(const nsIParserNode& aNode, nsIHTMLContent* aContent);
nsresult ProcessMETATag(const nsIParserNode& aNode);
nsresult ProcessSCRIPTTag(const nsIParserNode& aNode);
nsresult ProcessSTYLETag(const nsIParserNode& aNode);
@ -980,6 +981,9 @@ SinkContext::OpenContainer(const nsIParserNode& aNode)
case eHTMLTag_table:
mSink->mInMonolithicContainer++;
break;
case eHTMLTag_map:
mSink->ProcessMAPTag(aNode, content);
break;
default:
break;
}
@ -1798,53 +1802,13 @@ HTMLContentSink::CloseFrameset(const nsIParserNode& aNode)
NS_IMETHODIMP
HTMLContentSink::OpenMap(const nsIParserNode& aNode)
{
NS_IF_RELEASE(mCurrentMap);
NS_IF_RELEASE(mCurrentDOMMap);
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
nsIHTMLContent* map;
nsresult rv = CreateContentObject(aNode, nodeType, nsnull, nsnull, &map);
if (NS_FAILED(rv)) {
return rv;
}
// Set the content's document and attributes
map->SetDocument(mDocument, PR_FALSE);
nsIScriptContextOwner* sco = mDocument->GetScriptContextOwner();
rv = AddAttributes(aNode, map, sco);
NS_IF_RELEASE(sco);
if (NS_FAILED(rv)) {
NS_RELEASE(map);
return rv;
}
nsIDOMHTMLMapElement* domMap;
rv = map->QueryInterface(kIDOMHTMLMapElementIID, (void**)&domMap);
if (NS_FAILED(rv)) {
NS_RELEASE(map);
return rv;
}
// Strip out whitespace in the name for navigator compatability
// XXX NAV QUIRK
nsHTMLValue name;
map->GetHTMLAttribute(nsHTMLAtoms::name, name);
if (eHTMLUnit_String == name.GetUnit()) {
nsAutoString tmp;
name.GetStringValue(tmp);
tmp.StripWhitespace();
name.SetStringValue(tmp);
map->SetHTMLAttribute(nsHTMLAtoms::name, name, PR_FALSE);
}
// Add the map to the document
mHTMLDocument->AddImageMap(domMap);
mCurrentMap = map; // holds a reference
mCurrentDOMMap = domMap; // holds a reference
// Add the map content object to the document
rv = mCurrentContext->AddLeaf(map);
return rv;
SINK_TRACE_NODE(SINK_TRACE_CALLS,
"HTMLContentSink::OpenMap", aNode);
// We used to treat MAP elements specially (i.e. they were
// only parent elements for AREAs), but we don't anymore.
// HTML 4.0 says that MAP elements can have block content
// as children.
return mCurrentContext->OpenContainer(aNode);
}
NS_IMETHODIMP
@ -1854,7 +1818,8 @@ HTMLContentSink::CloseMap(const nsIParserNode& aNode)
"HTMLContentSink::CloseMap", aNode);
NS_IF_RELEASE(mCurrentMap);
NS_IF_RELEASE(mCurrentDOMMap);
return NS_OK;
return mCurrentContext->CloseContainer(aNode);
}
NS_IMETHODIMP
@ -2536,6 +2501,42 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
return result;
}
nsresult
HTMLContentSink::ProcessMAPTag(const nsIParserNode& aNode,
nsIHTMLContent* aContent)
{
nsresult rv;
NS_IF_RELEASE(mCurrentMap);
NS_IF_RELEASE(mCurrentDOMMap);
nsIDOMHTMLMapElement* domMap;
rv = aContent->QueryInterface(kIDOMHTMLMapElementIID, (void**)&domMap);
if (NS_FAILED(rv)) {
return rv;
}
// Strip out whitespace in the name for navigator compatability
// XXX NAV QUIRK
nsHTMLValue name;
aContent->GetHTMLAttribute(nsHTMLAtoms::name, name);
if (eHTMLUnit_String == name.GetUnit()) {
nsAutoString tmp;
name.GetStringValue(tmp);
tmp.StripWhitespace();
name.SetStringValue(tmp);
aContent->SetHTMLAttribute(nsHTMLAtoms::name, name, PR_FALSE);
}
// Don't need to add the map to the document here anymore.
// The map adds itself
mCurrentMap = aContent;
NS_ADDREF(aContent);
mCurrentDOMMap = domMap; // holds a reference
return rv;
}
nsresult
HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
{

Просмотреть файл

@ -429,6 +429,19 @@ nsHTMLDocument::AddImageMap(nsIDOMHTMLMapElement* aMap)
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP
nsHTMLDocument::RemoveImageMap(nsIDOMHTMLMapElement* aMap)
{
NS_PRECONDITION(nsnull != aMap, "null ptr");
if (nsnull == aMap) {
return NS_ERROR_NULL_POINTER;
}
if (mImageMaps.RemoveElement((void*)aMap)) {
NS_RELEASE(aMap);
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLDocument::GetImageMap(const nsString& aMapName,
nsIDOMHTMLMapElement** aResult)

Просмотреть файл

@ -59,6 +59,8 @@ public:
NS_IMETHOD AddImageMap(nsIDOMHTMLMapElement* aMap);
NS_IMETHOD RemoveImageMap(nsIDOMHTMLMapElement* aMap);
NS_IMETHOD GetImageMap(const nsString& aMapName,
nsIDOMHTMLMapElement** aResult);

Просмотреть файл

@ -25,6 +25,7 @@ class nsIDOMHTMLCollection;
class nsIDOMHTMLFormElement;
class nsIDOMHTMLMapElement;
class nsIHTMLStyleSheet;
class nsIStyleSheet;
/* b2a848b0-d0a9-11d1-89b1-006008911b81 */
#define NS_IHTMLDOCUMENT_IID \
@ -48,6 +49,8 @@ public:
NS_IMETHOD GetImageMap(const nsString& aMapName,
nsIDOMHTMLMapElement** aResult) = 0;
NS_IMETHOD RemoveImageMap(nsIDOMHTMLMapElement* aMap) = 0;
NS_IMETHOD AddForm(nsIDOMHTMLFormElement* aForm) = 0;
NS_IMETHOD GetForms(nsIDOMHTMLCollection** aForms) = 0;

Просмотреть файл

@ -609,9 +609,6 @@ basefont {
head {
display: none;
}
map {
display: none;
}
meta {
display: none;
}

Просмотреть файл

@ -2899,56 +2899,65 @@ nsCSSFrameConstructor::ConstructFrame(nsIPresContext* aPresContext,
return rv;
}
// XXX we need aFrameSubTree's prev-sibling in order to properly
// place its replacement!
NS_IMETHODIMP
nsCSSFrameConstructor::ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree)
NS_IMETHODIMP
nsCSSFrameConstructor::ReconstructDocElementHierarchy(nsIPresContext* aPresContext)
{
nsresult rv = NS_OK;
nsIDocument* document;
rv = aContent->GetDocument(document);
if (NS_FAILED(rv)) {
return rv;
}
if (nsnull != document) {
nsCOMPtr<nsIPresShell> shell;
rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv)) {
// XXX This API needs changing, because it appears to be designed for
// an arbitrary content element, but yet it always constructs the document
// element's frame. Plus it has the problem noted above in the previous XXX
rv = aParentFrame->RemoveFrame(*aPresContext, *shell,
nsnull, aFrameSubTree);
// XXX Remove any existing fixed items...
if (nsnull != mDocument) {
nsCOMPtr<nsIContent> rootContent(dont_AddRef(mDocument->GetRootContent()));
if (rootContent) {
nsCOMPtr<nsIPresShell> shell;
rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv)) {
nsIFrame* newChild;
nsCOMPtr<nsIStyleContext> rootPseudoStyle;
nsAbsoluteItems fixedItems(nsnull); // XXX FIX ME...
nsIFrame* docElementFrame;
// Get the frame that corresponds to the document element
shell->GetPrimaryFrameFor(rootContent, &docElementFrame);
aParentFrame->GetStyleContext(getter_AddRefs(rootPseudoStyle));
rv = ConstructDocElementFrame(aPresContext, aContent,
aParentFrame, rootPseudoStyle, newChild,
fixedItems);
// XXX Do something with the fixed items...
if (NS_SUCCEEDED(rv)) {
rv = aParentFrame->InsertFrames(*aPresContext, *shell,
nsnull, nsnull, newChild);
if (nsnull != docElementFrame) {
nsIFrame* docParentFrame;
docElementFrame->GetParent(&docParentFrame);
if (nsnull != docParentFrame) {
// Remove the old document element hieararchy
rv = docParentFrame->RemoveFrame(*aPresContext,
*shell,
nsnull,
docElementFrame);
// XXX Remove any existing fixed items...
if (NS_SUCCEEDED(rv)) {
nsIFrame* newChild;
nsCOMPtr<nsIStyleContext> rootPseudoStyle;
nsAbsoluteItems fixedItems(nsnull); // XXX FIX ME...
docParentFrame->GetStyleContext(getter_AddRefs(rootPseudoStyle));
rv = ConstructDocElementFrame(aPresContext, rootContent,
docParentFrame,
rootPseudoStyle, newChild,
fixedItems);
// XXX Do something with the fixed items...
if (NS_SUCCEEDED(rv)) {
rv = docParentFrame->InsertFrames(*aPresContext,
*shell,
nsnull,
nsnull,
newChild);
}
}
}
}
}
}
NS_RELEASE(document);
}
}
return rv;
}
nsIFrame*
nsCSSFrameConstructor::GetFrameFor(nsIPresShell* aPresShell, nsIPresContext* aPresContext,
nsIContent* aContent)
@ -3677,7 +3686,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
nsIFrame* frame;
shell->GetPrimaryFrameFor(aContent, &frame);
PRBool reconstruct = PR_FALSE;
PRBool restyle = PR_FALSE;
PRBool reflow = PR_FALSE;
PRBool reframe = PR_FALSE;
@ -3704,6 +3714,9 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
switch (aHint) {
default:
case NS_STYLE_HINT_RECONSTRUCT_ALL:
reconstruct = PR_TRUE;
break;
case NS_STYLE_HINT_UNKNOWN:
case NS_STYLE_HINT_FRAMECHANGE:
reframe = PR_TRUE;
@ -3720,7 +3733,10 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
}
// apply changes
if (PR_TRUE == reframe) {
if (PR_TRUE == reconstruct) {
ReconstructDocElementHierarchy(aPresContext);
}
else if (PR_TRUE == reframe) {
RecreateFramesForContent(aPresContext, aContent);
}
else if (PR_TRUE == restyle) {

Просмотреть файл

@ -50,10 +50,7 @@ public:
nsIContent* aDocElement,
nsIFrame*& aNewFrame);
NS_IMETHODIMP ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree);
NS_IMETHOD ReconstructDocElementHierarchy(nsIPresContext* aPresContext);
NS_IMETHOD ContentAppended(nsIPresContext* aPresContext,
nsIContent* aContainer,

Просмотреть файл

@ -34,8 +34,31 @@ for (var i = 0; i < a.length-1; i++) {
}
</SCRIPT>
</SELECT>
element's
</P>
<P>
shape attribute to
<SELECT SIZE="1" NAME="shape">
<OPTION SELECTED VALUE="rect">rect</OPTION>
<OPTION VALUE="circle">circle</OPTION>
<OPTION VALUE="poly">poly</OPTION>
<OPTION VALUE="default">default</OPTION>
</SELECT>
<INPUT TYPE="button" VALUE="Change Shape" onClick="changeElementShape(); return true;">
(turn on visual debugging in the viewer to see the area boundaries)
</P>
</FORM>
<SCRIPT>
var nth = new Array("upper_left", "middle_middle", "lower_middle",
"upper_middle", "middle_left", "lower_right",
"lower_left", "middle_right", "upper_right",
"left_brown", "top_brown", "right_brown");
var shapes = new Array("rect", "circle", "poly", "default");
function changeElementShape() {
var area = document.getElementById(nth[document.forms[0].nth.selectedIndex]);
area.shape = shapes[document.forms[0].shape.selectedIndex];
}
</SCRIPT>
</BODY>
</HTML>

Просмотреть файл

@ -89,10 +89,7 @@ public:
NS_IMETHOD ConstructRootFrame(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame*& aFrameSubTree);
NS_IMETHOD ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree);
NS_IMETHOD ReconstructDocElementHierarchy(nsIPresContext* aPresContext);
NS_IMETHOD ContentAppended(nsIPresContext* aPresContext,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer);
@ -728,13 +725,9 @@ NS_IMETHODIMP StyleSetImpl::ConstructRootFrame(nsIPresContext* aPresContext,
}
NS_IMETHODIMP
StyleSetImpl::ReconstructFrames(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIFrame* aFrameSubTree)
StyleSetImpl::ReconstructDocElementHierarchy(nsIPresContext* aPresContext)
{
return mFrameConstructor->ReconstructFrames(aPresContext, aContent,
aParentFrame, aFrameSubTree);
return mFrameConstructor->ReconstructDocElementHierarchy(aPresContext);
}
NS_IMETHODIMP StyleSetImpl::ContentAppended(nsIPresContext* aPresContext,

Просмотреть файл

@ -609,9 +609,6 @@ basefont {
head {
display: none;
}
map {
display: none;
}
meta {
display: none;
}