mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
- Implement the :checked CSS pseudoclass which maps to the "selected" property on option elements.
- Eliminate the _moz-option-selected attribute; move the actual selected state into the option content node. - Change all users of _moz-option-selected to use :checked. - Add a third parameter to nsIDocument[Observer]::ContentStatesChanged to indicate which pseudoclass changed, this is used for optimizing handling of :checked state changes. Bug 128947, r=dbaron, sr=jst, a=asa.
This commit is contained in:
parent
fefe11a9c3
commit
d2229cbf68
@ -318,7 +318,8 @@ public:
|
||||
// notify that one or two content nodes changed state
|
||||
// either may be nsnull, but not both
|
||||
NS_IMETHOD ContentStatesChanged(nsIContent* aContent1,
|
||||
nsIContent* aContent2) = 0;
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass) = 0;
|
||||
NS_IMETHOD AttributeWillChange(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute) = 0;
|
||||
|
@ -138,7 +138,8 @@ public:
|
||||
*/
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) = 0;
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the content model has changed. This method is called
|
||||
|
@ -90,9 +90,10 @@ struct RuleProcessorData {
|
||||
PRPackedBool mIsHTMLContent; // if content, then does QI on HTMLContent, true or false
|
||||
PRPackedBool mIsHTMLLink; // if content, calls nsStyleUtil::IsHTMLLink
|
||||
PRPackedBool mIsSimpleXLink; // if content, calls nsStyleUtil::IsSimpleXLink
|
||||
nsLinkState mLinkState; // if a link, this is the state, otherwise unknown
|
||||
PRPackedBool mIsQuirkMode; // Possibly remove use of this in SelectorMatches?
|
||||
PRPackedBool mHasAttributes; // if content, content->GetAttrCount() > 0
|
||||
PRPackedBool mIsChecked; // checked/selected attribute for option and select elements
|
||||
nsLinkState mLinkState; // if a link, this is the state, otherwise unknown
|
||||
PRInt32 mEventState; // if content, eventStateMgr->GetContentState()
|
||||
PRInt32 mNameSpaceID; // if content, content->GetNameSapce()
|
||||
RuleProcessorData* mPreviousSiblingData;
|
||||
|
@ -138,7 +138,8 @@ public:
|
||||
nsISupports* aSubContent) { return NS_OK; }
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) { return NS_OK; }
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass) { return NS_OK; }
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -1847,14 +1847,15 @@ nsDocument::ContentChanged(nsIContent* aContent,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::ContentStatesChanged(nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
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->ContentStatesChanged(this, aContent1, aContent2);
|
||||
observer->ContentStatesChanged(this, aContent1, aContent2, aChangedPseudoClass);
|
||||
// Make sure that the observer didn't remove itself during the
|
||||
// notification. If it did, update our index and count.
|
||||
if (i < mObservers.Count() &&
|
||||
|
@ -162,7 +162,8 @@ public:
|
||||
nsISupports* aSubContent) { return NS_OK; }
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) { return NS_OK; }
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass) { return NS_OK; }
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
@ -452,7 +453,8 @@ public:
|
||||
NS_IMETHOD ContentChanged(nsIContent* aContent,
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
|
||||
NS_IMETHOD AttributeWillChange(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -206,7 +206,8 @@ public:
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
@ -1476,9 +1477,11 @@ StyleSetImpl::ContentChanged(nsIPresContext* aPresContext,
|
||||
NS_IMETHODIMP
|
||||
StyleSetImpl::ContentStatesChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
return mFrameConstructor->ContentStatesChanged(aPresContext, aContent1, aContent2);
|
||||
return mFrameConstructor->ContentStatesChanged(aPresContext, aContent1, aContent2,
|
||||
aChangedPseudoClass);
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,6 +110,7 @@
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsCSSAtoms.h"
|
||||
|
||||
#if defined(DEBUG_rods) || defined(DEBUG_bryner)
|
||||
//#define DEBUG_DOCSHELL_FOCUS
|
||||
@ -3528,16 +3529,16 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState)
|
||||
if (newHover) {
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
newHover->GetParent(*getter_AddRefs(parent));
|
||||
doc1->ContentStatesChanged(newHover, parent);
|
||||
doc1->ContentStatesChanged(newHover, parent, nsCSSAtoms::hoverPseudo);
|
||||
while (parent && parent != commonHoverParent) {
|
||||
parent->GetParent(*getter_AddRefs(newHover));
|
||||
if (newHover && newHover != commonHoverParent) {
|
||||
newHover->GetParent(*getter_AddRefs(parent));
|
||||
if (parent == commonHoverParent) {
|
||||
doc1->ContentStatesChanged(newHover, nsnull);
|
||||
doc1->ContentStatesChanged(newHover, nsnull, nsCSSAtoms::hoverPseudo);
|
||||
}
|
||||
else {
|
||||
doc1->ContentStatesChanged(newHover, parent);
|
||||
doc1->ContentStatesChanged(newHover, parent, nsCSSAtoms::hoverPseudo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -3549,16 +3550,16 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState)
|
||||
if (oldHover) {
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
oldHover->GetParent(*getter_AddRefs(parent));
|
||||
doc1->ContentStatesChanged(oldHover, parent);
|
||||
doc1->ContentStatesChanged(oldHover, parent, nsCSSAtoms::hoverPseudo);
|
||||
while (parent && parent != commonHoverParent) {
|
||||
parent->GetParent(*getter_AddRefs(oldHover));
|
||||
if (oldHover && oldHover != commonHoverParent) {
|
||||
oldHover->GetParent(*getter_AddRefs(parent));
|
||||
if (parent == commonHoverParent) {
|
||||
doc1->ContentStatesChanged(oldHover, nsnull);
|
||||
doc1->ContentStatesChanged(oldHover, nsnull, nsCSSAtoms::hoverPseudo);
|
||||
}
|
||||
else {
|
||||
doc1->ContentStatesChanged(oldHover, parent);
|
||||
doc1->ContentStatesChanged(oldHover, parent, nsCSSAtoms::hoverPseudo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -3567,23 +3568,23 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState)
|
||||
}
|
||||
}
|
||||
|
||||
doc1->ContentStatesChanged(notifyContent[0], notifyContent[1]);
|
||||
doc1->ContentStatesChanged(notifyContent[0], notifyContent[1], nsnull);
|
||||
if (notifyContent[2]) { // more that two notifications are needed (should be rare)
|
||||
// XXX a further optimization here would be to group the notification pairs
|
||||
// together by parent/child, only needed if more than two content changed
|
||||
// (ie: if [0] and [2] are parent/child, then notify (0,2) (1,3))
|
||||
doc1->ContentStatesChanged(notifyContent[2], notifyContent[3]);
|
||||
doc1->ContentStatesChanged(notifyContent[2], notifyContent[3], nsnull);
|
||||
if (notifyContent[4]) { // more that two notifications are needed (should be rare)
|
||||
doc1->ContentStatesChanged(notifyContent[4], nsnull);
|
||||
doc1->ContentStatesChanged(notifyContent[4], nsnull, nsnull);
|
||||
}
|
||||
}
|
||||
doc1->EndUpdate();
|
||||
|
||||
if (doc2) {
|
||||
doc2->BeginUpdate();
|
||||
doc2->ContentStatesChanged(notifyContent[1], notifyContent[2]);
|
||||
doc2->ContentStatesChanged(notifyContent[1], notifyContent[2], nsnull);
|
||||
if (notifyContent[3]) {
|
||||
doc1->ContentStatesChanged(notifyContent[3], notifyContent[4]);
|
||||
doc1->ContentStatesChanged(notifyContent[3], notifyContent[4], nsnull);
|
||||
}
|
||||
doc2->EndUpdate();
|
||||
}
|
||||
|
@ -60,13 +60,6 @@ public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IOPTIONELEMENT_IID)
|
||||
|
||||
/**
|
||||
* Check whether the option element is selected from its own point
|
||||
* of view. This should only be used by SelectElement, really.
|
||||
* Everyone else is safe using GetSelected() on the DOMHTMLOptionElement.
|
||||
*/
|
||||
NS_IMETHOD GetSelectedInternal(PRBool* aValue) = 0;
|
||||
|
||||
/**
|
||||
* Check whether the option element is selected from its own point
|
||||
* of view. This should only be used by SelectElement, really.
|
||||
|
@ -68,7 +68,7 @@
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
|
||||
#include "nsCSSAtoms.h"
|
||||
|
||||
class nsHTMLOptionElement : public nsGenericHTMLContainerElement,
|
||||
public nsIDOMHTMLOptionElement,
|
||||
@ -108,7 +108,6 @@ public:
|
||||
#endif
|
||||
|
||||
// nsIOptionElement
|
||||
NS_IMETHOD GetSelectedInternal(PRBool* aValue);
|
||||
NS_IMETHOD SetSelectedInternal(PRBool aValue, PRBool aNotify);
|
||||
NS_IMETHOD GetValueOrText(nsAString& aValue);
|
||||
|
||||
@ -121,7 +120,8 @@ protected:
|
||||
// there's a select associated with this option or not.
|
||||
void GetSelect(nsIDOMHTMLSelectElement **aSelectElement) const;
|
||||
|
||||
PRBool mIsInitialized;
|
||||
PRPackedBool mIsInitialized;
|
||||
PRPackedBool mIsSelected;
|
||||
};
|
||||
|
||||
nsresult
|
||||
@ -170,8 +170,9 @@ NS_NewHTMLOptionElement(nsIHTMLContent** aInstancePtrResult,
|
||||
|
||||
|
||||
nsHTMLOptionElement::nsHTMLOptionElement()
|
||||
: mIsInitialized(PR_FALSE),
|
||||
mIsSelected(PR_FALSE)
|
||||
{
|
||||
mIsInitialized = PR_FALSE;
|
||||
}
|
||||
|
||||
nsHTMLOptionElement::~nsHTMLOptionElement()
|
||||
@ -241,43 +242,16 @@ nsHTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::GetSelectedInternal(PRBool* aValue)
|
||||
{
|
||||
// If it's not initialized, initialize it.
|
||||
if (!mIsInitialized) {
|
||||
mIsInitialized = PR_TRUE;
|
||||
PRBool selected;
|
||||
GetDefaultSelected(&selected);
|
||||
// This does not need to be SetSelected (which sets selected in the select)
|
||||
// because we *will* be initialized when we are placed into a select. Plus
|
||||
// it seems like that's just inviting an infinite loop.
|
||||
SetSelectedInternal(selected, PR_TRUE);
|
||||
}
|
||||
nsAutoString tmpVal;
|
||||
nsresult rv = GetAttr(kNameSpaceID_None,
|
||||
nsLayoutAtoms::optionSelectedPseudo,
|
||||
tmpVal);
|
||||
*aValue = !(NS_FAILED(rv) || NS_CONTENT_ATTR_NOT_THERE == rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::SetSelectedInternal(PRBool aValue, PRBool aNotify)
|
||||
{
|
||||
mIsInitialized = PR_TRUE;
|
||||
mIsSelected = aValue;
|
||||
|
||||
// This affects the display, but what the hey, it's a good place for it
|
||||
if (aValue) {
|
||||
return SetAttr(kNameSpaceID_None,
|
||||
nsLayoutAtoms::optionSelectedPseudo,
|
||||
NS_LITERAL_STRING(""),
|
||||
aNotify);
|
||||
} else {
|
||||
return UnsetAttr(kNameSpaceID_None,
|
||||
nsLayoutAtoms::optionSelectedPseudo,
|
||||
aNotify);
|
||||
}
|
||||
if (aNotify && mDocument)
|
||||
mDocument->ContentStatesChanged(this, nsnull, nsCSSAtoms::checkedPseudo);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -309,8 +283,19 @@ nsHTMLOptionElement::GetSelected(PRBool* aValue)
|
||||
NS_ENSURE_ARG_POINTER(aValue);
|
||||
*aValue = PR_FALSE;
|
||||
|
||||
// If there is no select element, return the selected
|
||||
return GetSelectedInternal(aValue);
|
||||
// If it's not initialized, initialize it.
|
||||
if (!mIsInitialized) {
|
||||
mIsInitialized = PR_TRUE;
|
||||
PRBool selected;
|
||||
GetDefaultSelected(&selected);
|
||||
// This does not need to be SetSelected (which sets selected in the select)
|
||||
// because we *will* be initialized when we are placed into a select. Plus
|
||||
// it seems like that's just inviting an infinite loop.
|
||||
SetSelectedInternal(selected, PR_TRUE);
|
||||
}
|
||||
|
||||
*aValue = mIsSelected;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -438,7 +438,7 @@ nsHTMLSelectElement::InsertOptionsIntoList(nsIContent* aOptions,
|
||||
|
||||
// Actually select the options if the added options warrant it
|
||||
nsCOMPtr<nsIDOMNode> optionNode;
|
||||
nsCOMPtr<nsIOptionElement> option;
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> option;
|
||||
for (PRInt32 i=aListIndex;i<insertIndex;i++) {
|
||||
// Notify the frame that the option is added
|
||||
if (selectFrame) {
|
||||
@ -449,7 +449,7 @@ nsHTMLSelectElement::InsertOptionsIntoList(nsIContent* aOptions,
|
||||
option = do_QueryInterface(optionNode);
|
||||
if (option) {
|
||||
PRBool selected;
|
||||
option->GetSelectedInternal(&selected);
|
||||
option->GetSelected(&selected);
|
||||
if (selected) {
|
||||
// Clear all other options
|
||||
PRBool isMultiple;
|
||||
|
@ -290,7 +290,8 @@ public:
|
||||
nsISupports* aSubContent) { return NS_OK; }
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) { return NS_OK; }
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass) { return NS_OK; }
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -70,6 +70,7 @@
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
#include "nsIDOMHTMLLinkElement.h"
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIDOMCSSStyleSheet.h"
|
||||
#include "nsIDOMCSSStyleRule.h"
|
||||
@ -3232,6 +3233,7 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext,
|
||||
mIsHTMLContent = PR_FALSE;
|
||||
mIsHTMLLink = PR_FALSE;
|
||||
mIsSimpleXLink = PR_FALSE;
|
||||
mIsChecked = PR_FALSE;
|
||||
mLinkState = eLinkState_Unknown;
|
||||
mEventState = NS_EVENT_STATE_UNSPECIFIED;
|
||||
mNameSpaceID = kNameSpaceID_Unknown;
|
||||
@ -3299,6 +3301,15 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext,
|
||||
nsStyleUtil::IsSimpleXlink(aContent, mPresContext, &mLinkState)) {
|
||||
mIsSimpleXLink = PR_TRUE;
|
||||
}
|
||||
|
||||
if (mIsHTMLContent) {
|
||||
PRBool isChecked = PR_FALSE;
|
||||
if (mContentTag == nsHTMLAtoms::option) {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optEl = do_QueryInterface(mContent);
|
||||
optEl->GetSelected(&isChecked);
|
||||
}
|
||||
mIsChecked = isChecked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3590,6 +3601,14 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
result = localFalse; // not a link
|
||||
}
|
||||
}
|
||||
else if (nsCSSAtoms::checkedPseudo == pseudoClass->mAtom) {
|
||||
// This pseudoclass matches the selected state on the following elements:
|
||||
// <option>
|
||||
// <input type=checkbox>
|
||||
// <input type=radio>
|
||||
if (aTestState)
|
||||
result = data.mIsChecked ? localTrue : localFalse;
|
||||
}
|
||||
else {
|
||||
result = localFalse; // unknown pseudo class
|
||||
}
|
||||
|
@ -87,7 +87,6 @@ LAYOUT_ATOM(popupList, "Popup-list")
|
||||
LAYOUT_ATOM(canvasPseudo, ":canvas")
|
||||
LAYOUT_ATOM(commentTagName, "__moz_comment")
|
||||
LAYOUT_ATOM(dummyOptionPseudo, ":-moz-dummy-option")
|
||||
LAYOUT_ATOM(optionSelectedPseudo, "_moz-option-selected")
|
||||
LAYOUT_ATOM(textTagName, "__moz_text")
|
||||
LAYOUT_ATOM(pagePseudo, ":-moz-page")
|
||||
LAYOUT_ATOM(pageContentPseudo, ":-moz-pagecontent")
|
||||
|
@ -304,7 +304,8 @@ public:
|
||||
nsISupports* aSubContent) { return NS_OK; }
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) { return NS_OK; }
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass) { return NS_OK; }
|
||||
NS_IMETHOD AttributeChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -1933,11 +1933,13 @@ nsXULDocument::ContentChanged(nsIContent* aContent,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::ContentStatesChanged(nsIContent* aContent1, nsIContent* aContent2)
|
||||
nsXULDocument::ContentStatesChanged(nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
|
||||
observer->ContentStatesChanged(this, aContent1, aContent2);
|
||||
observer->ContentStatesChanged(this, aContent1, aContent2, aChangedPseudoClass);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -278,7 +278,9 @@ public:
|
||||
NS_IMETHOD ContentChanged(nsIContent* aContent,
|
||||
nsISupports* aSubContent);
|
||||
|
||||
NS_IMETHOD ContentStatesChanged(nsIContent* aContent1, nsIContent* aContent2);
|
||||
NS_IMETHOD ContentStatesChanged(nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -337,7 +337,8 @@ nsXULTemplateBuilder::ContentChanged(nsIDocument *aDocument,
|
||||
NS_IMETHODIMP
|
||||
nsXULTemplateBuilder::ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -115,7 +115,8 @@ public:
|
||||
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
|
@ -91,7 +91,8 @@ public:
|
||||
nsISupports* aSubContent) { return NS_OK; }
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) { return NS_OK; }
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass) { return NS_OK; }
|
||||
NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; }
|
||||
|
@ -10064,7 +10064,8 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
|
||||
NS_IMETHODIMP
|
||||
nsCSSFrameConstructor::ContentStatesChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
|
@ -122,7 +122,8 @@ public:
|
||||
|
||||
NS_IMETHOD ContentStatesChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
|
@ -87,7 +87,6 @@ LAYOUT_ATOM(popupList, "Popup-list")
|
||||
LAYOUT_ATOM(canvasPseudo, ":canvas")
|
||||
LAYOUT_ATOM(commentTagName, "__moz_comment")
|
||||
LAYOUT_ATOM(dummyOptionPseudo, ":-moz-dummy-option")
|
||||
LAYOUT_ATOM(optionSelectedPseudo, "_moz-option-selected")
|
||||
LAYOUT_ATOM(textTagName, "__moz_text")
|
||||
LAYOUT_ATOM(pagePseudo, ":-moz-page")
|
||||
LAYOUT_ATOM(pageContentPseudo, ":-moz-pagecontent")
|
||||
|
@ -1028,7 +1028,8 @@ public:
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
@ -5095,10 +5096,12 @@ PresShell::ContentChanged(nsIDocument *aDocument,
|
||||
NS_IMETHODIMP
|
||||
PresShell::ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
WillCauseReflow();
|
||||
nsresult rv = mStyleSet->ContentStatesChanged(mPresContext, aContent1, aContent2);
|
||||
nsresult rv = mStyleSet->ContentStatesChanged(mPresContext, aContent1, aContent2,
|
||||
aChangedPseudoClass);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
|
||||
|
@ -202,7 +202,8 @@ public:
|
||||
*/
|
||||
NS_IMETHOD ContentStatesChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) = 0;
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass) = 0;
|
||||
|
||||
/**
|
||||
* Notification that an attribute was changed for a content node
|
||||
|
@ -229,7 +229,8 @@ public:
|
||||
nsISupports* aSubContent) = 0;
|
||||
NS_IMETHOD ContentStatesChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) = 0;
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass) = 0;
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -93,11 +93,7 @@ const PRInt32 kNothingSelected = -1;
|
||||
const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32
|
||||
const PRInt32 kNoSizeSpecified = -1;
|
||||
|
||||
//XXX: This is temporary. It simulates psuedo states by using a attribute selector on
|
||||
// -moz-option-selected in the ua.css style sheet. This will not be needed when
|
||||
//The event state manager is functional. KMM
|
||||
//const char * kMozSelected = "-moz-option-selected";
|
||||
// it is now using "nsLayoutAtoms::optionSelectedPseudo"
|
||||
// We now use the :checked pseudoclass for the option selected state
|
||||
|
||||
//---------------------------------------------------------
|
||||
nsresult
|
||||
@ -1678,11 +1674,13 @@ nsListControlFrame::GetOption(nsIDOMHTMLCollection& aCollection, PRInt32 aIndex)
|
||||
PRBool
|
||||
nsListControlFrame::IsContentSelected(nsIContent* aContent)
|
||||
{
|
||||
nsAutoString value;
|
||||
//nsIAtom * selectedAtom = NS_NewAtom("selected");
|
||||
nsresult result = aContent->GetAttr(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, value);
|
||||
PRBool isSelected = PR_FALSE;
|
||||
|
||||
return (NS_CONTENT_ATTR_NOT_THERE == result ? PR_FALSE : PR_TRUE);
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optEl = do_QueryInterface(aContent);
|
||||
if (optEl)
|
||||
optEl->GetSelected(&isSelected);
|
||||
|
||||
return isSelected;
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,7 +104,8 @@ public:
|
||||
nsISupports* aSubContent) { return NS_OK; }
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) { return NS_OK; }
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass) { return NS_OK; }
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -1116,7 +1116,8 @@ nsImageMap::ContentChanged(nsIDocument *aDocument,
|
||||
NS_IMETHODIMP
|
||||
nsImageMap::ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -108,7 +108,8 @@ public:
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -104,7 +104,8 @@ public:
|
||||
nsISupports* aSubContent) { return NS_OK; }
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) { return NS_OK; }
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass) { return NS_OK; }
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -1116,7 +1116,8 @@ nsImageMap::ContentChanged(nsIDocument *aDocument,
|
||||
NS_IMETHODIMP
|
||||
nsImageMap::ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -108,7 +108,8 @@ public:
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -1028,7 +1028,8 @@ public:
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
@ -5095,10 +5096,12 @@ PresShell::ContentChanged(nsIDocument *aDocument,
|
||||
NS_IMETHODIMP
|
||||
PresShell::ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
WillCauseReflow();
|
||||
nsresult rv = mStyleSet->ContentStatesChanged(mPresContext, aContent1, aContent2);
|
||||
nsresult rv = mStyleSet->ContentStatesChanged(mPresContext, aContent1, aContent2,
|
||||
aChangedPseudoClass);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
|
||||
|
@ -181,7 +181,7 @@ select > option {
|
||||
padding: 0 5px 0 3px;
|
||||
}
|
||||
|
||||
option[_moz-option-selected] {
|
||||
option:checked {
|
||||
color: HighlightText ! important;
|
||||
background-color: Highlight ! important;
|
||||
}
|
||||
|
@ -93,11 +93,7 @@ const PRInt32 kNothingSelected = -1;
|
||||
const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32
|
||||
const PRInt32 kNoSizeSpecified = -1;
|
||||
|
||||
//XXX: This is temporary. It simulates psuedo states by using a attribute selector on
|
||||
// -moz-option-selected in the ua.css style sheet. This will not be needed when
|
||||
//The event state manager is functional. KMM
|
||||
//const char * kMozSelected = "-moz-option-selected";
|
||||
// it is now using "nsLayoutAtoms::optionSelectedPseudo"
|
||||
// We now use the :checked pseudoclass for the option selected state
|
||||
|
||||
//---------------------------------------------------------
|
||||
nsresult
|
||||
@ -1678,11 +1674,13 @@ nsListControlFrame::GetOption(nsIDOMHTMLCollection& aCollection, PRInt32 aIndex)
|
||||
PRBool
|
||||
nsListControlFrame::IsContentSelected(nsIContent* aContent)
|
||||
{
|
||||
nsAutoString value;
|
||||
//nsIAtom * selectedAtom = NS_NewAtom("selected");
|
||||
nsresult result = aContent->GetAttr(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, value);
|
||||
PRBool isSelected = PR_FALSE;
|
||||
|
||||
return (NS_CONTENT_ATTR_NOT_THERE == result ? PR_FALSE : PR_TRUE);
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optEl = do_QueryInterface(aContent);
|
||||
if (optEl)
|
||||
optEl->GetSelected(&isSelected);
|
||||
|
||||
return isSelected;
|
||||
}
|
||||
|
||||
|
||||
|
@ -10064,7 +10064,8 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
|
||||
NS_IMETHODIMP
|
||||
nsCSSFrameConstructor::ContentStatesChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
|
@ -122,7 +122,8 @@ public:
|
||||
|
||||
NS_IMETHOD ContentStatesChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
|
@ -181,7 +181,7 @@ select > option {
|
||||
padding: 0 5px 0 3px;
|
||||
}
|
||||
|
||||
option[_moz-option-selected] {
|
||||
option:checked {
|
||||
color: HighlightText ! important;
|
||||
background-color: Highlight ! important;
|
||||
}
|
||||
|
@ -70,6 +70,7 @@
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
#include "nsIDOMHTMLLinkElement.h"
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIDOMCSSStyleSheet.h"
|
||||
#include "nsIDOMCSSStyleRule.h"
|
||||
@ -3232,6 +3233,7 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext,
|
||||
mIsHTMLContent = PR_FALSE;
|
||||
mIsHTMLLink = PR_FALSE;
|
||||
mIsSimpleXLink = PR_FALSE;
|
||||
mIsChecked = PR_FALSE;
|
||||
mLinkState = eLinkState_Unknown;
|
||||
mEventState = NS_EVENT_STATE_UNSPECIFIED;
|
||||
mNameSpaceID = kNameSpaceID_Unknown;
|
||||
@ -3299,6 +3301,15 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext,
|
||||
nsStyleUtil::IsSimpleXlink(aContent, mPresContext, &mLinkState)) {
|
||||
mIsSimpleXLink = PR_TRUE;
|
||||
}
|
||||
|
||||
if (mIsHTMLContent) {
|
||||
PRBool isChecked = PR_FALSE;
|
||||
if (mContentTag == nsHTMLAtoms::option) {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optEl = do_QueryInterface(mContent);
|
||||
optEl->GetSelected(&isChecked);
|
||||
}
|
||||
mIsChecked = isChecked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3590,6 +3601,14 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
result = localFalse; // not a link
|
||||
}
|
||||
}
|
||||
else if (nsCSSAtoms::checkedPseudo == pseudoClass->mAtom) {
|
||||
// This pseudoclass matches the selected state on the following elements:
|
||||
// <option>
|
||||
// <input type=checkbox>
|
||||
// <input type=radio>
|
||||
if (aTestState)
|
||||
result = data.mIsChecked ? localTrue : localFalse;
|
||||
}
|
||||
else {
|
||||
result = localFalse; // unknown pseudo class
|
||||
}
|
||||
|
@ -90,9 +90,10 @@ struct RuleProcessorData {
|
||||
PRPackedBool mIsHTMLContent; // if content, then does QI on HTMLContent, true or false
|
||||
PRPackedBool mIsHTMLLink; // if content, calls nsStyleUtil::IsHTMLLink
|
||||
PRPackedBool mIsSimpleXLink; // if content, calls nsStyleUtil::IsSimpleXLink
|
||||
nsLinkState mLinkState; // if a link, this is the state, otherwise unknown
|
||||
PRPackedBool mIsQuirkMode; // Possibly remove use of this in SelectorMatches?
|
||||
PRPackedBool mHasAttributes; // if content, content->GetAttrCount() > 0
|
||||
PRPackedBool mIsChecked; // checked/selected attribute for option and select elements
|
||||
nsLinkState mLinkState; // if a link, this is the state, otherwise unknown
|
||||
PRInt32 mEventState; // if content, eventStateMgr->GetContentState()
|
||||
PRInt32 mNameSpaceID; // if content, content->GetNameSapce()
|
||||
RuleProcessorData* mPreviousSiblingData;
|
||||
|
@ -206,7 +206,8 @@ public:
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
@ -1476,9 +1477,11 @@ StyleSetImpl::ContentChanged(nsIPresContext* aPresContext,
|
||||
NS_IMETHODIMP
|
||||
StyleSetImpl::ContentStatesChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
return mFrameConstructor->ContentStatesChanged(aPresContext, aContent1, aContent2);
|
||||
return mFrameConstructor->ContentStatesChanged(aPresContext, aContent1, aContent2,
|
||||
aChangedPseudoClass);
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsXULAtoms.h"
|
||||
#include "nsCSSAtoms.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIBoxObject.h"
|
||||
@ -221,8 +222,13 @@ nsOutlinerContentView::SetSelection(nsIOutlinerSelection* aSelection)
|
||||
mSelection->SetSelectEventsSuppressed(PR_TRUE);
|
||||
for (PRInt32 i = 0; i < mRows.Count(); ++i) {
|
||||
Row* row = (Row*)mRows[i];
|
||||
if (row->mContent->HasAttr(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo))
|
||||
mSelection->ToggleSelect(i);
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optEl = do_QueryInterface(row->mContent);
|
||||
if (optEl) {
|
||||
PRBool isSelected;
|
||||
optEl->GetSelected(&isSelected);
|
||||
if (isSelected)
|
||||
mSelection->ToggleSelect(i);
|
||||
}
|
||||
}
|
||||
mSelection->SetSelectEventsSuppressed(PR_FALSE);
|
||||
}
|
||||
@ -648,8 +654,22 @@ nsOutlinerContentView::ContentChanged(nsIDocument *aDocument,
|
||||
NS_IMETHODIMP
|
||||
nsOutlinerContentView::ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
if (!aContent1 || !mSelection || !aContent1->IsContentOfType(nsIContent::eHTML) ||
|
||||
aChangedPseudoClass != nsCSSAtoms::checkedPseudo)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAtom> contentTag;
|
||||
aContent1->GetTag(*getter_AddRefs(contentTag));
|
||||
if (contentTag == nsHTMLAtoms::option) {
|
||||
// update the selected state for this node
|
||||
PRInt32 index = FindContent(aContent1);
|
||||
if (index >= 0)
|
||||
mSelection->ToggleSelect(index);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -663,6 +683,10 @@ nsOutlinerContentView::AttributeChanged(nsIDocument *aDocument,
|
||||
{
|
||||
// First, get the element on which the attribute has changed
|
||||
// and then try to find content item in our array of rows.
|
||||
|
||||
if (!aContent->IsContentOfType(nsIContent::eXUL))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aContent->GetTag(*getter_AddRefs(tag));
|
||||
|
||||
@ -734,16 +758,6 @@ nsOutlinerContentView::AttributeChanged(nsIDocument *aDocument,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tag == nsHTMLAtoms::option) {
|
||||
if (aAttribute == nsLayoutAtoms::optionSelectedPseudo) {
|
||||
PRInt32 index = FindContent(aContent);
|
||||
if (index >= 0) {
|
||||
NS_ASSERTION(mSelection, "Need to handle optionSelected change with no OutlinerSelection");
|
||||
if (mSelection)
|
||||
mSelection->ToggleSelect(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -771,12 +785,17 @@ nsOutlinerContentView::ContentInserted(nsIDocument *aDocument,
|
||||
nsCOMPtr<nsIAtom> childTag;
|
||||
aChild->GetTag(*getter_AddRefs(childTag));
|
||||
|
||||
if ((childTag != nsXULAtoms::outlineritem) &&
|
||||
(childTag != nsXULAtoms::outlinerseparator) &&
|
||||
(childTag != nsHTMLAtoms::option) &&
|
||||
(childTag != nsXULAtoms::outlinerchildren) &&
|
||||
(childTag != nsXULAtoms::outlinerrow) &&
|
||||
(childTag != nsXULAtoms::outlinercell))
|
||||
if (aChild->IsContentOfType(nsIContent::eHTML)) {
|
||||
if (childTag != nsHTMLAtoms::option)
|
||||
return NS_OK;
|
||||
} else if (aChild->IsContentOfType(nsIContent::eXUL)) {
|
||||
if (childTag != nsXULAtoms::outlineritem &&
|
||||
childTag != nsXULAtoms::outlinerseparator &&
|
||||
childTag != nsXULAtoms::outlinerchildren &&
|
||||
childTag != nsXULAtoms::outlinerrow &&
|
||||
childTag != nsXULAtoms::outlinercell)
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_OK;
|
||||
|
||||
// If we have a legal tag, go up to the outliner/select and make sure
|
||||
@ -786,7 +805,8 @@ nsOutlinerContentView::ContentInserted(nsIDocument *aDocument,
|
||||
|
||||
while (element) {
|
||||
element->GetTag(*getter_AddRefs(parentTag));
|
||||
if (parentTag == nsXULAtoms::outliner || parentTag == nsHTMLAtoms::select)
|
||||
if ((element->IsContentOfType(nsIContent::eXUL) && parentTag == nsXULAtoms::outliner) ||
|
||||
(element->IsContentOfType(nsIContent::eHTML) && parentTag == nsHTMLAtoms::select))
|
||||
if (element == mRoot) // this is for us, stop looking
|
||||
break;
|
||||
else // this is not for us, we can bail out
|
||||
@ -874,12 +894,17 @@ nsOutlinerContentView::ContentRemoved(nsIDocument *aDocument,
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aChild->GetTag(*getter_AddRefs(tag));
|
||||
|
||||
if ((tag != nsXULAtoms::outlineritem) &&
|
||||
(tag != nsXULAtoms::outlinerseparator) &&
|
||||
(tag != nsHTMLAtoms::option) &&
|
||||
(tag != nsXULAtoms::outlinerchildren) &&
|
||||
(tag != nsXULAtoms::outlinerrow) &&
|
||||
(tag != nsXULAtoms::outlinercell))
|
||||
if (aChild->IsContentOfType(nsIContent::eHTML)) {
|
||||
if (tag != nsHTMLAtoms::option)
|
||||
return NS_OK;
|
||||
} else if (aChild->IsContentOfType(nsIContent::eXUL)) {
|
||||
if (tag != nsXULAtoms::outlineritem &&
|
||||
tag != nsXULAtoms::outlinerseparator &&
|
||||
tag != nsXULAtoms::outlinerchildren &&
|
||||
tag != nsXULAtoms::outlinerrow &&
|
||||
tag != nsXULAtoms::outlinercell)
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_OK;
|
||||
|
||||
// If we have a legal tag, go up to the outliner/select and make sure
|
||||
@ -889,7 +914,8 @@ nsOutlinerContentView::ContentRemoved(nsIDocument *aDocument,
|
||||
|
||||
while (element) {
|
||||
element->GetTag(*getter_AddRefs(parentTag));
|
||||
if (parentTag == nsXULAtoms::outliner || parentTag == nsHTMLAtoms::select)
|
||||
if ((element->IsContentOfType(nsIContent::eXUL) && parentTag == nsXULAtoms::outliner) ||
|
||||
(element->IsContentOfType(nsIContent::eHTML) && parentTag == nsHTMLAtoms::select))
|
||||
if (element == mRoot) // this is for us, stop looking
|
||||
break;
|
||||
else // this is not for us, we can bail out
|
||||
@ -1010,12 +1036,15 @@ nsOutlinerContentView::Serialize(nsIContent* aContent, PRInt32 aParentIndex, PRI
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
content->GetTag(*getter_AddRefs(tag));
|
||||
PRInt32 count = aRows.Count();
|
||||
if (tag == nsXULAtoms::outlineritem)
|
||||
SerializeItem(content, aParentIndex, aIndex, aRows);
|
||||
else if (tag == nsXULAtoms::outlinerseparator)
|
||||
SerializeSeparator(content, aParentIndex, aIndex, aRows);
|
||||
else if (tag == nsHTMLAtoms::option)
|
||||
SerializeOption(content, aParentIndex, aIndex, aRows);
|
||||
if (content->IsContentOfType(nsIContent::eXUL)) {
|
||||
if (tag == nsXULAtoms::outlineritem)
|
||||
SerializeItem(content, aParentIndex, aIndex, aRows);
|
||||
else if (tag == nsXULAtoms::outlinerseparator)
|
||||
SerializeSeparator(content, aParentIndex, aIndex, aRows);
|
||||
} else if (content->IsContentOfType(nsIContent::eHTML)) {
|
||||
if (tag == nsHTMLAtoms::option)
|
||||
SerializeOption(content, aParentIndex, aIndex, aRows);
|
||||
}
|
||||
*aIndex += aRows.Count() - count;
|
||||
}
|
||||
}
|
||||
@ -1074,7 +1103,10 @@ nsOutlinerContentView::SerializeOption(nsIContent* aContent, PRInt32 aParentInde
|
||||
// This will happen before the OutlinerSelection is hooked up. So, cache the selected
|
||||
// state in the row properties and update the selection when it is attached.
|
||||
|
||||
if (aContent->HasAttr(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo))
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optEl = do_QueryInterface(aContent);
|
||||
PRBool isSelected;
|
||||
optEl->GetSelected(&isSelected);
|
||||
if (isSelected)
|
||||
mUpdateSelection = PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,8 @@ class nsOutlinerContentView : public nsIOutlinerView,
|
||||
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudo);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsXULAtoms.h"
|
||||
#include "nsCSSAtoms.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIBoxObject.h"
|
||||
@ -221,8 +222,13 @@ nsOutlinerContentView::SetSelection(nsIOutlinerSelection* aSelection)
|
||||
mSelection->SetSelectEventsSuppressed(PR_TRUE);
|
||||
for (PRInt32 i = 0; i < mRows.Count(); ++i) {
|
||||
Row* row = (Row*)mRows[i];
|
||||
if (row->mContent->HasAttr(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo))
|
||||
mSelection->ToggleSelect(i);
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optEl = do_QueryInterface(row->mContent);
|
||||
if (optEl) {
|
||||
PRBool isSelected;
|
||||
optEl->GetSelected(&isSelected);
|
||||
if (isSelected)
|
||||
mSelection->ToggleSelect(i);
|
||||
}
|
||||
}
|
||||
mSelection->SetSelectEventsSuppressed(PR_FALSE);
|
||||
}
|
||||
@ -648,8 +654,22 @@ nsOutlinerContentView::ContentChanged(nsIDocument *aDocument,
|
||||
NS_IMETHODIMP
|
||||
nsOutlinerContentView::ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
if (!aContent1 || !mSelection || !aContent1->IsContentOfType(nsIContent::eHTML) ||
|
||||
aChangedPseudoClass != nsCSSAtoms::checkedPseudo)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAtom> contentTag;
|
||||
aContent1->GetTag(*getter_AddRefs(contentTag));
|
||||
if (contentTag == nsHTMLAtoms::option) {
|
||||
// update the selected state for this node
|
||||
PRInt32 index = FindContent(aContent1);
|
||||
if (index >= 0)
|
||||
mSelection->ToggleSelect(index);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -663,6 +683,10 @@ nsOutlinerContentView::AttributeChanged(nsIDocument *aDocument,
|
||||
{
|
||||
// First, get the element on which the attribute has changed
|
||||
// and then try to find content item in our array of rows.
|
||||
|
||||
if (!aContent->IsContentOfType(nsIContent::eXUL))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aContent->GetTag(*getter_AddRefs(tag));
|
||||
|
||||
@ -734,16 +758,6 @@ nsOutlinerContentView::AttributeChanged(nsIDocument *aDocument,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tag == nsHTMLAtoms::option) {
|
||||
if (aAttribute == nsLayoutAtoms::optionSelectedPseudo) {
|
||||
PRInt32 index = FindContent(aContent);
|
||||
if (index >= 0) {
|
||||
NS_ASSERTION(mSelection, "Need to handle optionSelected change with no OutlinerSelection");
|
||||
if (mSelection)
|
||||
mSelection->ToggleSelect(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -771,12 +785,17 @@ nsOutlinerContentView::ContentInserted(nsIDocument *aDocument,
|
||||
nsCOMPtr<nsIAtom> childTag;
|
||||
aChild->GetTag(*getter_AddRefs(childTag));
|
||||
|
||||
if ((childTag != nsXULAtoms::outlineritem) &&
|
||||
(childTag != nsXULAtoms::outlinerseparator) &&
|
||||
(childTag != nsHTMLAtoms::option) &&
|
||||
(childTag != nsXULAtoms::outlinerchildren) &&
|
||||
(childTag != nsXULAtoms::outlinerrow) &&
|
||||
(childTag != nsXULAtoms::outlinercell))
|
||||
if (aChild->IsContentOfType(nsIContent::eHTML)) {
|
||||
if (childTag != nsHTMLAtoms::option)
|
||||
return NS_OK;
|
||||
} else if (aChild->IsContentOfType(nsIContent::eXUL)) {
|
||||
if (childTag != nsXULAtoms::outlineritem &&
|
||||
childTag != nsXULAtoms::outlinerseparator &&
|
||||
childTag != nsXULAtoms::outlinerchildren &&
|
||||
childTag != nsXULAtoms::outlinerrow &&
|
||||
childTag != nsXULAtoms::outlinercell)
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_OK;
|
||||
|
||||
// If we have a legal tag, go up to the outliner/select and make sure
|
||||
@ -786,7 +805,8 @@ nsOutlinerContentView::ContentInserted(nsIDocument *aDocument,
|
||||
|
||||
while (element) {
|
||||
element->GetTag(*getter_AddRefs(parentTag));
|
||||
if (parentTag == nsXULAtoms::outliner || parentTag == nsHTMLAtoms::select)
|
||||
if ((element->IsContentOfType(nsIContent::eXUL) && parentTag == nsXULAtoms::outliner) ||
|
||||
(element->IsContentOfType(nsIContent::eHTML) && parentTag == nsHTMLAtoms::select))
|
||||
if (element == mRoot) // this is for us, stop looking
|
||||
break;
|
||||
else // this is not for us, we can bail out
|
||||
@ -874,12 +894,17 @@ nsOutlinerContentView::ContentRemoved(nsIDocument *aDocument,
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aChild->GetTag(*getter_AddRefs(tag));
|
||||
|
||||
if ((tag != nsXULAtoms::outlineritem) &&
|
||||
(tag != nsXULAtoms::outlinerseparator) &&
|
||||
(tag != nsHTMLAtoms::option) &&
|
||||
(tag != nsXULAtoms::outlinerchildren) &&
|
||||
(tag != nsXULAtoms::outlinerrow) &&
|
||||
(tag != nsXULAtoms::outlinercell))
|
||||
if (aChild->IsContentOfType(nsIContent::eHTML)) {
|
||||
if (tag != nsHTMLAtoms::option)
|
||||
return NS_OK;
|
||||
} else if (aChild->IsContentOfType(nsIContent::eXUL)) {
|
||||
if (tag != nsXULAtoms::outlineritem &&
|
||||
tag != nsXULAtoms::outlinerseparator &&
|
||||
tag != nsXULAtoms::outlinerchildren &&
|
||||
tag != nsXULAtoms::outlinerrow &&
|
||||
tag != nsXULAtoms::outlinercell)
|
||||
return NS_OK;
|
||||
} else
|
||||
return NS_OK;
|
||||
|
||||
// If we have a legal tag, go up to the outliner/select and make sure
|
||||
@ -889,7 +914,8 @@ nsOutlinerContentView::ContentRemoved(nsIDocument *aDocument,
|
||||
|
||||
while (element) {
|
||||
element->GetTag(*getter_AddRefs(parentTag));
|
||||
if (parentTag == nsXULAtoms::outliner || parentTag == nsHTMLAtoms::select)
|
||||
if ((element->IsContentOfType(nsIContent::eXUL) && parentTag == nsXULAtoms::outliner) ||
|
||||
(element->IsContentOfType(nsIContent::eHTML) && parentTag == nsHTMLAtoms::select))
|
||||
if (element == mRoot) // this is for us, stop looking
|
||||
break;
|
||||
else // this is not for us, we can bail out
|
||||
@ -1010,12 +1036,15 @@ nsOutlinerContentView::Serialize(nsIContent* aContent, PRInt32 aParentIndex, PRI
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
content->GetTag(*getter_AddRefs(tag));
|
||||
PRInt32 count = aRows.Count();
|
||||
if (tag == nsXULAtoms::outlineritem)
|
||||
SerializeItem(content, aParentIndex, aIndex, aRows);
|
||||
else if (tag == nsXULAtoms::outlinerseparator)
|
||||
SerializeSeparator(content, aParentIndex, aIndex, aRows);
|
||||
else if (tag == nsHTMLAtoms::option)
|
||||
SerializeOption(content, aParentIndex, aIndex, aRows);
|
||||
if (content->IsContentOfType(nsIContent::eXUL)) {
|
||||
if (tag == nsXULAtoms::outlineritem)
|
||||
SerializeItem(content, aParentIndex, aIndex, aRows);
|
||||
else if (tag == nsXULAtoms::outlinerseparator)
|
||||
SerializeSeparator(content, aParentIndex, aIndex, aRows);
|
||||
} else if (content->IsContentOfType(nsIContent::eHTML)) {
|
||||
if (tag == nsHTMLAtoms::option)
|
||||
SerializeOption(content, aParentIndex, aIndex, aRows);
|
||||
}
|
||||
*aIndex += aRows.Count() - count;
|
||||
}
|
||||
}
|
||||
@ -1074,7 +1103,10 @@ nsOutlinerContentView::SerializeOption(nsIContent* aContent, PRInt32 aParentInde
|
||||
// This will happen before the OutlinerSelection is hooked up. So, cache the selected
|
||||
// state in the row properties and update the selection when it is attached.
|
||||
|
||||
if (aContent->HasAttr(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo))
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optEl = do_QueryInterface(aContent);
|
||||
PRBool isSelected;
|
||||
optEl->GetSelected(&isSelected);
|
||||
if (isSelected)
|
||||
mUpdateSelection = PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,8 @@ class nsOutlinerContentView : public nsIOutlinerView,
|
||||
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudo);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
|
@ -47,17 +47,17 @@ select {
|
||||
border:2px inset rgb(192, 192, 192);
|
||||
}
|
||||
|
||||
select[size] option[_moz-option-selected] {
|
||||
select[size] option:checked {
|
||||
background-color:rgb(0, 0, 128);
|
||||
color: white;
|
||||
}
|
||||
|
||||
select option[_moz-option-selected] {
|
||||
select option:checked {
|
||||
background-color:rgb(0, 0, 128);
|
||||
color: white;
|
||||
}
|
||||
|
||||
select[size="1"] option[_moz-option-selected] {
|
||||
select[size="1"] option:checked {
|
||||
background-color:rgb(0, 0, 128);
|
||||
color: white;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ option {
|
||||
padding-left:10px;
|
||||
}
|
||||
|
||||
option[_moz-option-selected] {
|
||||
option:checked {
|
||||
color:black;
|
||||
background-color:rgb(255, 221, 255);
|
||||
padding-left:10px;
|
||||
|
@ -59,7 +59,7 @@ option {
|
||||
background-color:green;
|
||||
}
|
||||
|
||||
option[_moz-option-selected] {
|
||||
option:checked {
|
||||
color:red;
|
||||
background-color:yellow;
|
||||
}
|
||||
|
@ -215,18 +215,18 @@ option {
|
||||
}
|
||||
|
||||
/* Combobox item style */
|
||||
select option[_moz-option-selected] {
|
||||
select option:checked {
|
||||
color:black;
|
||||
background-color:white;
|
||||
}
|
||||
|
||||
/* List box item selected style */
|
||||
select[size] option[_moz-option-selected] {
|
||||
select[size] option:checked {
|
||||
color:white;
|
||||
background-color:rgb(51,51,102);
|
||||
}
|
||||
|
||||
select[size="1"] option[_moz-option-selected] {
|
||||
select[size="1"] option:checked {
|
||||
color:black;
|
||||
background-color:white;
|
||||
}
|
||||
@ -253,4 +253,4 @@ textarea {
|
||||
border: 2px inset #c0c0c0;
|
||||
background-color:white;
|
||||
color:black;
|
||||
}
|
||||
}
|
||||
|
@ -770,7 +770,8 @@ nsMenuBarX::ContentChanged( nsIDocument * aDocument, nsIContent * aContent, nsIS
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMenuBarX::ContentStatesChanged( nsIDocument * aDocument, nsIContent * aContent1, nsIContent * aContent2)
|
||||
nsMenuBarX::ContentStatesChanged( nsIDocument * aDocument, nsIContent * aContent1,
|
||||
nsIContent * aContent2, nsIAtom * aChangedPseudoClass)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -112,7 +112,8 @@ public:
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -664,7 +664,8 @@ nsMenuBar::ContentChanged( nsIDocument * aDocument, nsIContent * aContent, nsISu
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMenuBar::ContentStatesChanged( nsIDocument * aDocument, nsIContent * aContent1, nsIContent * aContent2)
|
||||
nsMenuBar::ContentStatesChanged( nsIDocument * aDocument, nsIContent * aContent1,
|
||||
nsIContent * aContent2, nsIAtom * aChangedPseudoClass)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -115,7 +115,8 @@ public:
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -760,7 +760,8 @@ nsMenuBarX::ContentChanged( nsIDocument * aDocument, nsIContent * aContent, nsIS
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMenuBarX::ContentStatesChanged( nsIDocument * aDocument, nsIContent * aContent1, nsIContent * aContent2)
|
||||
nsMenuBarX::ContentStatesChanged( nsIDocument * aDocument, nsIContent * aContent1,
|
||||
nsIContent * aContent2, nsIAtom * aChangedPseudoClass)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -114,7 +114,8 @@ public:
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -1550,7 +1550,8 @@ nsWebShellWindow::ContentChanged(nsIDocument *aDocument,
|
||||
NS_IMETHODIMP
|
||||
nsWebShellWindow::ContentStatesChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -124,7 +124,8 @@ public:
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2,
|
||||
nsIAtom* aChangedPseudoClass);
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
Loading…
x
Reference in New Issue
Block a user