зеркало из https://github.com/mozilla/pjs.git
fixes bug 323793 "Expose .ping attribute for <a> and <area> elements" r=jst sr=bzbarsky
This commit is contained in:
Родитель
620356e8b9
Коммит
c66402ebc4
|
@ -575,6 +575,7 @@ GK_ATOM(perMille, "per-mille")
|
|||
GK_ATOM(percent, "percent")
|
||||
GK_ATOM(persist, "persist")
|
||||
GK_ATOM(phase, "phase")
|
||||
GK_ATOM(ping, "ping")
|
||||
GK_ATOM(plaintext, "plaintext")
|
||||
GK_ATOM(pointSize, "point-size")
|
||||
GK_ATOM(popup, "popup")
|
||||
|
|
|
@ -2970,6 +2970,52 @@ nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetURIListAttr(nsIAtom* aAttr, nsAString& aResult)
|
||||
{
|
||||
aResult.Truncate();
|
||||
|
||||
nsAutoString value;
|
||||
if (!GetAttr(kNameSpaceID_None, aAttr, value))
|
||||
return NS_OK;
|
||||
|
||||
nsIDocument* doc = GetOwnerDoc();
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
|
||||
// Value contains relative URIs split on spaces (U+0020)
|
||||
const PRUnichar *start = value.BeginReading();
|
||||
const PRUnichar *end = value.EndReading();
|
||||
const PRUnichar *iter = start;
|
||||
for (;;) {
|
||||
if (iter < end && *iter != ' ') {
|
||||
++iter;
|
||||
} else { // iter is pointing at either end or a space
|
||||
while (*start == ' ' && start < iter)
|
||||
++start;
|
||||
if (iter != start) {
|
||||
if (!aResult.IsEmpty())
|
||||
aResult.Append(PRUnichar(' '));
|
||||
const nsSubstring& uriPart = Substring(start, iter);
|
||||
nsCOMPtr<nsIURI> attrURI;
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(attrURI),
|
||||
uriPart, doc, baseURI);
|
||||
if (attrURI) {
|
||||
nsCAutoString spec;
|
||||
attrURI->GetSpec(spec);
|
||||
AppendUTF8toUTF16(spec, aResult);
|
||||
} else {
|
||||
aResult.Append(uriPart);
|
||||
}
|
||||
}
|
||||
start = iter = iter + 1;
|
||||
if (iter >= end)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsGenericHTMLFrameElement, TabIndex, tabindex, 0)
|
||||
|
|
|
@ -780,6 +780,20 @@ protected:
|
|||
*/
|
||||
NS_HIDDEN_(nsresult) GetURIAttr(nsIAtom* aAttr, nsAString& aResult);
|
||||
|
||||
/**
|
||||
* This method works like GetURIAttr, except that it supports multiple
|
||||
* URIs separated by whitespace (one or more U+0020 SPACE characters).
|
||||
*
|
||||
* Gets the absolute URI values of an attribute, by resolving any relative
|
||||
* URIs in the attribute against the baseuri of the element. If a substring
|
||||
* isn't a relative URI, the substring is returned as is. Only works for
|
||||
* attributes in null namespace.
|
||||
*
|
||||
* @param aAttr name of attribute.
|
||||
* @param aResult result value [out]
|
||||
*/
|
||||
NS_HIDDEN_(nsresult) GetURIListAttr(nsIAtom* aAttr, nsAString& aResult);
|
||||
|
||||
/**
|
||||
* Helper method to recreate all frames for this content, if there
|
||||
* are any.
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
#include "nsIDOMNSHTMLAnchorElement.h"
|
||||
#include "nsIDOMNSHTMLAnchorElement2.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
|
@ -68,7 +68,7 @@ nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult);
|
|||
|
||||
class nsHTMLAnchorElement : public nsGenericHTMLElement,
|
||||
public nsIDOMHTMLAnchorElement,
|
||||
public nsIDOMNSHTMLAnchorElement,
|
||||
public nsIDOMNSHTMLAnchorElement2,
|
||||
public nsILink
|
||||
{
|
||||
public:
|
||||
|
@ -93,6 +93,9 @@ public:
|
|||
// nsIDOMNSHTMLAnchorElement
|
||||
NS_DECL_NSIDOMNSHTMLANCHORELEMENT
|
||||
|
||||
// nsIDOMNSHTMLAnchorElement2
|
||||
NS_DECL_NSIDOMNSHTMLANCHORELEMENT2
|
||||
|
||||
// nsILink
|
||||
NS_IMETHOD GetLinkState(nsLinkState &aState);
|
||||
NS_IMETHOD SetLinkState(nsLinkState aState);
|
||||
|
@ -152,6 +155,7 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLAnchorElement, nsGenericElement)
|
|||
NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLAnchorElement, nsGenericHTMLElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLAnchorElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLAnchorElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLAnchorElement2)
|
||||
NS_INTERFACE_MAP_ENTRY(nsILink)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLAnchorElement)
|
||||
NS_HTML_CONTENT_INTERFACE_MAP_END
|
||||
|
@ -548,6 +552,18 @@ nsHTMLAnchorElement::ToString(nsAString& aSource)
|
|||
return GetHref(aSource);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::GetPing(nsAString& aValue)
|
||||
{
|
||||
return GetURIListAttr(nsHTMLAtoms::ping, aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::SetPing(const nsAString& aValue)
|
||||
{
|
||||
return SetAttr(kNameSpaceID_None, nsHTMLAtoms::ping, aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::GetLinkState(nsLinkState &aState)
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsIDOMNSHTMLAreaElement.h"
|
||||
#include "nsIDOMNSHTMLAreaElement2.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsILink.h"
|
||||
|
@ -52,7 +52,7 @@
|
|||
|
||||
class nsHTMLAreaElement : public nsGenericHTMLElement,
|
||||
public nsIDOMHTMLAreaElement,
|
||||
public nsIDOMNSHTMLAreaElement,
|
||||
public nsIDOMNSHTMLAreaElement2,
|
||||
public nsILink
|
||||
{
|
||||
public:
|
||||
|
@ -77,6 +77,9 @@ public:
|
|||
// nsIDOMNSHTMLAreaElement
|
||||
NS_DECL_NSIDOMNSHTMLAREAELEMENT
|
||||
|
||||
// nsIDOMNSHTMLAreaElement2
|
||||
NS_DECL_NSIDOMNSHTMLAREAELEMENT2
|
||||
|
||||
// nsILink
|
||||
NS_IMETHOD GetLinkState(nsLinkState &aState);
|
||||
NS_IMETHOD SetLinkState(nsLinkState aState);
|
||||
|
@ -133,6 +136,7 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLAreaElement, nsGenericElement)
|
|||
NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLAreaElement, nsGenericHTMLElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLAreaElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLAreaElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLAreaElement2)
|
||||
NS_INTERFACE_MAP_ENTRY(nsILink)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLAreaElement)
|
||||
NS_HTML_CONTENT_INTERFACE_MAP_END
|
||||
|
@ -480,6 +484,18 @@ nsHTMLAreaElement::ToString(nsAString& aSource)
|
|||
return GetHref(aSource);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::GetPing(nsAString& aValue)
|
||||
{
|
||||
return GetURIListAttr(nsHTMLAtoms::ping, aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::SetPing(const nsAString& aValue)
|
||||
{
|
||||
return SetAttr(kNameSpaceID_None, nsHTMLAtoms::ping, aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::GetLinkState(nsLinkState &aState)
|
||||
{
|
||||
|
|
|
@ -109,7 +109,9 @@ SDK_XPIDLSRCS = \
|
|||
XPIDLSRCS = \
|
||||
nsIDOMHTMLCanvasElement.idl \
|
||||
nsIDOMNSHTMLAnchorElement.idl \
|
||||
nsIDOMNSHTMLAnchorElement2.idl \
|
||||
nsIDOMNSHTMLAreaElement.idl \
|
||||
nsIDOMNSHTMLAreaElement2.idl \
|
||||
nsIDOMNSHTMLButtonElement.idl \
|
||||
nsIDOMNSHTMLDocument.idl \
|
||||
nsIDOMNSHTMLElement.idl \
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@meer.net>
|
||||
*
|
||||
* 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 "nsIDOMNSHTMLAnchorElement.idl"
|
||||
|
||||
[scriptable, uuid(d7627eda-6ec0-4326-87c4-c3067fe6e324)]
|
||||
interface nsIDOMNSHTMLAnchorElement2 : nsIDOMNSHTMLAnchorElement
|
||||
{
|
||||
attribute DOMString ping;
|
||||
};
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@meer.net>
|
||||
*
|
||||
* 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 "nsIDOMNSHTMLAreaElement.idl"
|
||||
|
||||
[scriptable, uuid(1859b16a-7c16-4ab7-bdb9-52792ba16cc1)]
|
||||
interface nsIDOMNSHTMLAreaElement2 : nsIDOMNSHTMLAreaElement
|
||||
{
|
||||
attribute DOMString ping;
|
||||
};
|
Загрузка…
Ссылка в новой задаче