Implement a content model view for <outliner>.
r=bryner sr=hyatt
This commit is contained in:
varga%utcru.sk 2001-11-30 04:41:55 +00:00
Родитель e8ba05adf2
Коммит 6506cc314e
19 изменённых файлов: 3500 добавлений и 84 удалений

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

@ -98,7 +98,10 @@ XUL_ATOM(focus, "focus")
XUL_ATOM(outliner, "outliner")
XUL_ATOM(outlinerbody, "outlinerbody")
XUL_ATOM(outlinercol, "outlinercol")
XUL_ATOM(outlinerchildren, "outlinerchildren")
XUL_ATOM(outlineritem, "outlineritem")
XUL_ATOM(outlinerrow, "outlinerrow")
XUL_ATOM(outlinerseparator, "outlinerseparator")
XUL_ATOM(outlinercell, "outlinercell")
XUL_ATOM(cycler, "cycler")

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

@ -7790,6 +7790,14 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext,
PRInt32 namespaceID;
bindingManager->ResolveTag(aContainer, &namespaceID, getter_AddRefs(tag));
// Just ignore outliner tags, anyway we don't create any frames for them.
if (tag == nsXULAtoms::outlineritem ||
tag == nsXULAtoms::outlinerseparator ||
tag == nsXULAtoms::outlinerchildren ||
tag == nsXULAtoms::outlinerrow ||
tag == nsXULAtoms::outlinercell)
return NS_OK;
PRBool treeChildren = tag.get() == nsXULAtoms::treechildren;
PRBool treeItem = tag.get() == nsXULAtoms::treeitem;
@ -8370,6 +8378,14 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext,
PRInt32 namespaceID;
bindingManager->ResolveTag(aContainer, &namespaceID, getter_AddRefs(tag));
// Just ignore outliner tags, anyway we don't create any frames for them.
if (tag == nsXULAtoms::outlineritem ||
tag == nsXULAtoms::outlinerseparator ||
tag == nsXULAtoms::outlinerchildren ||
tag == nsXULAtoms::outlinerrow ||
tag == nsXULAtoms::outlinercell)
return NS_OK;
PRBool treeChildren = tag && tag.get() == nsXULAtoms::treechildren;
PRBool treeItem = tag && tag.get() == nsXULAtoms::treeitem;
if (treeChildren || treeItem) {
@ -9228,6 +9244,14 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext,
PRInt32 namespaceID;
bindingManager->ResolveTag(aContainer, &namespaceID, getter_AddRefs(tag));
// Just ignore outliner tags, anyway we don't create any frames for them.
if (tag == nsXULAtoms::outlineritem ||
tag == nsXULAtoms::outlinerseparator ||
tag == nsXULAtoms::outlinerchildren ||
tag == nsXULAtoms::outlinerrow ||
tag == nsXULAtoms::outlinercell)
return NS_OK;
PRBool treeChildren = tag && tag.get() == nsXULAtoms::treechildren;
PRBool treeItem = tag && tag.get() == nsXULAtoms::treeitem;

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

@ -7790,6 +7790,14 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext,
PRInt32 namespaceID;
bindingManager->ResolveTag(aContainer, &namespaceID, getter_AddRefs(tag));
// Just ignore outliner tags, anyway we don't create any frames for them.
if (tag == nsXULAtoms::outlineritem ||
tag == nsXULAtoms::outlinerseparator ||
tag == nsXULAtoms::outlinerchildren ||
tag == nsXULAtoms::outlinerrow ||
tag == nsXULAtoms::outlinercell)
return NS_OK;
PRBool treeChildren = tag.get() == nsXULAtoms::treechildren;
PRBool treeItem = tag.get() == nsXULAtoms::treeitem;
@ -8370,6 +8378,14 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext,
PRInt32 namespaceID;
bindingManager->ResolveTag(aContainer, &namespaceID, getter_AddRefs(tag));
// Just ignore outliner tags, anyway we don't create any frames for them.
if (tag == nsXULAtoms::outlineritem ||
tag == nsXULAtoms::outlinerseparator ||
tag == nsXULAtoms::outlinerchildren ||
tag == nsXULAtoms::outlinerrow ||
tag == nsXULAtoms::outlinercell)
return NS_OK;
PRBool treeChildren = tag && tag.get() == nsXULAtoms::treechildren;
PRBool treeItem = tag && tag.get() == nsXULAtoms::treeitem;
if (treeChildren || treeItem) {
@ -9228,6 +9244,14 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext,
PRInt32 namespaceID;
bindingManager->ResolveTag(aContainer, &namespaceID, getter_AddRefs(tag));
// Just ignore outliner tags, anyway we don't create any frames for them.
if (tag == nsXULAtoms::outlineritem ||
tag == nsXULAtoms::outlinerseparator ||
tag == nsXULAtoms::outlinerchildren ||
tag == nsXULAtoms::outlinerrow ||
tag == nsXULAtoms::outlinercell)
return NS_OK;
PRBool treeChildren = tag && tag.get() == nsXULAtoms::treechildren;
PRBool treeItem = tag && tag.get() == nsXULAtoms::treeitem;

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

@ -33,6 +33,7 @@ XPIDLSRCS= nsIOutlinerView.idl \
nsIOutlinerSelection.idl \
nsIOutlinerBoxObject.idl \
nsIOutlinerColFrame.idl \
nsIOutlinerContentView.idl \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

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

@ -25,6 +25,7 @@ XPIDLSRCS= .\nsIOutlinerView.idl \
.\nsIOutlinerSelection.idl \
.\nsIOutlinerBoxObject.idl \
.\nsIOutlinerColFrame.idl \
.\nsIOutlinerContentView.idl \
$(NULL)
MODULE=layout_xul

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

@ -0,0 +1,59 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jan Varga (varga@utcru.sk)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIDOMElement.idl"
[scriptable, uuid(F066F69A-6FFE-4117-A85C-ABE9D15C6BBC)]
interface nsIOutlinerContentView : nsISupports
{
/**
* The element in the DOM which this view uses as root content.
*/
attribute nsIDOMElement root;
/**
* Retrieve the content item associated with the specified index.
*/
nsIDOMElement getItemAtIndex(in long index);
/**
* Retrieve the index associated with the specified content item.
*/
long getIndexOfItem(in nsIDOMElement item);
};

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

@ -49,12 +49,16 @@ CPPSRCS = \
nsOutlinerBoxObject.cpp \
nsOutlinerColFrame.cpp \
nsOutlinerSelection.cpp \
nsOutlinerUtils.cpp \
nsOutlinerContentView.cpp \
$(NULL)
EXPORTS = \
nsOutlinerBodyFrame.h \
nsOutlinerColFrame.h \
nsOutlinerSelection.h \
nsOutlinerUtils.h \
nsOutlinerContentView.h \
$(NULL)
DEFINES += -D_IMPL_NS_HTML

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

@ -46,6 +46,8 @@ CPPSRCS= \
nsOutlinerBodyFrame.cpp \
nsOutlinerColFrame.cpp \
nsOutlinerSelection.cpp \
nsOutlinerUtils.cpp \
nsOutlinerContentView.cpp \
$(NULL)
CPP_OBJS= \
@ -53,9 +55,12 @@ CPP_OBJS= \
.\$(OBJDIR)\nsOutlinerBodyFrame.obj \
.\$(OBJDIR)\nsOutlinerColFrame.obj \
.\$(OBJDIR)\nsOutlinerSelection.obj \
.\$(OBJDIR)\nsOutlinerUtils.obj \
.\$(OBJDIR)\nsOutlinerContentView.obj \
$(NULL)
EXPORTS = nsOutlinerColFrame.h \
nsOutlinerUtils.h \
$(NULL)
LINCS= \

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

@ -23,6 +23,7 @@
* Original Author: David W. Hyatt (hyatt@netscape.com)
* Ben Goodger <ben@netscape.com>
* Joe Hewitt <hewitt@netscape.com>
* Jan Varga <varga@utcru.sk>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -76,6 +77,7 @@
#include "nsNetUtil.h"
#include "nsBoxLayoutState.h"
#include "nsIDragService.h"
#include "nsOutlinerContentView.h"
#ifdef USE_IMG2
#include "imgIRequest.h"
@ -405,17 +407,33 @@ NS_IMETHODIMP nsOutlinerBodyFrame::Reflow(nsIPresContext* aPresContext,
}
}
// See if there is a XUL outliner builder associated with the
// element. If so, try to make *it* be the view.
// A content model view is always created and hooked up,
// unless there is a XULOutlinerBuilder view.
nsCOMPtr<nsIDOMXULElement> xulele = do_QueryInterface(mContent);
if (xulele) {
nsCOMPtr<nsIOutlinerView> view;
// First, see if there is a XUL outliner builder
// associated with the element.
nsCOMPtr<nsIXULTemplateBuilder> builder;
xulele->GetBuilder(getter_AddRefs(builder));
if (builder) {
nsCOMPtr<nsIOutlinerView> view = do_QueryInterface(builder);
if (view)
SetView(view);
if (builder)
view = do_QueryInterface(builder);
else {
// No builder, create a outliner content model view.
nsCOMPtr<nsIOutlinerContentView> contentView;
NS_NewOutlinerContentView(getter_AddRefs(contentView));
if (contentView) {
contentView->SetRoot(xulele);
view = do_QueryInterface(contentView);
}
}
// Hook up the view.
if (view)
SetView(view);
}
}
@ -785,39 +803,6 @@ NS_IMETHODIMP nsOutlinerBodyFrame::GetCellAt(PRInt32 aX, PRInt32 aY, PRInt32* aR
PRInt32 x, y;
AdjustEventCoordsToBoxCoordSpace ( aX, aY, &x, &y );
#if 0
// Convert our x and y coords to twips.
float pixelsToTwips = 0.0;
mPresContext->GetPixelsToTwips(&pixelsToTwips);
aX = NSToIntRound(aX * pixelsToTwips);
aY = NSToIntRound(aY * pixelsToTwips);
// Get our box object.
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(*getter_AddRefs(doc));
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mContent));
nsCOMPtr<nsIBoxObject> boxObject;
nsDoc->GetBoxObjectFor(elt, getter_AddRefs(boxObject));
PRInt32 x;
PRInt32 y;
boxObject->GetX(&x);
boxObject->GetY(&y);
x = NSToIntRound(x * pixelsToTwips);
y = NSToIntRound(y * pixelsToTwips);
// Adjust into our coordinate space.
x = aX-x;
y = aY-y;
// Adjust y by the inner box y, so that we're in the inner box's
// coordinate space.
y += mInnerBox.y;
#endif
// Now just mod by our total inner box height and add to our top row index.
*aRow = (y/mRowHeight)+mTopRowIndex;
@ -1690,7 +1675,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintRow(int aRowIndex, const nsRect& aRowRec
aRenderingContext.PushState();
PRUint8 side = NS_SIDE_TOP;
PRInt32 y = rowRect.y + rowRect.height / 2;
nscoord currY = rowRect.y + rowRect.height / 2;
for (PRInt32 i = 0; i < 2; i++) {
nscolor color;
PRBool transparent; PRBool foreground;
@ -1700,10 +1685,10 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintRow(int aRowIndex, const nsRect& aRowRec
style = borderStyle->GetBorderStyle(side);
aRenderingContext.SetLineStyle(ConvertBorderStyleToLineStyle(style));
aRenderingContext.DrawLine(rowRect.x, y, rowRect.x + rowRect.width, y);
aRenderingContext.DrawLine(rowRect.x, currY, rowRect.x + rowRect.width, currY);
side = NS_SIDE_BOTTOM;
y = y + 16;
currY += 16;
}
PRBool clipState;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,194 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jan Varga (varga@utcru.sk)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsOutlinerContentView_h__
#define nsOutlinerContentView_h__
#include "nsCOMPtr.h"
#include "nsFixedSizeAllocator.h"
#include "nsVoidArray.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDocumentObserver.h"
#include "nsIOutlinerView.h"
#include "nsIOutlinerBoxObject.h"
#include "nsIOutlinerSelection.h"
#include "nsIOutlinerContentView.h"
class Property;
class nsOutlinerContentView : public nsIOutlinerView,
public nsIOutlinerContentView,
public nsIDocumentObserver
{
public:
nsOutlinerContentView(void);
virtual ~nsOutlinerContentView(void);
friend nsresult NS_NewOutlinerContentView(nsIOutlinerContentView** aResult);
NS_DECL_ISUPPORTS
NS_DECL_NSIOUTLINERVIEW
NS_DECL_NSIOUTLINERCONTENTVIEW
// nsIDocumentObserver
NS_IMETHOD BeginUpdate(nsIDocument *aDocument);
NS_IMETHOD EndUpdate(nsIDocument *aDocument);
NS_IMETHOD BeginLoad(nsIDocument *aDocument);
NS_IMETHOD EndLoad(nsIDocument *aDocument);
NS_IMETHOD BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell);
NS_IMETHOD EndReflow(nsIDocument *aDocument, nsIPresShell* aShell);
NS_IMETHOD ContentChanged(nsIDocument *aDocument,
nsIContent* aContent,
nsISupports* aSubContent);
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
nsIContent* aContent1,
nsIContent* aContent2);
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
nsIContent* aContent,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType,
PRInt32 aHint);
NS_IMETHOD ContentAppended(nsIDocument *aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer);
NS_IMETHOD ContentInserted(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aOldChild,
nsIContent* aNewChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet);
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet);
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
PRBool aDisabled);
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule,
PRInt32 aHint);
NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule);
NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule);
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument);
protected:
// Recursive methods which deal with serializing of nested content.
void Serialize(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows);
void SerializeItem(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows);
void SerializeSeparator(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows);
void GetIndexInSubtree(nsIContent* aContainer, nsIContent* aContent, PRInt32* aResult);
// Helper methods which we use to manage our plain array of rows.
void EnsureSubtree(PRInt32 aIndex, PRInt32* aCount);
void RemoveSubtree(PRInt32 aIndex, PRInt32* aCount);
void InsertRow(PRInt32 aParentIndex, PRInt32 aIndex, nsIContent* aContent, PRInt32* aCount);
void RemoveRow(PRInt32 aIndex, PRInt32* aCount);
void ClearRows();
void OpenContainer(PRInt32 aIndex);
void CloseContainer(PRInt32 aIndex);
PRInt32 FindContent(nsIContent* aContent);
void UpdateSubtreeSizes(PRInt32 aIndex, PRInt32 aCount);
void UpdateParentIndexes(PRInt32 aIndex, PRInt32 aSkip, PRInt32 aCount);
// Content helpers.
nsresult GetImmediateChild(nsIContent* aContainer, nsIAtom* aTag, nsIContent** aResult);
nsresult GetColIndex(const PRUnichar* aColID, PRInt32* aResult);
nsresult GetNamedCell(nsIContent* aContainer, const PRUnichar* aColID, nsIContent** aResult);
nsresult ParseProperties(nsIContent* aContent, Property** aProperty);
private:
nsCOMPtr<nsIOutlinerBoxObject> mBoxObject;
nsCOMPtr<nsIOutlinerSelection> mSelection;
nsCOMPtr<nsIContent> mRoot;
nsIDocument* mDocument; // WEAK
nsFixedSizeAllocator mAllocator;
nsVoidArray mRows;
};
#endif // nsOutlinerContentView_h__

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

@ -0,0 +1,80 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Waterson <waterson@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsOutlinerUtils.h"
nsresult
nsOutlinerUtils::TokenizeProperties(const nsAString& aProperties, nsISupportsArray* aPropertiesArray)
{
NS_PRECONDITION(aPropertiesArray != nsnull, "null ptr");
if (! aPropertiesArray)
return NS_ERROR_NULL_POINTER;
nsAString::const_iterator end;
aProperties.EndReading(end);
nsAString::const_iterator iter;
aProperties.BeginReading(iter);
do {
// Skip whitespace
while (iter != end && nsCRT::IsAsciiSpace(*iter))
++iter;
// If only whitespace, we're done
if (iter == end)
break;
// Note the first non-whitespace character
nsAString::const_iterator first = iter;
// Advance to the next whitespace character
while (iter != end && ! nsCRT::IsAsciiSpace(*iter))
++iter;
// XXX this would be nonsensical
NS_ASSERTION(iter != first, "eh? something's wrong here");
if (iter == first)
break;
nsCOMPtr<nsIAtom> atom = dont_AddRef(NS_NewAtom(Substring(first, iter)));
aPropertiesArray->AppendElement(atom);
} while (iter != end);
return NS_OK;
}

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

@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Waterson <waterson@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsOutlinerUtils_h__
#define nsOutlinerUtils_h__
#include "nsString.h"
#include "nsISupportsArray.h"
class nsOutlinerUtils
{
public:
/**
* Parse a whitespace separated list of properties into an array
* of atoms.
*/
static nsresult
TokenizeProperties(const nsAString& aProperties, nsISupportsArray* aPropertiesArray);
};
#endif // nsOutlinerUtils_h__

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

@ -0,0 +1,59 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jan Varga (varga@utcru.sk)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIDOMElement.idl"
[scriptable, uuid(F066F69A-6FFE-4117-A85C-ABE9D15C6BBC)]
interface nsIOutlinerContentView : nsISupports
{
/**
* The element in the DOM which this view uses as root content.
*/
attribute nsIDOMElement root;
/**
* Retrieve the content item associated with the specified index.
*/
nsIDOMElement getItemAtIndex(in long index);
/**
* Retrieve the index associated with the specified content item.
*/
long getIndexOfItem(in nsIDOMElement item);
};

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

@ -23,6 +23,7 @@
* Original Author: David W. Hyatt (hyatt@netscape.com)
* Ben Goodger <ben@netscape.com>
* Joe Hewitt <hewitt@netscape.com>
* Jan Varga <varga@utcru.sk>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -76,6 +77,7 @@
#include "nsNetUtil.h"
#include "nsBoxLayoutState.h"
#include "nsIDragService.h"
#include "nsOutlinerContentView.h"
#ifdef USE_IMG2
#include "imgIRequest.h"
@ -405,17 +407,33 @@ NS_IMETHODIMP nsOutlinerBodyFrame::Reflow(nsIPresContext* aPresContext,
}
}
// See if there is a XUL outliner builder associated with the
// element. If so, try to make *it* be the view.
// A content model view is always created and hooked up,
// unless there is a XULOutlinerBuilder view.
nsCOMPtr<nsIDOMXULElement> xulele = do_QueryInterface(mContent);
if (xulele) {
nsCOMPtr<nsIOutlinerView> view;
// First, see if there is a XUL outliner builder
// associated with the element.
nsCOMPtr<nsIXULTemplateBuilder> builder;
xulele->GetBuilder(getter_AddRefs(builder));
if (builder) {
nsCOMPtr<nsIOutlinerView> view = do_QueryInterface(builder);
if (view)
SetView(view);
if (builder)
view = do_QueryInterface(builder);
else {
// No builder, create a outliner content model view.
nsCOMPtr<nsIOutlinerContentView> contentView;
NS_NewOutlinerContentView(getter_AddRefs(contentView));
if (contentView) {
contentView->SetRoot(xulele);
view = do_QueryInterface(contentView);
}
}
// Hook up the view.
if (view)
SetView(view);
}
}
@ -785,39 +803,6 @@ NS_IMETHODIMP nsOutlinerBodyFrame::GetCellAt(PRInt32 aX, PRInt32 aY, PRInt32* aR
PRInt32 x, y;
AdjustEventCoordsToBoxCoordSpace ( aX, aY, &x, &y );
#if 0
// Convert our x and y coords to twips.
float pixelsToTwips = 0.0;
mPresContext->GetPixelsToTwips(&pixelsToTwips);
aX = NSToIntRound(aX * pixelsToTwips);
aY = NSToIntRound(aY * pixelsToTwips);
// Get our box object.
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(*getter_AddRefs(doc));
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mContent));
nsCOMPtr<nsIBoxObject> boxObject;
nsDoc->GetBoxObjectFor(elt, getter_AddRefs(boxObject));
PRInt32 x;
PRInt32 y;
boxObject->GetX(&x);
boxObject->GetY(&y);
x = NSToIntRound(x * pixelsToTwips);
y = NSToIntRound(y * pixelsToTwips);
// Adjust into our coordinate space.
x = aX-x;
y = aY-y;
// Adjust y by the inner box y, so that we're in the inner box's
// coordinate space.
y += mInnerBox.y;
#endif
// Now just mod by our total inner box height and add to our top row index.
*aRow = (y/mRowHeight)+mTopRowIndex;
@ -1690,7 +1675,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintRow(int aRowIndex, const nsRect& aRowRec
aRenderingContext.PushState();
PRUint8 side = NS_SIDE_TOP;
PRInt32 y = rowRect.y + rowRect.height / 2;
nscoord currY = rowRect.y + rowRect.height / 2;
for (PRInt32 i = 0; i < 2; i++) {
nscolor color;
PRBool transparent; PRBool foreground;
@ -1700,10 +1685,10 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintRow(int aRowIndex, const nsRect& aRowRec
style = borderStyle->GetBorderStyle(side);
aRenderingContext.SetLineStyle(ConvertBorderStyleToLineStyle(style));
aRenderingContext.DrawLine(rowRect.x, y, rowRect.x + rowRect.width, y);
aRenderingContext.DrawLine(rowRect.x, currY, rowRect.x + rowRect.width, currY);
side = NS_SIDE_BOTTOM;
y = y + 16;
currY += 16;
}
PRBool clipState;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,194 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jan Varga (varga@utcru.sk)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsOutlinerContentView_h__
#define nsOutlinerContentView_h__
#include "nsCOMPtr.h"
#include "nsFixedSizeAllocator.h"
#include "nsVoidArray.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDocumentObserver.h"
#include "nsIOutlinerView.h"
#include "nsIOutlinerBoxObject.h"
#include "nsIOutlinerSelection.h"
#include "nsIOutlinerContentView.h"
class Property;
class nsOutlinerContentView : public nsIOutlinerView,
public nsIOutlinerContentView,
public nsIDocumentObserver
{
public:
nsOutlinerContentView(void);
virtual ~nsOutlinerContentView(void);
friend nsresult NS_NewOutlinerContentView(nsIOutlinerContentView** aResult);
NS_DECL_ISUPPORTS
NS_DECL_NSIOUTLINERVIEW
NS_DECL_NSIOUTLINERCONTENTVIEW
// nsIDocumentObserver
NS_IMETHOD BeginUpdate(nsIDocument *aDocument);
NS_IMETHOD EndUpdate(nsIDocument *aDocument);
NS_IMETHOD BeginLoad(nsIDocument *aDocument);
NS_IMETHOD EndLoad(nsIDocument *aDocument);
NS_IMETHOD BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell);
NS_IMETHOD EndReflow(nsIDocument *aDocument, nsIPresShell* aShell);
NS_IMETHOD ContentChanged(nsIDocument *aDocument,
nsIContent* aContent,
nsISupports* aSubContent);
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
nsIContent* aContent1,
nsIContent* aContent2);
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
nsIContent* aContent,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType,
PRInt32 aHint);
NS_IMETHOD ContentAppended(nsIDocument *aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer);
NS_IMETHOD ContentInserted(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aOldChild,
nsIContent* aNewChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet);
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet);
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
PRBool aDisabled);
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule,
PRInt32 aHint);
NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule);
NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule);
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument);
protected:
// Recursive methods which deal with serializing of nested content.
void Serialize(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows);
void SerializeItem(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows);
void SerializeSeparator(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows);
void GetIndexInSubtree(nsIContent* aContainer, nsIContent* aContent, PRInt32* aResult);
// Helper methods which we use to manage our plain array of rows.
void EnsureSubtree(PRInt32 aIndex, PRInt32* aCount);
void RemoveSubtree(PRInt32 aIndex, PRInt32* aCount);
void InsertRow(PRInt32 aParentIndex, PRInt32 aIndex, nsIContent* aContent, PRInt32* aCount);
void RemoveRow(PRInt32 aIndex, PRInt32* aCount);
void ClearRows();
void OpenContainer(PRInt32 aIndex);
void CloseContainer(PRInt32 aIndex);
PRInt32 FindContent(nsIContent* aContent);
void UpdateSubtreeSizes(PRInt32 aIndex, PRInt32 aCount);
void UpdateParentIndexes(PRInt32 aIndex, PRInt32 aSkip, PRInt32 aCount);
// Content helpers.
nsresult GetImmediateChild(nsIContent* aContainer, nsIAtom* aTag, nsIContent** aResult);
nsresult GetColIndex(const PRUnichar* aColID, PRInt32* aResult);
nsresult GetNamedCell(nsIContent* aContainer, const PRUnichar* aColID, nsIContent** aResult);
nsresult ParseProperties(nsIContent* aContent, Property** aProperty);
private:
nsCOMPtr<nsIOutlinerBoxObject> mBoxObject;
nsCOMPtr<nsIOutlinerSelection> mSelection;
nsCOMPtr<nsIContent> mRoot;
nsIDocument* mDocument; // WEAK
nsFixedSizeAllocator mAllocator;
nsVoidArray mRows;
};
#endif // nsOutlinerContentView_h__

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

@ -0,0 +1,80 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Waterson <waterson@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsOutlinerUtils.h"
nsresult
nsOutlinerUtils::TokenizeProperties(const nsAString& aProperties, nsISupportsArray* aPropertiesArray)
{
NS_PRECONDITION(aPropertiesArray != nsnull, "null ptr");
if (! aPropertiesArray)
return NS_ERROR_NULL_POINTER;
nsAString::const_iterator end;
aProperties.EndReading(end);
nsAString::const_iterator iter;
aProperties.BeginReading(iter);
do {
// Skip whitespace
while (iter != end && nsCRT::IsAsciiSpace(*iter))
++iter;
// If only whitespace, we're done
if (iter == end)
break;
// Note the first non-whitespace character
nsAString::const_iterator first = iter;
// Advance to the next whitespace character
while (iter != end && ! nsCRT::IsAsciiSpace(*iter))
++iter;
// XXX this would be nonsensical
NS_ASSERTION(iter != first, "eh? something's wrong here");
if (iter == first)
break;
nsCOMPtr<nsIAtom> atom = dont_AddRef(NS_NewAtom(Substring(first, iter)));
aPropertiesArray->AppendElement(atom);
} while (iter != end);
return NS_OK;
}

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

@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Waterson <waterson@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsOutlinerUtils_h__
#define nsOutlinerUtils_h__
#include "nsString.h"
#include "nsISupportsArray.h"
class nsOutlinerUtils
{
public:
/**
* Parse a whitespace separated list of properties into an array
* of atoms.
*/
static nsresult
TokenizeProperties(const nsAString& aProperties, nsISupportsArray* aPropertiesArray);
};
#endif // nsOutlinerUtils_h__