mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 824823 part 8. Convert nsTextNode to WebIDL. r=peterv
This commit is contained in:
parent
498d64b509
commit
f1feb59fc3
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "nsTextNode.h"
|
||||
#include "mozilla/dom/TextBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/DirectionalityUtils.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
@ -112,13 +113,6 @@ NS_NewTextNode(nsIContent** aInstancePtrResult,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTextNode::nsTextNode(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsGenericDOMDataNode(aNodeInfo)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::TEXT_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
}
|
||||
|
||||
nsTextNode::~nsTextNode()
|
||||
{
|
||||
}
|
||||
@ -136,6 +130,12 @@ NS_INTERFACE_TABLE_HEAD(nsTextNode)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Text)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
|
||||
|
||||
JSObject*
|
||||
nsTextNode::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
|
||||
{
|
||||
return TextBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
bool
|
||||
nsTextNode::IsNodeOfType(uint32_t aFlags) const
|
||||
{
|
||||
@ -185,6 +185,17 @@ void nsTextNode::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
nsGenericDOMDataNode::UnbindFromTree(aDeep, aNullParent);
|
||||
}
|
||||
|
||||
already_AddRefed<nsTextNode>
|
||||
nsTextNode::SplitText(uint32_t aOffset, ErrorResult& rv)
|
||||
{
|
||||
nsCOMPtr<nsIContent> newChild;
|
||||
rv = SplitData(aOffset, getter_AddRefs(newChild));
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<nsTextNode*>(newChild.forget().get());
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
nsTextNode::List(FILE* out, int32_t aIndent) const
|
||||
@ -330,3 +341,4 @@ nsAttributeTextNode::UpdateText(bool aNotify)
|
||||
SetText(attrValue, aNotify);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,16 @@
|
||||
* 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/. */
|
||||
|
||||
#ifndef nsTextNode_h
|
||||
#define nsTextNode_h
|
||||
|
||||
/*
|
||||
* Implementation of DOM Core's nsIDOMText node.
|
||||
*/
|
||||
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsDebug.h"
|
||||
|
||||
/**
|
||||
* Class used to implement DOM text nodes
|
||||
@ -17,7 +21,14 @@ class nsTextNode : public nsGenericDOMDataNode,
|
||||
public nsIDOMText
|
||||
{
|
||||
public:
|
||||
nsTextNode(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
nsTextNode(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsGenericDOMDataNode(aNodeInfo)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::TEXT_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
virtual ~nsTextNode();
|
||||
|
||||
// nsISupports
|
||||
@ -51,8 +62,22 @@ public:
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||
|
||||
// WebIDL API
|
||||
already_AddRefed<nsTextNode> SplitText(uint32_t aOffset,
|
||||
mozilla::ErrorResult& rv);
|
||||
void GetWholeText(nsAString& aWholeText, mozilla::ErrorResult& rv)
|
||||
{
|
||||
rv = GetWholeText(aWholeText);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out, int32_t aIndent) const;
|
||||
virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
|
||||
bool *aTriedToWrap) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // nsTextNode_h
|
||||
|
@ -146,6 +146,7 @@ DOMInterfaces = {
|
||||
'nativeType': 'nsGenericDOMDataNode',
|
||||
'hasXPConnectImpls': True,
|
||||
'hasInstanceInterface': 'nsIDOMCharacterData',
|
||||
'concrete': False
|
||||
},
|
||||
|
||||
'ClientRectList': {
|
||||
@ -704,6 +705,11 @@ DOMInterfaces = {
|
||||
'resultNotAddRefed': [ 'getItem' ]
|
||||
},
|
||||
|
||||
'Text': {
|
||||
'nativeType': 'nsTextNode',
|
||||
'hasInstanceInterface': 'nsIDOMText',
|
||||
},
|
||||
|
||||
'TextDecoder': [
|
||||
{
|
||||
'workers': True,
|
||||
@ -1095,7 +1101,6 @@ addExternalIface('SVGAnimatedString')
|
||||
addExternalIface('SVGLength')
|
||||
addExternalIface('SVGNumber')
|
||||
addExternalIface('SVGSVGElement', nativeType='nsSVGSVGElement')
|
||||
addExternalIface('Text', nativeType='nsTextNode')
|
||||
addExternalIface('TextMetrics', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
||||
addExternalIface('TreeWalker')
|
||||
addExternalIface('Touch', headerFile='nsIDOMTouchEvent.h')
|
||||
|
@ -92,21 +92,7 @@
|
||||
"Attr interface: attribute value": true,
|
||||
"Stringification of document.querySelector(\"[id]\").attributes[0]": "debug",
|
||||
"CharacterData interface: operation remove()": true,
|
||||
"Text interface: existence and properties of interface object": true,
|
||||
"Text interface: existence and properties of interface prototype object": true,
|
||||
"Text interface: existence and properties of interface prototype object's \"constructor\" property": true,
|
||||
"Text interface: attribute wholeText": true,
|
||||
"Stringification of document.createTextNode(\"abc\")": "debug",
|
||||
"Text interface: calling splitText(unsigned long) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
|
||||
"CharacterData interface: calling substringData(unsigned long,unsigned long) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
|
||||
"CharacterData interface: calling appendData(DOMString) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
|
||||
"CharacterData interface: calling insertData(unsigned long,DOMString) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
|
||||
"CharacterData interface: calling deleteData(unsigned long,unsigned long) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
|
||||
"CharacterData interface: calling replaceData(unsigned long,unsigned long,DOMString) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
|
||||
"CharacterData interface: document.createTextNode(\"abc\") must inherit property \"remove\" with the proper type (7)": true,
|
||||
"EventTarget interface: calling addEventListener(DOMString,EventListener,boolean) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
|
||||
"EventTarget interface: calling removeEventListener(DOMString,EventListener,boolean) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
|
||||
"EventTarget interface: calling dispatchEvent(Event) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
|
||||
"ProcessingInstruction interface: existence and properties of interface object": true,
|
||||
"ProcessingInstruction interface: existence and properties of interface prototype object": true,
|
||||
"ProcessingInstruction interface: existence and properties of interface prototype object's \"constructor\" property": true,
|
||||
|
@ -22,7 +22,6 @@ interface NodeIterator;
|
||||
interface ProcessingInstruction;
|
||||
interface Range;
|
||||
interface StyleSheetList;
|
||||
interface Text;
|
||||
interface Touch;
|
||||
interface TouchList;
|
||||
interface TreeWalker;
|
||||
|
@ -11,6 +11,8 @@
|
||||
*/
|
||||
|
||||
interface Text : CharacterData {
|
||||
[Throws]
|
||||
Text splitText(unsigned long offset);
|
||||
[Throws]
|
||||
readonly attribute DOMString wholeText;
|
||||
};
|
||||
|
@ -102,6 +102,7 @@ webidl_files = \
|
||||
SVGPreserveAspectRatio.webidl \
|
||||
SVGTransform.webidl \
|
||||
SVGTransformList.webidl \
|
||||
Text.webidl \
|
||||
TextDecoder.webidl \
|
||||
TextEncoder.webidl \
|
||||
URL.webidl \
|
||||
|
Loading…
Reference in New Issue
Block a user