зеркало из https://github.com/mozilla/pjs.git
Add support for '::' notation for CSS pseudo-elements (bug 62843). Drop
selectors containing unrecognized pseudo-classes and pseudo-elements (bug 145968). Fix some CSS rules in quirk.css and xul.css that were bogus (no bug). Patch in bug 62843. r+sr=dbaron
This commit is contained in:
Родитель
1b5ff9dcc7
Коммит
23e8590dc2
|
@ -66,6 +66,8 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsCSSPseudoClasses.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "nsCSSAnonBoxes.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsINameSpace.h"
|
||||
#include "nsThemeConstants.h"
|
||||
|
@ -1526,11 +1528,6 @@ static PRBool IsSinglePseudoClass(const nsCSSSelector& aSelector)
|
|||
}
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
static PRBool IsTreePseudoElement(const nsString& aPseudo)
|
||||
{
|
||||
return Substring(aPseudo, 0, 10).Equals(NS_LITERAL_STRING("-moz-tree-"));
|
||||
}
|
||||
|
||||
static PRBool IsTreePseudoElement(nsIAtom* aPseudo)
|
||||
{
|
||||
const char* str;
|
||||
|
@ -2112,40 +2109,75 @@ void CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
|
|||
PRInt32& aErrorCode,
|
||||
PRBool aIsNegated)
|
||||
{
|
||||
nsAutoString buffer;
|
||||
if (! GetToken(aErrorCode, PR_FALSE)) { // premature eof
|
||||
REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("name of pseudo-selector"));
|
||||
REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("name of pseudo-class or pseudo-element"));
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
buffer.Truncate();
|
||||
buffer.Append(PRUnichar(':'));
|
||||
buffer.Append(mToken.mIdent);
|
||||
ToLowerCase(buffer);
|
||||
nsCOMPtr<nsIAtom> pseudo = do_GetAtom(buffer);
|
||||
|
||||
if (eCSSToken_Ident != mToken.mType) { // malformed selector
|
||||
if (eCSSToken_Function != mToken.mType ||
|
||||
!(
|
||||
#ifdef MOZ_XUL
|
||||
// -moz-tree is a pseudo-element and therefore cannot be negated
|
||||
(!aIsNegated && IsTreePseudoElement(mToken.mIdent)) ||
|
||||
#endif
|
||||
// the negation pseudo-class is a function
|
||||
(nsCSSPseudoClasses::notPseudo == pseudo) ||
|
||||
// as is the lang pseudo-class
|
||||
(nsCSSPseudoClasses::lang == pseudo))) {
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier for pseudo-class selector not found"));
|
||||
UngetToken();
|
||||
// First, find out whether we are parsing a CSS3 pseudo-element
|
||||
PRBool parsingPseudoElement = PR_FALSE;
|
||||
if (mToken.IsSymbol(':')) {
|
||||
parsingPseudoElement = PR_TRUE;
|
||||
if (! GetToken(aErrorCode, PR_FALSE)) { // premature eof
|
||||
REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("name of pseudo-class or pseudo-element"));
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Do some sanity-checking on the token
|
||||
if (eCSSToken_Ident != mToken.mType && eCSSToken_Function != mToken.mType) {
|
||||
// malformed selector
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier for pseudo-class or pseudo-element but found"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
// OK, now we know we have an mIdent. Atomize it. All the atoms, for
|
||||
// pseudo-classes as well as pseudo-elements, start with a single ':'.
|
||||
nsAutoString buffer;
|
||||
buffer.Append(PRUnichar(':'));
|
||||
buffer.Append(mToken.mIdent);
|
||||
ToLowerCase(buffer);
|
||||
nsCOMPtr<nsIAtom> pseudo = do_GetAtom(buffer);
|
||||
|
||||
// stash away some info about this pseudo so we only have to get it once.
|
||||
#ifdef MOZ_XUL
|
||||
PRBool isTree = (eCSSToken_Function == mToken.mType) &&
|
||||
IsTreePseudoElement(pseudo);
|
||||
#endif
|
||||
PRBool isPseudoElement = nsCSSPseudoElements::IsPseudoElement(pseudo);
|
||||
PRBool isAnonBox = nsCSSAnonBoxes::IsAnonBox(pseudo);
|
||||
|
||||
// If it's a function token, it better be on our "ok" list
|
||||
if (eCSSToken_Function == mToken.mType &&
|
||||
#ifdef MOZ_XUL
|
||||
!isTree &&
|
||||
#endif
|
||||
nsCSSPseudoClasses::notPseudo != pseudo &&
|
||||
nsCSSPseudoClasses::lang != pseudo) { // There are no other function pseudos
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier for function pseudo-class or pseudo-element but found"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
// If it starts with "::", it better be a pseudo-element
|
||||
if (parsingPseudoElement &&
|
||||
!isPseudoElement &&
|
||||
!isAnonBox) {
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected pseudo-element but found"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (nsCSSPseudoClasses::notPseudo == pseudo) {
|
||||
if (aIsNegated) { // :not() can't be itself negated
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Negation pseudo-class can't be negated"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -2155,7 +2187,8 @@ void CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (nsCSSPseudoClasses::IsPseudoClass(pseudo)) {
|
||||
else if (!parsingPseudoElement &&
|
||||
nsCSSPseudoClasses::IsPseudoClass(pseudo)) {
|
||||
aDataMask |= SEL_MASK_PCLASS;
|
||||
if (nsCSSPseudoClasses::lang == pseudo) {
|
||||
ParseLangSelector(aSelector, aParsingStatus, aErrorCode);
|
||||
|
@ -2168,26 +2201,43 @@ void CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
|
|||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (isPseudoElement || isAnonBox) {
|
||||
// Pseudo-element. Make some more sanity checks.
|
||||
|
||||
if (aIsNegated) { // pseudo-elements can't be negated
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Pseudo-elements can't be negated"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
// CSS2 pseudo-elements are allowed to have a single ':' on them, as are
|
||||
// various -moz-* pseudo-elements (anonymous boxes). Others (CSS3+
|
||||
// pseudo-elements) must have |parsingPseudoElement| set.
|
||||
if (!parsingPseudoElement &&
|
||||
// XXXbz remove the isAnonBox check once we have converted all
|
||||
// of our stylesheets to using '::' (see bug 211657).
|
||||
!isAnonBox &&
|
||||
!nsCSSPseudoElements::IsCSS2PseudoElement(pseudo)) {
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("This pseudo-element must use the \"::\" form: "));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == (aDataMask & SEL_MASK_PELEM)) {
|
||||
aDataMask |= SEL_MASK_PELEM;
|
||||
aSelector.AddPseudoClass(pseudo); // store it here, it gets pulled later
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
if (eCSSToken_Function == mToken.mType &&
|
||||
IsTreePseudoElement(mToken.mIdent)) {
|
||||
if (isTree) {
|
||||
// We have encountered a pseudoelement of the form
|
||||
// -moz-tree-xxxx(a,b,c). We parse (a,b,c) and add each
|
||||
// item in the list to the pseudoclass list. They will be pulled
|
||||
// from the list later along with the pseudoelement.
|
||||
if (!ParseTreePseudoElement(aErrorCode, aSelector))
|
||||
// from the list later along with the pseudo-element.
|
||||
if (!ParseTreePseudoElement(aErrorCode, aSelector)) {
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2211,6 +2261,12 @@ void CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
|
|||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Not a pseudo-class, not a pseudo-element.... forget it
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Unknown pseudo-class or pseudo-element"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
aParsingStatus = SELECTOR_PARSING_ENDED_OK;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
#include "nsILookAndFeel.h"
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
|
||||
#include "nsIStyleSet.h"
|
||||
|
||||
|
@ -590,6 +591,9 @@ void nsCSSSelector::ToStringInternal(nsAString& aString,
|
|||
} else {
|
||||
// Append the tag name, if there is one
|
||||
if (mTag) {
|
||||
if (IsPseudoElement(mTag) && !nsCSSPseudoElements::IsCSS2PseudoElement(mTag)) {
|
||||
aString.Append(PRUnichar(':'));
|
||||
}
|
||||
nsAutoString prefix;
|
||||
mTag->ToString(prefix);
|
||||
aString.Append(prefix);
|
||||
|
|
|
@ -39,30 +39,48 @@
|
|||
/*
|
||||
* This file contains the list of nsIAtoms and their values for CSS
|
||||
* pseudo-elements. It is designed to be used as inline input to
|
||||
* nsCSSPseudoElements.cpp *only* through the magic of C preprocessing.
|
||||
* All entries must be enclosed in the macro CSS_PSEUDO_ELEMENT which
|
||||
* will have cruel and unusual things done to it. The entries should be
|
||||
* kept in some sort of logical order. The first argument to
|
||||
* CSS_PSEUDO_ELEMENT is the C++ identifier of the atom. The second
|
||||
* argument is the string value of the atom.
|
||||
* nsCSSPseudoElements.cpp *only* through the magic of C preprocessing. All
|
||||
* entries must be enclosed either in the macro CSS_PSEUDO_ELEMENT or in the
|
||||
* macro CSS2_PSEUDO_ELEMENT; these macros will have cruel and unusual things
|
||||
* done to them. The difference between the two macros is that the
|
||||
* pseudo-elements enclosed in CSS2_PSEUDO_ELEMENT are the pseudo-elements
|
||||
* which are allowed to have only a single ':' in stylesheets. The entries
|
||||
* should be kept in some sort of logical order. The first argument to all the
|
||||
* macros is the C++ identifier of the atom. The second argument is the string
|
||||
* value of the atom.
|
||||
*
|
||||
* Code including this file MUST define CSS_PSEUDO_ELEMENT. If desired, it can
|
||||
* also define CSS2_PSEUDO_ELEMENT to perform special handling of the CSS2
|
||||
* pseudo-elements.
|
||||
*/
|
||||
|
||||
// OUTPUT_CLASS=nsCSSPseudoElements
|
||||
// MACRO_NAME=CSS_PSEUDO_ELEMENT
|
||||
|
||||
CSS_PSEUDO_ELEMENT(after, ":after")
|
||||
CSS_PSEUDO_ELEMENT(before, ":before")
|
||||
#ifndef CSS2_PSEUDO_ELEMENT
|
||||
#define DEFINED_CSS2_PSEUDO_ELEMENT
|
||||
#define CSS2_PSEUDO_ELEMENT(name_, value_) CSS_PSEUDO_ELEMENT(name_, value_)
|
||||
#endif // CSS2_PSEUDO_ELEMENT
|
||||
|
||||
CSS_PSEUDO_ELEMENT(firstLetter, ":first-letter")
|
||||
CSS_PSEUDO_ELEMENT(firstLine, ":first-line")
|
||||
CSS2_PSEUDO_ELEMENT(after, ":after")
|
||||
CSS2_PSEUDO_ELEMENT(before, ":before")
|
||||
|
||||
CSS_PSEUDO_ELEMENT(mozSelection, ":-moz-selection")
|
||||
CSS2_PSEUDO_ELEMENT(firstLetter, ":first-letter")
|
||||
CSS2_PSEUDO_ELEMENT(firstLine, ":first-line")
|
||||
|
||||
CSS_PSEUDO_ELEMENT(mozFocusInner, ":-moz-focus-inner")
|
||||
CSS_PSEUDO_ELEMENT(mozFocusOuter, ":-moz-focus-outer")
|
||||
// XXXbz These should be converted to the CSS_PSEUDO_ELEMENT macro. See bug
|
||||
// 211657
|
||||
CSS2_PSEUDO_ELEMENT(mozSelection, ":-moz-selection")
|
||||
|
||||
CSS_PSEUDO_ELEMENT(mozListBullet, ":-moz-list-bullet")
|
||||
CSS_PSEUDO_ELEMENT(mozListNumber, ":-moz-list-number")
|
||||
CSS2_PSEUDO_ELEMENT(mozFocusInner, ":-moz-focus-inner")
|
||||
CSS2_PSEUDO_ELEMENT(mozFocusOuter, ":-moz-focus-outer")
|
||||
|
||||
CSS_PSEUDO_ELEMENT(horizontalFramesetBorder, ":-moz-hframeset-border")
|
||||
CSS_PSEUDO_ELEMENT(verticalFramesetBorder, ":-moz-vframeset-border")
|
||||
CSS2_PSEUDO_ELEMENT(mozListBullet, ":-moz-list-bullet")
|
||||
CSS2_PSEUDO_ELEMENT(mozListNumber, ":-moz-list-number")
|
||||
|
||||
CSS2_PSEUDO_ELEMENT(horizontalFramesetBorder, ":-moz-hframeset-border")
|
||||
CSS2_PSEUDO_ELEMENT(verticalFramesetBorder, ":-moz-vframeset-border")
|
||||
|
||||
#ifdef DEFINED_CSS2_PSEUDO_ELEMENT
|
||||
#undef CSS2_PSEUDO_ELEMENT
|
||||
#endif
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 atom lists for CSS pseudos.
|
||||
*
|
||||
* 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):
|
||||
* L. David Baron <dbaron@dbaron.org>
|
||||
*
|
||||
* 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsCSSPseudoElements_h___
|
||||
#define nsCSSPseudoElements_h___
|
||||
|
||||
#include "nsIAtom.h"
|
||||
|
||||
// Empty class derived from nsIAtom so that function signatures can
|
||||
// require an atom from this atom list.
|
||||
class nsICSSPseudoElement : public nsIAtom {};
|
||||
|
||||
class nsCSSPseudoElements {
|
||||
public:
|
||||
|
||||
static void AddRefAtoms();
|
||||
|
||||
static PRBool IsPseudoElement(nsIAtom *aAtom);
|
||||
|
||||
#define CSS_PSEUDO_ELEMENT(_name, _value) static nsICSSPseudoElement* _name;
|
||||
#include "nsCSSPseudoElementList.h"
|
||||
#undef CSS_PSEUDO_ELEMENT
|
||||
};
|
||||
|
||||
#endif /* nsCSSPseudoElements_h___ */
|
|
@ -1,67 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 atom lists for CSS pseudos.
|
||||
*
|
||||
* 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):
|
||||
* L. David Baron <dbaron@dbaron.org>
|
||||
*
|
||||
* 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "nsAtomListUtils.h"
|
||||
#include "nsStaticAtom.h"
|
||||
#include "nsMemory.h"
|
||||
|
||||
// define storage for all atoms
|
||||
#define CSS_PSEUDO_ELEMENT(_name, _value) \
|
||||
nsICSSPseudoElement* nsCSSPseudoElements::_name;
|
||||
#include "nsCSSPseudoElementList.h"
|
||||
#undef CSS_PSEUDO_ELEMENT
|
||||
|
||||
static const nsStaticAtom CSSPseudoElements_info[] = {
|
||||
#define CSS_PSEUDO_ELEMENT(name_, value_) \
|
||||
{ value_, (nsIAtom**)&nsCSSPseudoElements::name_ },
|
||||
#include "nsCSSPseudoElementList.h"
|
||||
#undef CSS_PSEUDO_ELEMENT
|
||||
};
|
||||
|
||||
void nsCSSPseudoElements::AddRefAtoms()
|
||||
{
|
||||
NS_RegisterStaticAtoms(CSSPseudoElements_info,
|
||||
NS_ARRAY_LENGTH(CSSPseudoElements_info));
|
||||
}
|
||||
|
||||
PRBool nsCSSPseudoElements::IsPseudoElement(nsIAtom *aAtom)
|
||||
{
|
||||
return nsAtomListUtils::IsMember(aAtom, CSSPseudoElements_info,
|
||||
NS_ARRAY_LENGTH(CSSPseudoElements_info));
|
||||
}
|
||||
|
|
@ -44,11 +44,11 @@ input[type=image] {
|
|||
}
|
||||
|
||||
/* border when focused -- only change style to dotted */
|
||||
input[type=image]:focused {
|
||||
input[type=image]:focus {
|
||||
border-style: dotted;
|
||||
}
|
||||
|
||||
/* border when focused -- only change color to gray */
|
||||
/* border when disabled -- only change color to gray */
|
||||
input[type=image][disabled] {
|
||||
border-color: GrayText;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,8 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsCSSPseudoClasses.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "nsCSSAnonBoxes.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsINameSpace.h"
|
||||
#include "nsThemeConstants.h"
|
||||
|
@ -1526,11 +1528,6 @@ static PRBool IsSinglePseudoClass(const nsCSSSelector& aSelector)
|
|||
}
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
static PRBool IsTreePseudoElement(const nsString& aPseudo)
|
||||
{
|
||||
return Substring(aPseudo, 0, 10).Equals(NS_LITERAL_STRING("-moz-tree-"));
|
||||
}
|
||||
|
||||
static PRBool IsTreePseudoElement(nsIAtom* aPseudo)
|
||||
{
|
||||
const char* str;
|
||||
|
@ -2112,40 +2109,75 @@ void CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
|
|||
PRInt32& aErrorCode,
|
||||
PRBool aIsNegated)
|
||||
{
|
||||
nsAutoString buffer;
|
||||
if (! GetToken(aErrorCode, PR_FALSE)) { // premature eof
|
||||
REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("name of pseudo-selector"));
|
||||
REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("name of pseudo-class or pseudo-element"));
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
buffer.Truncate();
|
||||
buffer.Append(PRUnichar(':'));
|
||||
buffer.Append(mToken.mIdent);
|
||||
ToLowerCase(buffer);
|
||||
nsCOMPtr<nsIAtom> pseudo = do_GetAtom(buffer);
|
||||
|
||||
if (eCSSToken_Ident != mToken.mType) { // malformed selector
|
||||
if (eCSSToken_Function != mToken.mType ||
|
||||
!(
|
||||
#ifdef MOZ_XUL
|
||||
// -moz-tree is a pseudo-element and therefore cannot be negated
|
||||
(!aIsNegated && IsTreePseudoElement(mToken.mIdent)) ||
|
||||
#endif
|
||||
// the negation pseudo-class is a function
|
||||
(nsCSSPseudoClasses::notPseudo == pseudo) ||
|
||||
// as is the lang pseudo-class
|
||||
(nsCSSPseudoClasses::lang == pseudo))) {
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier for pseudo-class selector not found"));
|
||||
UngetToken();
|
||||
// First, find out whether we are parsing a CSS3 pseudo-element
|
||||
PRBool parsingPseudoElement = PR_FALSE;
|
||||
if (mToken.IsSymbol(':')) {
|
||||
parsingPseudoElement = PR_TRUE;
|
||||
if (! GetToken(aErrorCode, PR_FALSE)) { // premature eof
|
||||
REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("name of pseudo-class or pseudo-element"));
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Do some sanity-checking on the token
|
||||
if (eCSSToken_Ident != mToken.mType && eCSSToken_Function != mToken.mType) {
|
||||
// malformed selector
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier for pseudo-class or pseudo-element but found"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
// OK, now we know we have an mIdent. Atomize it. All the atoms, for
|
||||
// pseudo-classes as well as pseudo-elements, start with a single ':'.
|
||||
nsAutoString buffer;
|
||||
buffer.Append(PRUnichar(':'));
|
||||
buffer.Append(mToken.mIdent);
|
||||
ToLowerCase(buffer);
|
||||
nsCOMPtr<nsIAtom> pseudo = do_GetAtom(buffer);
|
||||
|
||||
// stash away some info about this pseudo so we only have to get it once.
|
||||
#ifdef MOZ_XUL
|
||||
PRBool isTree = (eCSSToken_Function == mToken.mType) &&
|
||||
IsTreePseudoElement(pseudo);
|
||||
#endif
|
||||
PRBool isPseudoElement = nsCSSPseudoElements::IsPseudoElement(pseudo);
|
||||
PRBool isAnonBox = nsCSSAnonBoxes::IsAnonBox(pseudo);
|
||||
|
||||
// If it's a function token, it better be on our "ok" list
|
||||
if (eCSSToken_Function == mToken.mType &&
|
||||
#ifdef MOZ_XUL
|
||||
!isTree &&
|
||||
#endif
|
||||
nsCSSPseudoClasses::notPseudo != pseudo &&
|
||||
nsCSSPseudoClasses::lang != pseudo) { // There are no other function pseudos
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier for function pseudo-class or pseudo-element but found"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
// If it starts with "::", it better be a pseudo-element
|
||||
if (parsingPseudoElement &&
|
||||
!isPseudoElement &&
|
||||
!isAnonBox) {
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected pseudo-element but found"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (nsCSSPseudoClasses::notPseudo == pseudo) {
|
||||
if (aIsNegated) { // :not() can't be itself negated
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Negation pseudo-class can't be negated"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -2155,7 +2187,8 @@ void CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (nsCSSPseudoClasses::IsPseudoClass(pseudo)) {
|
||||
else if (!parsingPseudoElement &&
|
||||
nsCSSPseudoClasses::IsPseudoClass(pseudo)) {
|
||||
aDataMask |= SEL_MASK_PCLASS;
|
||||
if (nsCSSPseudoClasses::lang == pseudo) {
|
||||
ParseLangSelector(aSelector, aParsingStatus, aErrorCode);
|
||||
|
@ -2168,26 +2201,43 @@ void CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
|
|||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (isPseudoElement || isAnonBox) {
|
||||
// Pseudo-element. Make some more sanity checks.
|
||||
|
||||
if (aIsNegated) { // pseudo-elements can't be negated
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Pseudo-elements can't be negated"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
// CSS2 pseudo-elements are allowed to have a single ':' on them, as are
|
||||
// various -moz-* pseudo-elements (anonymous boxes). Others (CSS3+
|
||||
// pseudo-elements) must have |parsingPseudoElement| set.
|
||||
if (!parsingPseudoElement &&
|
||||
// XXXbz remove the isAnonBox check once we have converted all
|
||||
// of our stylesheets to using '::' (see bug 211657).
|
||||
!isAnonBox &&
|
||||
!nsCSSPseudoElements::IsCSS2PseudoElement(pseudo)) {
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("This pseudo-element must use the \"::\" form: "));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == (aDataMask & SEL_MASK_PELEM)) {
|
||||
aDataMask |= SEL_MASK_PELEM;
|
||||
aSelector.AddPseudoClass(pseudo); // store it here, it gets pulled later
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
if (eCSSToken_Function == mToken.mType &&
|
||||
IsTreePseudoElement(mToken.mIdent)) {
|
||||
if (isTree) {
|
||||
// We have encountered a pseudoelement of the form
|
||||
// -moz-tree-xxxx(a,b,c). We parse (a,b,c) and add each
|
||||
// item in the list to the pseudoclass list. They will be pulled
|
||||
// from the list later along with the pseudoelement.
|
||||
if (!ParseTreePseudoElement(aErrorCode, aSelector))
|
||||
// from the list later along with the pseudo-element.
|
||||
if (!ParseTreePseudoElement(aErrorCode, aSelector)) {
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2211,6 +2261,12 @@ void CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
|
|||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Not a pseudo-class, not a pseudo-element.... forget it
|
||||
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Unknown pseudo-class or pseudo-element"));
|
||||
UngetToken();
|
||||
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
|
||||
return;
|
||||
}
|
||||
aParsingStatus = SELECTOR_PARSING_ENDED_OK;
|
||||
}
|
||||
|
|
|
@ -39,30 +39,48 @@
|
|||
/*
|
||||
* This file contains the list of nsIAtoms and their values for CSS
|
||||
* pseudo-elements. It is designed to be used as inline input to
|
||||
* nsCSSPseudoElements.cpp *only* through the magic of C preprocessing.
|
||||
* All entries must be enclosed in the macro CSS_PSEUDO_ELEMENT which
|
||||
* will have cruel and unusual things done to it. The entries should be
|
||||
* kept in some sort of logical order. The first argument to
|
||||
* CSS_PSEUDO_ELEMENT is the C++ identifier of the atom. The second
|
||||
* argument is the string value of the atom.
|
||||
* nsCSSPseudoElements.cpp *only* through the magic of C preprocessing. All
|
||||
* entries must be enclosed either in the macro CSS_PSEUDO_ELEMENT or in the
|
||||
* macro CSS2_PSEUDO_ELEMENT; these macros will have cruel and unusual things
|
||||
* done to them. The difference between the two macros is that the
|
||||
* pseudo-elements enclosed in CSS2_PSEUDO_ELEMENT are the pseudo-elements
|
||||
* which are allowed to have only a single ':' in stylesheets. The entries
|
||||
* should be kept in some sort of logical order. The first argument to all the
|
||||
* macros is the C++ identifier of the atom. The second argument is the string
|
||||
* value of the atom.
|
||||
*
|
||||
* Code including this file MUST define CSS_PSEUDO_ELEMENT. If desired, it can
|
||||
* also define CSS2_PSEUDO_ELEMENT to perform special handling of the CSS2
|
||||
* pseudo-elements.
|
||||
*/
|
||||
|
||||
// OUTPUT_CLASS=nsCSSPseudoElements
|
||||
// MACRO_NAME=CSS_PSEUDO_ELEMENT
|
||||
|
||||
CSS_PSEUDO_ELEMENT(after, ":after")
|
||||
CSS_PSEUDO_ELEMENT(before, ":before")
|
||||
#ifndef CSS2_PSEUDO_ELEMENT
|
||||
#define DEFINED_CSS2_PSEUDO_ELEMENT
|
||||
#define CSS2_PSEUDO_ELEMENT(name_, value_) CSS_PSEUDO_ELEMENT(name_, value_)
|
||||
#endif // CSS2_PSEUDO_ELEMENT
|
||||
|
||||
CSS_PSEUDO_ELEMENT(firstLetter, ":first-letter")
|
||||
CSS_PSEUDO_ELEMENT(firstLine, ":first-line")
|
||||
CSS2_PSEUDO_ELEMENT(after, ":after")
|
||||
CSS2_PSEUDO_ELEMENT(before, ":before")
|
||||
|
||||
CSS_PSEUDO_ELEMENT(mozSelection, ":-moz-selection")
|
||||
CSS2_PSEUDO_ELEMENT(firstLetter, ":first-letter")
|
||||
CSS2_PSEUDO_ELEMENT(firstLine, ":first-line")
|
||||
|
||||
CSS_PSEUDO_ELEMENT(mozFocusInner, ":-moz-focus-inner")
|
||||
CSS_PSEUDO_ELEMENT(mozFocusOuter, ":-moz-focus-outer")
|
||||
// XXXbz These should be converted to the CSS_PSEUDO_ELEMENT macro. See bug
|
||||
// 211657
|
||||
CSS2_PSEUDO_ELEMENT(mozSelection, ":-moz-selection")
|
||||
|
||||
CSS_PSEUDO_ELEMENT(mozListBullet, ":-moz-list-bullet")
|
||||
CSS_PSEUDO_ELEMENT(mozListNumber, ":-moz-list-number")
|
||||
CSS2_PSEUDO_ELEMENT(mozFocusInner, ":-moz-focus-inner")
|
||||
CSS2_PSEUDO_ELEMENT(mozFocusOuter, ":-moz-focus-outer")
|
||||
|
||||
CSS_PSEUDO_ELEMENT(horizontalFramesetBorder, ":-moz-hframeset-border")
|
||||
CSS_PSEUDO_ELEMENT(verticalFramesetBorder, ":-moz-vframeset-border")
|
||||
CSS2_PSEUDO_ELEMENT(mozListBullet, ":-moz-list-bullet")
|
||||
CSS2_PSEUDO_ELEMENT(mozListNumber, ":-moz-list-number")
|
||||
|
||||
CSS2_PSEUDO_ELEMENT(horizontalFramesetBorder, ":-moz-hframeset-border")
|
||||
CSS2_PSEUDO_ELEMENT(verticalFramesetBorder, ":-moz-vframeset-border")
|
||||
|
||||
#ifdef DEFINED_CSS2_PSEUDO_ELEMENT
|
||||
#undef CSS2_PSEUDO_ELEMENT
|
||||
#endif
|
||||
|
|
|
@ -65,3 +65,14 @@ PRBool nsCSSPseudoElements::IsPseudoElement(nsIAtom *aAtom)
|
|||
NS_ARRAY_LENGTH(CSSPseudoElements_info));
|
||||
}
|
||||
|
||||
PRBool nsCSSPseudoElements::IsCSS2PseudoElement(nsIAtom *aAtom)
|
||||
{
|
||||
#define CSS2_PSEUDO_ELEMENT(name_, value_) \
|
||||
nsCSSPseudoElements::name_ == aAtom ||
|
||||
#define CSS_PSEUDO_ELEMENT(name_, value_)
|
||||
return
|
||||
#include "nsCSSPseudoElementList.h"
|
||||
PR_FALSE;
|
||||
#undef CSS_PSEUDO_ELEMENT
|
||||
#undef CSS2_PSEUDO_ELEMENT
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ public:
|
|||
|
||||
static PRBool IsPseudoElement(nsIAtom *aAtom);
|
||||
|
||||
static PRBool IsCSS2PseudoElement(nsIAtom *aAtom);
|
||||
|
||||
#define CSS_PSEUDO_ELEMENT(_name, _value) static nsICSSPseudoElement* _name;
|
||||
#include "nsCSSPseudoElementList.h"
|
||||
#undef CSS_PSEUDO_ELEMENT
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
#include "nsILookAndFeel.h"
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
|
||||
#include "nsIStyleSet.h"
|
||||
|
||||
|
@ -590,6 +591,9 @@ void nsCSSSelector::ToStringInternal(nsAString& aString,
|
|||
} else {
|
||||
// Append the tag name, if there is one
|
||||
if (mTag) {
|
||||
if (IsPseudoElement(mTag) && !nsCSSPseudoElements::IsCSS2PseudoElement(mTag)) {
|
||||
aString.Append(PRUnichar(':'));
|
||||
}
|
||||
nsAutoString prefix;
|
||||
mTag->ToString(prefix);
|
||||
aString.Append(prefix);
|
||||
|
|
|
@ -44,11 +44,11 @@ input[type=image] {
|
|||
}
|
||||
|
||||
/* border when focused -- only change style to dotted */
|
||||
input[type=image]:focused {
|
||||
input[type=image]:focus {
|
||||
border-style: dotted;
|
||||
}
|
||||
|
||||
/* border when focused -- only change color to gray */
|
||||
/* border when disabled -- only change color to gray */
|
||||
input[type=image][disabled] {
|
||||
border-color: GrayText;
|
||||
}
|
||||
|
|
|
@ -537,10 +537,6 @@ stack, bulletinboard {
|
|||
display: -moz-stack;
|
||||
}
|
||||
|
||||
:-moz-deck-hidden {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
/********** tabbox *********/
|
||||
|
||||
tabbox {
|
||||
|
|
Загрузка…
Ссылка в новой задаче