Files
palemoon27/editor/libeditor/nsHTMLURIRefObject.cpp
T
roytam1 2a3dd7f84c import change from rmottola/Arctic-Fox:
- Bug 1139453 - Send network UP/DOWN events on desktop Linux. (7466c1298)
- Bug 1141488 - On non-APZ platforms, combine any async transform with the OMTA transform rather than clobbering it the OMTA transform. (fe48d6774)
- Bug 1080752 - Hold wakelock when attempting to connect to push server. (b1e74295f)
- Bug 1126089 - Allow messages to be sent after frame script unload event. (167ebbd9a)
- Bug 1126089 - Add test for pageload event on browser element when tab closed (f2011e6e4)
- Bug 1090921 - Logging to see which tasks remain alive too long (ebfc3c9bd)
- Bug 1142544 - delete now-unnecessary |extern "C++"| block from nsISupportsUtils.h; r=mccr8 (07e6572f8)
- Bug 1142503 - don't use QueryInterface when the compiler can do the cast for us; r=ehsan (b13219054)
- Bug 1140161 - Sensibly handle patterns with absolute paths in TEST_HARNESS_FILES. (173e369a7)
- Bug 1082510 - When we detect a chrome popup at the current event coordinates and remote content has the mouse captured, release capture. r=Enn (da9fe26a7)
- Bug 1137722 - Ensure that system message cache is refreshed before openapp. r=fabrice (97dc41f50)
- Bug 1139904 - Add initial test runtime files for mochitest browser-chrome and devtools (9837c79b1)
- Bug 1061604 part.1 nsTextStore::GetTextExt() should rReturn previous character rect instead of TS_E_NOLAYOUT when Google Japanese Input retrieves first character of selected clause at composing r=emk (54779d30e)
- Bug 1061604 part.2 nsTextStore::GetTextExt() should rReturn previous character rect of modified range instead of TS_E_NOLAYOUT when Google Japanese Input retrieves caret rect during composition r=emk (ba7f93879)
- Bug 1136051 - component_insert_pair statrs checks only while we are still checking or haven't started pairing; (ae1ae1d4f)
- Bug 1137007 - Detect namespace and SECCOMP_FILTER_FLAG_TSYNC support in SandboxInfo. r=kang, r=Unfocused (6d9e32a8f)
- Bug 1142263 - Specify all syscall parameters when doing CLONE_NEWUSER detection; f=bwc r=kang (8bcba1831)
-  Bug 1142567 - Remove FAIL_ON_WARNINGS_DEBUG; It is not used. (bf22f1ccf)
- No bug - Add an explanatory message to the multiple-inheritance assertion in DOM bindings; # (ffd94ef07)
- Bug 1141252. Don't mark the TablePainter display item as having background-attachment:fixed content if the background-attachment:fixed image will be painted by a dedicated nsDisplayTableCellBackground. r=mats (98287b37c)
- Bug 1140084 - delete list of script counts in tail-recursive fashion. (90a2b7c45)
- Bug 1048741 - [WebGL2] texParameter: Fix silly bug in TEXTURE_COMPARE_FUNC handling. (ccc90dae3)
- Bug 1142478. Fix integer attribute parsing to not lose track of leading zeroes. (d596a1ce1)
- Bug 1139388 - Remove superfluous locking in the OS X profiler implementation to fix deadlock. (r=mstange) (a13088958)
- Bug 1128603: Remove findReferences and the tests that use it. (bccc64734)
- Bug 1140683: Fix async plugin init using null plugin funcs on MacOSX (47b591d54)
- Bug 1142494 - Fix OSX packaging mistake. (15555f4ee)
- Bug 1136784 - Add screenshot to LogShake produced data. (7ff264243)
- Bug 1142550 - Fix screenshot. (d684b6469)
- Bug 1142006 - Set MACOSX_DEPLOYMENT_TARGET earlier. r=mshal (c333b954e)
- Bug 1100966 - Remember all ranges for all selections when joining nodes in the editor transactions; r=roc (bf34bd0c8)
- Bug 1136507 - L8, LA8, and A8 should not be renderable. (96e807795)
- Bug 1128019 - Init SCISSOR_BOX with initial width and height. (7258cc44c)
- Bug 1142211 - Add layerization testing mechanisms to reftest. r=roc (4c6aa11f8)
- Bug 1106905 - Modify mobile desktop mode implementation to use a desktop viewport. (644ede0e7)
- Bug 1139675 - Simplify the APIs for getting and setting the pres shell resolution. r=mstange,mattwoodrow (c520a8c98)
- Bug 1141563 - Don't update Shapes in parallel after compacting GC (098af79c9)
2019-07-13 08:35:45 +08:00

261 lines
6.9 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Here is the list, from beppe and glazman:
href >> A, AREA, BASE, LINK
src >> FRAME, IFRAME, IMG, INPUT, SCRIPT
<META http-equiv="refresh" content="3,http://www.acme.com/intro.html">
longdesc >> FRAME, IFRAME, IMG
usemap >> IMG, INPUT, OBJECT
action >> FORM
background >> BODY
codebase >> OBJECT, APPLET
classid >> OBJECT
data >> OBJECT
cite >> BLOCKQUOTE, DEL, INS, Q
profile >> HEAD
ARCHIVE attribute on APPLET ; warning, it contains a list of URIs.
Easier way of organizing the list:
a: href
area: href
base: href
body: background
blockquote: cite (not normally rewritable)
link: href
frame: src, longdesc
iframe: src, longdesc
input: src, usemap
form: action
img: src, longdesc, usemap
script: src
applet: codebase, archive <list>
object: codebase, data, classid, usemap
head: profile
del: cite
ins: cite
q: cite
*/
#include "nsHTMLURIRefObject.h"
#include "mozilla/mozalloc.h"
#include "nsAString.h"
#include "nsDebug.h"
#include "nsError.h"
#include "nsID.h"
#include "nsIDOMAttr.h"
#include "nsIDOMElement.h"
#include "nsIDOMMozNamedAttrMap.h"
#include "nsIDOMNode.h"
#include "nsISupportsUtils.h"
#include "nsString.h"
#include "nsAutoPtr.h"
// String classes change too often and I can't keep up.
// Set this macro to this week's approved case-insensitive compare routine.
#define MATCHES(tagName, str) tagName.EqualsIgnoreCase(str)
nsHTMLURIRefObject::nsHTMLURIRefObject()
{
mCurAttrIndex = mAttributeCnt = 0;
}
nsHTMLURIRefObject::~nsHTMLURIRefObject()
{
}
//Interfaces for addref and release and queryinterface
NS_IMPL_ISUPPORTS(nsHTMLURIRefObject, nsIURIRefObject)
NS_IMETHODIMP
nsHTMLURIRefObject::Reset()
{
mCurAttrIndex = 0;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLURIRefObject::GetNextURI(nsAString & aURI)
{
NS_ENSURE_TRUE(mNode, NS_ERROR_NOT_INITIALIZED);
nsAutoString tagName;
nsresult rv = mNode->GetNodeName(tagName);
NS_ENSURE_SUCCESS(rv, rv);
// Loop over attribute list:
if (!mAttributes)
{
nsCOMPtr<nsIDOMElement> element (do_QueryInterface(mNode));
NS_ENSURE_TRUE(element, NS_ERROR_INVALID_ARG);
mCurAttrIndex = 0;
element->GetAttributes(getter_AddRefs(mAttributes));
NS_ENSURE_TRUE(mAttributes, NS_ERROR_NOT_INITIALIZED);
rv = mAttributes->GetLength(&mAttributeCnt);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(mAttributeCnt, NS_ERROR_FAILURE);
mCurAttrIndex = 0;
}
while (mCurAttrIndex < mAttributeCnt)
{
nsCOMPtr<nsIDOMAttr> attrNode;
rv = mAttributes->Item(mCurAttrIndex++, getter_AddRefs(attrNode));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_ARG_POINTER(attrNode);
nsString curAttr;
rv = attrNode->GetName(curAttr);
NS_ENSURE_SUCCESS(rv, rv);
// href >> A, AREA, BASE, LINK
if (MATCHES(curAttr, "href"))
{
if (!MATCHES(tagName, "a") && !MATCHES(tagName, "area")
&& !MATCHES(tagName, "base") && !MATCHES(tagName, "link"))
continue;
rv = attrNode->GetValue(aURI);
NS_ENSURE_SUCCESS(rv, rv);
nsString uri (aURI);
// href pointing to a named anchor doesn't count
if (aURI.First() != char16_t('#'))
return NS_OK;
aURI.Truncate();
return NS_ERROR_INVALID_ARG;
}
// src >> FRAME, IFRAME, IMG, INPUT, SCRIPT
else if (MATCHES(curAttr, "src"))
{
if (!MATCHES(tagName, "img")
&& !MATCHES(tagName, "frame") && !MATCHES(tagName, "iframe")
&& !MATCHES(tagName, "input") && !MATCHES(tagName, "script"))
continue;
return attrNode->GetValue(aURI);
}
//<META http-equiv="refresh" content="3,http://www.acme.com/intro.html">
else if (MATCHES(curAttr, "content"))
{
if (!MATCHES(tagName, "meta"))
continue;
}
// longdesc >> FRAME, IFRAME, IMG
else if (MATCHES(curAttr, "longdesc"))
{
if (!MATCHES(tagName, "img")
&& !MATCHES(tagName, "frame") && !MATCHES(tagName, "iframe"))
continue;
}
// usemap >> IMG, INPUT, OBJECT
else if (MATCHES(curAttr, "usemap"))
{
if (!MATCHES(tagName, "img")
&& !MATCHES(tagName, "input") && !MATCHES(tagName, "object"))
continue;
}
// action >> FORM
else if (MATCHES(curAttr, "action"))
{
if (!MATCHES(tagName, "form"))
continue;
}
// background >> BODY
else if (MATCHES(curAttr, "background"))
{
if (!MATCHES(tagName, "body"))
continue;
}
// codebase >> OBJECT, APPLET
else if (MATCHES(curAttr, "codebase"))
{
if (!MATCHES(tagName, "meta"))
continue;
}
// classid >> OBJECT
else if (MATCHES(curAttr, "classid"))
{
if (!MATCHES(tagName, "object"))
continue;
}
// data >> OBJECT
else if (MATCHES(curAttr, "data"))
{
if (!MATCHES(tagName, "object"))
continue;
}
// cite >> BLOCKQUOTE, DEL, INS, Q
else if (MATCHES(curAttr, "cite"))
{
if (!MATCHES(tagName, "blockquote") && !MATCHES(tagName, "q")
&& !MATCHES(tagName, "del") && !MATCHES(tagName, "ins"))
continue;
}
// profile >> HEAD
else if (MATCHES(curAttr, "profile"))
{
if (!MATCHES(tagName, "head"))
continue;
}
// archive attribute on APPLET; warning, it contains a list of URIs.
else if (MATCHES(curAttr, "archive"))
{
if (!MATCHES(tagName, "applet"))
continue;
}
}
// Return a code to indicate that there are no more,
// to distinguish that case from real errors.
return NS_ERROR_NOT_AVAILABLE;
}
NS_IMETHODIMP
nsHTMLURIRefObject::RewriteAllURIs(const nsAString & aOldPat,
const nsAString & aNewPat,
bool aMakeRel)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsHTMLURIRefObject::GetNode(nsIDOMNode** aNode)
{
NS_ENSURE_TRUE(mNode, NS_ERROR_NOT_INITIALIZED);
NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
*aNode = mNode.get();
NS_ADDREF(*aNode);
return NS_OK;
}
NS_IMETHODIMP
nsHTMLURIRefObject::SetNode(nsIDOMNode *aNode)
{
mNode = aNode;
nsAutoString dummyURI;
if (NS_SUCCEEDED(GetNextURI(dummyURI)))
{
mCurAttrIndex = 0; // Reset so we'll get the first node next time
return NS_OK;
}
// If there weren't any URIs in the attributes,
// then don't accept this node.
mNode = 0;
return NS_ERROR_INVALID_ARG;
}
nsresult NS_NewHTMLURIRefObject(nsIURIRefObject** aResult, nsIDOMNode* aNode)
{
nsRefPtr<nsHTMLURIRefObject> refObject = new nsHTMLURIRefObject();
nsresult rv = refObject->SetNode(aNode);
if (NS_FAILED(rv)) {
*aResult = 0;
return rv;
}
refObject.forget(aResult);
return NS_OK;
}