зеркало из https://github.com/mozilla/gecko-dev.git
Bug 698275 - Various cleanup in HTML element implementations; r=mounir
This commit is contained in:
Родитель
9448a1cf88
Коммит
e977700f50
|
@ -474,13 +474,6 @@ nsGenericHTMLElement::GetAccessKeyLabel(nsAString& aLabel)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool
|
||||
IsBody(nsIContent *aContent)
|
||||
{
|
||||
return aContent->NodeInfo()->Equals(nsGkAtoms::body) &&
|
||||
aContent->IsHTML();
|
||||
}
|
||||
|
||||
static bool IS_TABLE_CELL(nsIAtom* frameType) {
|
||||
return nsGkAtoms::tableCellFrame == frameType ||
|
||||
nsGkAtoms::bcTableCellFrame == frameType;
|
||||
|
@ -516,7 +509,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
|
|||
Element* docElement = GetCurrentDoc()->GetRootElement();
|
||||
nsIContent* content = frame->GetContent();
|
||||
|
||||
if (content && (IsBody(content) || content == docElement)) {
|
||||
if (content && (content->IsHTML(nsGkAtoms::body) || content == docElement)) {
|
||||
parent = frame;
|
||||
}
|
||||
else {
|
||||
|
@ -550,7 +543,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
|
|||
|
||||
// Break if the ancestor frame type makes it suitable as offset parent
|
||||
// and this element is *not* positioned or if we found the body element.
|
||||
if (isOffsetParent || IsBody(content)) {
|
||||
if (isOffsetParent || content->IsHTML(nsGkAtoms::body)) {
|
||||
*aOffsetParent = content;
|
||||
NS_ADDREF(*aOffsetParent);
|
||||
break;
|
||||
|
@ -1090,8 +1083,8 @@ NS_IMETHODIMP
|
|||
nsGenericHTMLElement::SetDraggable(bool aDraggable)
|
||||
{
|
||||
return SetAttrHelper(nsGkAtoms::draggable,
|
||||
aDraggable ? NS_LITERAL_STRING("true") :
|
||||
NS_LITERAL_STRING("false"));
|
||||
aDraggable ? NS_LITERAL_STRING("true")
|
||||
: NS_LITERAL_STRING("false"));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1172,8 +1165,7 @@ nsGenericHTMLElement::FindAncestorForm(nsHTMLFormElement* aCurrentForm)
|
|||
nsIContent* content = this;
|
||||
while (content != bindingParent && content) {
|
||||
// If the current ancestor is a form, return it as our form
|
||||
if (content->Tag() == nsGkAtoms::form &&
|
||||
content->IsHTML()) {
|
||||
if (content->IsHTML(nsGkAtoms::form)) {
|
||||
#ifdef DEBUG
|
||||
if (!nsContentUtils::IsInSameAnonymousTree(this, content)) {
|
||||
// It's possible that we started unbinding at |content| or
|
||||
|
@ -1565,10 +1557,6 @@ nsGenericHTMLElement::GetPrimaryPresState(nsGenericHTMLElement* aContent,
|
|||
result = history->GetState(key, aPresState);
|
||||
if (!*aPresState) {
|
||||
*aPresState = new nsPresState();
|
||||
if (!*aPresState) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
result = history->AddState(key, *aPresState);
|
||||
}
|
||||
}
|
||||
|
@ -1659,7 +1647,7 @@ nsGenericHTMLElement::GetPresContext()
|
|||
// Get the document
|
||||
nsIDocument* doc = GetDocument();
|
||||
if (doc) {
|
||||
// Get presentation shell 0
|
||||
// Get presentation shell.
|
||||
nsIPresShell *presShell = doc->GetShell();
|
||||
if (presShell) {
|
||||
return presShell->GetPresContext();
|
||||
|
@ -1794,9 +1782,9 @@ nsGenericHTMLElement::ParseImageAttribute(nsIAtom* aAttribute,
|
|||
(aAttribute == nsGkAtoms::height)) {
|
||||
return aResult.ParseSpecialIntValue(aString);
|
||||
}
|
||||
else if ((aAttribute == nsGkAtoms::hspace) ||
|
||||
(aAttribute == nsGkAtoms::vspace) ||
|
||||
(aAttribute == nsGkAtoms::border)) {
|
||||
if ((aAttribute == nsGkAtoms::hspace) ||
|
||||
(aAttribute == nsGkAtoms::vspace) ||
|
||||
(aAttribute == nsGkAtoms::border)) {
|
||||
return aResult.ParseIntWithBounds(aString, 0);
|
||||
}
|
||||
return false;
|
||||
|
@ -3137,8 +3125,7 @@ nsGenericHTMLFormElement::UpdateFormOwner(bool aBindToTree,
|
|||
"element should be equals to the current element "
|
||||
"associated with the id in @form!");
|
||||
|
||||
if (element && element->Tag() == nsGkAtoms::form &&
|
||||
element->IsHTML()) {
|
||||
if (element && element->IsHTML(nsGkAtoms::form)) {
|
||||
mForm = static_cast<nsHTMLFormElement*>(element);
|
||||
}
|
||||
}
|
||||
|
@ -3316,9 +3303,8 @@ nsGenericHTMLFrameElement::GetFrameLoader(nsIFrameLoader **aFrameLoader)
|
|||
NS_IMETHODIMP_(already_AddRefed<nsFrameLoader>)
|
||||
nsGenericHTMLFrameElement::GetFrameLoader()
|
||||
{
|
||||
nsFrameLoader* loader = mFrameLoader;
|
||||
NS_IF_ADDREF(loader);
|
||||
return loader;
|
||||
nsRefPtr<nsFrameLoader> loader = mFrameLoader;
|
||||
return loader.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -3398,8 +3384,7 @@ nsGenericHTMLFrameElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|||
aValue, aNotify);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aNameSpaceID == kNameSpaceID_None &&
|
||||
aName == nsGkAtoms::src) {
|
||||
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::src) {
|
||||
// Don't propagate error here. The attribute was successfully set, that's
|
||||
// what we should reflect.
|
||||
LoadSrc();
|
||||
|
@ -3453,18 +3438,18 @@ nsGenericHTMLFrameElement::SizeOf() const
|
|||
nsresult
|
||||
nsGenericHTMLElement::Blur()
|
||||
{
|
||||
if (!ShouldBlur(this))
|
||||
if (!ShouldBlur(this)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
if (!doc)
|
||||
if (!doc) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMWindow* win = doc->GetWindow();
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
return (win && fm) ? fm->ClearFocus(win) : NS_OK;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -3505,8 +3490,8 @@ nsresult nsGenericHTMLElement::Click()
|
|||
// Strong in case the event kills it
|
||||
nsCOMPtr<nsIDocument> doc = GetCurrentDoc();
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell = nsnull;
|
||||
nsRefPtr<nsPresContext> context = nsnull;
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsRefPtr<nsPresContext> context;
|
||||
if (doc) {
|
||||
shell = doc->GetShell();
|
||||
if (shell) {
|
||||
|
@ -3653,8 +3638,9 @@ nsGenericHTMLElement::GetEditor(nsIEditor** aEditor)
|
|||
{
|
||||
*aEditor = nsnull;
|
||||
|
||||
if (!nsContentUtils::IsCallerTrustedForWrite())
|
||||
if (!nsContentUtils::IsCallerTrustedForWrite()) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
return GetEditorInternal(aEditor);
|
||||
}
|
||||
|
@ -3686,6 +3672,8 @@ nsGenericHTMLElement::GetAssociatedEditor()
|
|||
bool
|
||||
nsGenericHTMLElement::IsCurrentBodyElement()
|
||||
{
|
||||
// TODO Bug 698498: Should this handle the case where GetBody returns a
|
||||
// frameset?
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> bodyElement = do_QueryInterface(this);
|
||||
if (!bodyElement) {
|
||||
return false;
|
||||
|
|
|
@ -551,8 +551,6 @@ nsHTMLButtonElement::Reset()
|
|||
NS_IMETHODIMP
|
||||
nsHTMLButtonElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
//
|
||||
// We only submit if we were the button pressed
|
||||
//
|
||||
|
@ -578,7 +576,7 @@ nsHTMLButtonElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
|||
// Get the value
|
||||
//
|
||||
nsAutoString value;
|
||||
rv = GetValue(value);
|
||||
nsresult rv = GetValue(value);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -586,9 +584,7 @@ nsHTMLButtonElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
|||
//
|
||||
// Submit
|
||||
//
|
||||
rv = aFormSubmission->AddNameValuePair(name, value);
|
||||
|
||||
return rv;
|
||||
return aFormSubmission->AddNameValuePair(name, value);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -670,4 +666,3 @@ nsHTMLButtonElement::IntrinsicState() const
|
|||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ nsHTMLCanvasElement::ExtractData(const nsAString& aType,
|
|||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(imgStream, aStream);
|
||||
imgStream.forget(aStream);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,8 @@ nsHTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName,
|
|||
nsRefPtr<nsDOMMemoryFile> file =
|
||||
new nsDOMMemoryFile(imgData, imgSize, aName, type);
|
||||
|
||||
return CallQueryInterface(file, aResult);
|
||||
file.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -457,7 +458,7 @@ nsHTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
|
|||
return rv;
|
||||
}
|
||||
|
||||
*aContext = ctx.forget().get();
|
||||
ctx.forget(aContext);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -572,10 +573,8 @@ nsHTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId,
|
|||
if (!aContextId.Equals(NS_LITERAL_STRING("2d")))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (mCurrentContextId.IsEmpty()) {
|
||||
rv = GetContextHelper(aContextId, false, getter_AddRefs(mCurrentContext));
|
||||
nsresult rv = GetContextHelper(aContextId, false, getter_AddRefs(mCurrentContext));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!mCurrentContext) {
|
||||
return NS_OK;
|
||||
|
@ -602,27 +601,26 @@ nsHTMLCanvasElement::UpdateContext(nsIPropertyBag *aNewContextOptions)
|
|||
if (!mCurrentContext)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsIntSize sz = GetWidthHeight();
|
||||
|
||||
rv = mCurrentContext->SetIsOpaque(GetIsOpaque());
|
||||
nsresult rv = mCurrentContext->SetIsOpaque(GetIsOpaque());
|
||||
if (NS_FAILED(rv)) {
|
||||
mCurrentContext = nsnull;
|
||||
mCurrentContextId.AssignLiteral("");
|
||||
mCurrentContextId.Truncate();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mCurrentContext->SetContextOptions(aNewContextOptions);
|
||||
if (NS_FAILED(rv)) {
|
||||
mCurrentContext = nsnull;
|
||||
mCurrentContextId.AssignLiteral("");
|
||||
mCurrentContextId.Truncate();
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mCurrentContext->SetDimensions(sz.width, sz.height);
|
||||
if (NS_FAILED(rv)) {
|
||||
mCurrentContext = nsnull;
|
||||
mCurrentContextId.AssignLiteral("");
|
||||
mCurrentContextId.Truncate();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -715,10 +713,10 @@ nsHTMLCanvasElement::CountContexts()
|
|||
}
|
||||
|
||||
nsICanvasRenderingContextInternal *
|
||||
nsHTMLCanvasElement::GetContextAtIndex (PRInt32 index)
|
||||
nsHTMLCanvasElement::GetContextAtIndex(PRInt32 index)
|
||||
{
|
||||
if (mCurrentContext && index == 0)
|
||||
return mCurrentContext.get();
|
||||
return mCurrentContext;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ nsHTMLFieldSetElement::nsHTMLFieldSetElement(already_AddRefed<nsINodeInfo> aNode
|
|||
nsHTMLFieldSetElement::~nsHTMLFieldSetElement()
|
||||
{
|
||||
PRUint32 length = mDependentElements.Length();
|
||||
for (PRUint32 i=0; i<length; ++i) {
|
||||
for (PRUint32 i = 0; i < length; ++i) {
|
||||
mDependentElements[i]->ForgetFieldSet(this);
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ nsHTMLFieldSetElement::NotifyElementsForFirstLegendChange(bool aNotify)
|
|||
}
|
||||
|
||||
PRUint32 length = mElements->Length(true);
|
||||
for (PRUint32 i=0; i<length; ++i) {
|
||||
for (PRUint32 i = 0; i < length; ++i) {
|
||||
static_cast<nsGenericHTMLFormElement*>(mElements->GetNodeAt(i))
|
||||
->FieldSetFirstLegendChanged(aNotify);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "nsMappedAttributes.h"
|
||||
#include "nsRuleData.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsAlgorithm.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -217,7 +218,7 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
else
|
||||
size = value->GetIntegerValue();
|
||||
|
||||
size = ((0 < size) ? ((size < 8) ? size : 7) : 1);
|
||||
size = clamped(size, 1, 7);
|
||||
fontSize->SetIntValue(size, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1998,8 +1998,6 @@ nsHTMLFormElement::WalkRadioGroup(const nsAString& aName,
|
|||
nsIRadioVisitor* aVisitor,
|
||||
bool aFlushContent)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (aName.IsEmpty()) {
|
||||
//
|
||||
// XXX If the name is empty, it's not stored in the control list. There
|
||||
|
@ -2007,60 +2005,52 @@ nsHTMLFormElement::WalkRadioGroup(const nsAString& aName,
|
|||
//
|
||||
nsCOMPtr<nsIFormControl> control;
|
||||
PRUint32 len = GetElementCount();
|
||||
for (PRUint32 i=0; i<len; i++) {
|
||||
for (PRUint32 i = 0; i < len; i++) {
|
||||
control = GetElementAt(i);
|
||||
if (control->GetType() == NS_FORM_INPUT_RADIO) {
|
||||
nsCOMPtr<nsIContent> controlContent(do_QueryInterface(control));
|
||||
if (controlContent) {
|
||||
if (controlContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
|
||||
EmptyString(), eCaseMatters)) {
|
||||
if (!aVisitor->Visit(control)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Get the control / list of controls from the form using form["name"]
|
||||
//
|
||||
nsCOMPtr<nsISupports> item;
|
||||
item = DoResolveName(aName, aFlushContent);
|
||||
rv = item ? NS_OK : NS_ERROR_FAILURE;
|
||||
|
||||
if (item) {
|
||||
//
|
||||
// If it's just a lone radio button, then select it.
|
||||
//
|
||||
nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(item));
|
||||
if (formControl) {
|
||||
if (formControl->GetType() == NS_FORM_INPUT_RADIO) {
|
||||
aVisitor->Visit(formControl);
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMNodeList> nodeList(do_QueryInterface(item));
|
||||
if (nodeList) {
|
||||
PRUint32 length = 0;
|
||||
nodeList->GetLength(&length);
|
||||
for (PRUint32 i=0; i<length; i++) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nodeList->Item(i, getter_AddRefs(node));
|
||||
nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(node));
|
||||
if (formControl) {
|
||||
if (formControl->GetType() == NS_FORM_INPUT_RADIO) {
|
||||
if (!aVisitor->Visit(formControl)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIContent> controlContent = do_QueryInterface(control);
|
||||
if (controlContent &&
|
||||
controlContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
|
||||
EmptyString(), eCaseMatters) &&
|
||||
!aVisitor->Visit(control)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
// Get the control / list of controls from the form using form["name"]
|
||||
nsCOMPtr<nsISupports> item = DoResolveName(aName, aFlushContent);
|
||||
if (!item) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// If it's just a lone radio button, then select it.
|
||||
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(item);
|
||||
if (formControl) {
|
||||
if (formControl->GetType() == NS_FORM_INPUT_RADIO) {
|
||||
aVisitor->Visit(formControl);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNodeList> nodeList = do_QueryInterface(item);
|
||||
if (!nodeList) {
|
||||
return NS_OK;
|
||||
}
|
||||
PRUint32 length = 0;
|
||||
nodeList->GetLength(&length);
|
||||
for (PRUint32 i = 0; i < length; i++) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nodeList->Item(i, getter_AddRefs(node));
|
||||
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(node);
|
||||
if (formControl && formControl->GetType() == NS_FORM_INPUT_RADIO &&
|
||||
!aVisitor->Visit(formControl)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2181,13 +2171,12 @@ void
|
|||
nsFormControlList::Clear()
|
||||
{
|
||||
// Null out childrens' pointer to me. No refcounting here
|
||||
PRInt32 i;
|
||||
for (i = mElements.Length()-1; i >= 0; i--) {
|
||||
for (PRInt32 i = mElements.Length() - 1; i >= 0; i--) {
|
||||
mElements[i]->ClearForm(false);
|
||||
}
|
||||
mElements.Clear();
|
||||
|
||||
for (i = mNotInElements.Length()-1; i >= 0; i--) {
|
||||
for (PRInt32 i = mNotInElements.Length() - 1; i >= 0; i--) {
|
||||
mNotInElements[i]->ClearForm(false);
|
||||
}
|
||||
mNotInElements.Clear();
|
||||
|
@ -2277,31 +2266,33 @@ nsFormControlList::NamedItem(const nsAString& aName,
|
|||
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
|
||||
if (!mNameLookupTable.Get(aName, getter_AddRefs(supports))) // key not found
|
||||
return rv;
|
||||
|
||||
if (supports) {
|
||||
// We found something, check if it's a node
|
||||
CallQueryInterface(supports, aReturn);
|
||||
|
||||
if (!*aReturn) {
|
||||
// If not, we check if it's a node list.
|
||||
nsCOMPtr<nsIDOMNodeList> nodeList(do_QueryInterface(supports));
|
||||
NS_ASSERTION(nodeList, "Huh, what's going one here?");
|
||||
|
||||
if (nodeList) {
|
||||
// And since we're only asking for one node here, we return the first
|
||||
// one from the list.
|
||||
rv = nodeList->Item(0, aReturn);
|
||||
}
|
||||
}
|
||||
if (!mNameLookupTable.Get(aName, getter_AddRefs(supports))) {
|
||||
// key not found
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
if (!supports) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We found something, check if it's a node
|
||||
CallQueryInterface(supports, aReturn);
|
||||
if (*aReturn) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If not, we check if it's a node list.
|
||||
nsCOMPtr<nsIDOMNodeList> nodeList = do_QueryInterface(supports);
|
||||
NS_ASSERTION(nodeList, "Huh, what's going one here?");
|
||||
if (!nodeList) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// And since we're only asking for one node here, we return the first
|
||||
// one from the list.
|
||||
return nodeList->Item(0, aReturn);
|
||||
}
|
||||
|
||||
nsISupports*
|
||||
|
@ -2328,12 +2319,12 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild,
|
|||
|
||||
if (!supports) {
|
||||
// No entry found, add the form control
|
||||
NS_ENSURE_TRUE( mNameLookupTable.Put(aName,
|
||||
NS_ISUPPORTS_CAST(nsIContent*, aChild)),
|
||||
NS_ERROR_FAILURE );
|
||||
NS_ENSURE_TRUE(mNameLookupTable.Put(aName,
|
||||
NS_ISUPPORTS_CAST(nsIContent*, aChild)),
|
||||
NS_ERROR_FAILURE);
|
||||
} else {
|
||||
// Found something in the hash, check its type
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(supports));
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(supports);
|
||||
|
||||
if (content) {
|
||||
// Check if the new content is the same as the one we found in the
|
||||
|
@ -2347,7 +2338,6 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild,
|
|||
// Found an element, create a list, add the element to the list and put
|
||||
// the list in the hash
|
||||
nsSimpleContentList *list = new nsSimpleContentList(mForm);
|
||||
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ASSERTION(content->GetParent(), "Item in list without parent");
|
||||
|
||||
|
@ -2365,12 +2355,12 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild,
|
|||
NS_ERROR_FAILURE);
|
||||
} else {
|
||||
// There's already a list in the hash, add the child to the list
|
||||
nsCOMPtr<nsIDOMNodeList> nodeList(do_QueryInterface(supports));
|
||||
nsCOMPtr<nsIDOMNodeList> nodeList = do_QueryInterface(supports);
|
||||
NS_ENSURE_TRUE(nodeList, NS_ERROR_FAILURE);
|
||||
|
||||
// Upcast, uggly, but it works!
|
||||
nsSimpleContentList *list = static_cast<nsSimpleContentList *>
|
||||
((nsIDOMNodeList *)nodeList.get());
|
||||
nsSimpleContentList *list =
|
||||
static_cast<nsSimpleContentList*>(nodeList.get());
|
||||
|
||||
NS_ASSERTION(list->Length() > 1,
|
||||
"List should have been converted back to a single element");
|
||||
|
@ -2379,7 +2369,7 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild,
|
|||
// already in the list, since if it tests true the child would
|
||||
// have come at the end of the list, and the PositionIsBefore
|
||||
// will test false.
|
||||
if(nsContentUtils::PositionIsBefore(list->GetNodeAt(list->Length() - 1), aChild)) {
|
||||
if (nsContentUtils::PositionIsBefore(list->GetNodeAt(list->Length() - 1), aChild)) {
|
||||
list->AppendElement(aChild);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2455,8 +2445,7 @@ nsFormControlList::RemoveElementFromTable(nsGenericHTMLFormElement* aChild,
|
|||
NS_ENSURE_TRUE(nodeList, NS_ERROR_FAILURE);
|
||||
|
||||
// Upcast, uggly, but it works!
|
||||
nsBaseContentList *list = static_cast<nsBaseContentList *>
|
||||
((nsIDOMNodeList *)nodeList.get());
|
||||
nsBaseContentList *list = static_cast<nsBaseContentList*>(nodeList.get());
|
||||
|
||||
list->RemoveElement(aChild);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
KeyType GetKey() const { return mStr; }
|
||||
bool KeyEquals(const KeyTypePointer aKey) const
|
||||
{
|
||||
return mStr.Equals(*aKey,nsCaseInsensitiveStringComparator());
|
||||
return mStr.Equals(*aKey, nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
|
||||
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
|
||||
|
|
|
@ -678,7 +678,7 @@ nsHTMLImageElement::GetCORSMode()
|
|||
if (value) {
|
||||
NS_ASSERTION(value->Type() == nsAttrValue::eEnum,
|
||||
"Why is this not an enum value?");
|
||||
ret = (nsImageLoadingContent::CORSMode) value->GetEnumValue();
|
||||
ret = nsImageLoadingContent::CORSMode(value->GetEnumValue());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
#include "nsRadioVisitor.h"
|
||||
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/Util.h" // DebugOnly
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
@ -257,8 +258,6 @@ protected:
|
|||
NS_IMETHODIMP
|
||||
AsyncClickHandler::Run()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Get parent nsPIDOMWindow object.
|
||||
nsCOMPtr<nsIDocument> doc = mInput->OwnerDoc();
|
||||
|
||||
|
@ -296,9 +295,10 @@ AsyncClickHandler::Run()
|
|||
|
||||
bool multi = mInput->HasAttr(kNameSpaceID_None, nsGkAtoms::multiple);
|
||||
|
||||
rv = filePicker->Init(win, title, multi ?
|
||||
(PRInt16)nsIFilePicker::modeOpenMultiple :
|
||||
(PRInt16)nsIFilePicker::modeOpen);
|
||||
nsresult rv = filePicker->Init(win, title,
|
||||
multi
|
||||
? static_cast<PRInt16>(nsIFilePicker::modeOpenMultiple)
|
||||
: static_cast<PRInt16>(nsIFilePicker::modeOpen));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mInput->HasAttr(kNameSpaceID_None, nsGkAtoms::accept)) {
|
||||
|
@ -485,9 +485,7 @@ UploadLastDir::FetchLastUsedDirectory(nsIURI* aURI, nsILocalFile** aFile)
|
|||
if (!localFile)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
localFile->InitWithPath(prefStr);
|
||||
|
||||
*aFile = localFile;
|
||||
NS_ADDREF(*aFile);
|
||||
localFile.forget(aFile);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -663,9 +661,9 @@ nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
|||
*aResult = nsnull;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
|
||||
nsHTMLInputElement *it = new nsHTMLInputElement(ni.forget(), NOT_FROM_PARSER);
|
||||
nsRefPtr<nsHTMLInputElement> it =
|
||||
new nsHTMLInputElement(ni.forget(), NOT_FROM_PARSER);
|
||||
|
||||
nsCOMPtr<nsINode> kungFuDeathGrip = it;
|
||||
nsresult rv = CopyInnerTo(it);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -712,8 +710,7 @@ nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
|||
break;
|
||||
}
|
||||
|
||||
kungFuDeathGrip.swap(*aResult);
|
||||
|
||||
it.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -788,9 +785,7 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|||
if (GET_BOOLBIT(mBitField, BF_PARSER_CREATING)) {
|
||||
SET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED, true);
|
||||
} else {
|
||||
bool defaultChecked;
|
||||
GetDefaultChecked(&defaultChecked);
|
||||
DoSetChecked(defaultChecked, true, true);
|
||||
DoSetChecked(DefaultChecked(), true, true);
|
||||
SetCheckedChanged(false);
|
||||
}
|
||||
}
|
||||
|
@ -1011,22 +1006,25 @@ nsHTMLInputElement::SetValue(const nsAString& aValue)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::GetList(nsIDOMHTMLElement** aValue)
|
||||
{
|
||||
*aValue = nsnull;
|
||||
|
||||
nsAutoString dataListId;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::list, dataListId);
|
||||
if (!dataListId.IsEmpty()) {
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
|
||||
if (doc) {
|
||||
Element* elem = doc->GetElementById(dataListId);
|
||||
|
||||
if (elem && elem->IsHTML(nsGkAtoms::datalist)) {
|
||||
CallQueryInterface(elem, aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
if (dataListId.IsEmpty()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aValue = nsnull;
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
if (!doc) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Element* element = doc->GetElementById(dataListId);
|
||||
if (!element || !element->IsHTML(nsGkAtoms::datalist)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
CallQueryInterface(element, aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1042,8 +1040,11 @@ nsHTMLInputElement::MozGetFileNameArray(PRUint32 *aLength, PRUnichar ***aFileNam
|
|||
*aLength = mFiles.Count();
|
||||
PRUnichar **ret =
|
||||
static_cast<PRUnichar **>(NS_Alloc(mFiles.Count() * sizeof(PRUnichar*)));
|
||||
|
||||
for (PRInt32 i = 0; i < mFiles.Count(); i++) {
|
||||
if (!ret) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (PRInt32 i = 0; i < mFiles.Count(); i++) {
|
||||
nsString str;
|
||||
mFiles[i]->GetMozFullPathInternal(str);
|
||||
ret[i] = NS_strdup(str.get());
|
||||
|
@ -1243,7 +1244,7 @@ nsHTMLInputElement::GetDisplayFileName(nsAString& aValue) const
|
|||
}
|
||||
|
||||
aValue.Truncate();
|
||||
for (PRUint32 i = 0; i < (PRUint32)mFiles.Count(); ++i) {
|
||||
for (PRInt32 i = 0; i < mFiles.Count(); ++i) {
|
||||
nsString str;
|
||||
mFiles[i]->GetMozFullPathInternal(str);
|
||||
if (i == 0) {
|
||||
|
@ -1319,7 +1320,7 @@ nsHTMLInputElement::UpdateFileList()
|
|||
mFileList->Clear();
|
||||
|
||||
const nsCOMArray<nsIDOMFile>& files = GetFiles();
|
||||
for (PRUint32 i = 0; i < (PRUint32)files.Count(); ++i) {
|
||||
for (PRInt32 i = 0; i < files.Count(); ++i) {
|
||||
if (!mFileList->Append(files[i])) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1457,8 +1458,6 @@ nsresult
|
|||
nsHTMLInputElement::DoSetChecked(bool aChecked, bool aNotify,
|
||||
bool aSetValueChanged)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// If the user or JS attempts to set checked, whether it actually changes the
|
||||
// value or not, we say the value was changed so that defaultValue don't
|
||||
// affect it no more.
|
||||
|
@ -1466,66 +1465,53 @@ nsHTMLInputElement::DoSetChecked(bool aChecked, bool aNotify,
|
|||
DoSetCheckedChanged(true, aNotify);
|
||||
}
|
||||
|
||||
//
|
||||
// Don't do anything if we're not changing whether it's checked (it would
|
||||
// screw up state actually, especially when you are setting radio button to
|
||||
// false)
|
||||
//
|
||||
if (GetChecked() == aChecked) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// Set checked
|
||||
//
|
||||
if (mType == NS_FORM_INPUT_RADIO) {
|
||||
//
|
||||
// For radio button, we need to do some extra fun stuff
|
||||
//
|
||||
if (aChecked) {
|
||||
rv = RadioSetChecked(aNotify);
|
||||
} else {
|
||||
nsIRadioGroupContainer* container = GetRadioGroupContainer();
|
||||
if (container) {
|
||||
nsAutoString name;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
||||
container->SetCurrentRadioButton(name, nsnull);
|
||||
}
|
||||
// SetCheckedInternal is going to ask all radios to update their
|
||||
// validity state. We have to be sure the radio group container knows
|
||||
// the currently selected radio.
|
||||
SetCheckedInternal(false, aNotify);
|
||||
}
|
||||
} else {
|
||||
if (mType != NS_FORM_INPUT_RADIO) {
|
||||
SetCheckedInternal(aChecked, aNotify);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
// For radio button, we need to do some extra fun stuff
|
||||
if (aChecked) {
|
||||
return RadioSetChecked(aNotify);
|
||||
}
|
||||
|
||||
nsIRadioGroupContainer* container = GetRadioGroupContainer();
|
||||
if (container) {
|
||||
nsAutoString name;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
||||
container->SetCurrentRadioButton(name, nsnull);
|
||||
}
|
||||
// SetCheckedInternal is going to ask all radios to update their
|
||||
// validity state. We have to be sure the radio group container knows
|
||||
// the currently selected radio.
|
||||
SetCheckedInternal(false, aNotify);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLInputElement::RadioSetChecked(bool aNotify)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
//
|
||||
// Find the selected radio button so we can deselect it
|
||||
//
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> currentlySelected = GetSelectedRadioButton();
|
||||
|
||||
//
|
||||
// Deselect the currently selected radio button
|
||||
//
|
||||
if (currentlySelected) {
|
||||
// Pass true for the aNotify parameter since the currently selected
|
||||
// button is already in the document.
|
||||
static_cast<nsHTMLInputElement*>
|
||||
(static_cast<nsIDOMHTMLInputElement*>(currentlySelected))->SetCheckedInternal(false, true);
|
||||
static_cast<nsHTMLInputElement*>(currentlySelected.get())
|
||||
->SetCheckedInternal(false, true);
|
||||
}
|
||||
|
||||
//
|
||||
// Let the group know that we are now the One True Radio Button
|
||||
//
|
||||
nsresult rv = NS_OK;
|
||||
nsIRadioGroupContainer* container = GetRadioGroupContainer();
|
||||
if (container) {
|
||||
nsAutoString name;
|
||||
|
@ -1566,9 +1552,7 @@ nsHTMLInputElement::GetRadioGroupContainer() const
|
|||
already_AddRefed<nsIDOMHTMLInputElement>
|
||||
nsHTMLInputElement::GetSelectedRadioButton()
|
||||
{
|
||||
nsIDOMHTMLInputElement* selected;
|
||||
nsIRadioGroupContainer* container = GetRadioGroupContainer();
|
||||
|
||||
if (!container) {
|
||||
return nsnull;
|
||||
}
|
||||
|
@ -1576,8 +1560,9 @@ nsHTMLInputElement::GetSelectedRadioButton()
|
|||
nsAutoString name;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
||||
|
||||
container->GetCurrentRadioButton(name, &selected);
|
||||
return selected;
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> selected;
|
||||
container->GetCurrentRadioButton(name, getter_AddRefs(selected));
|
||||
return selected.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1596,7 +1581,7 @@ nsHTMLInputElement::MaybeSubmitForm(nsPresContext* aPresContext)
|
|||
// Get the default submit element
|
||||
nsIFormControl* submitControl = mForm->GetDefaultSubmitElement();
|
||||
if (submitControl) {
|
||||
nsCOMPtr<nsIContent> submitContent(do_QueryInterface(submitControl));
|
||||
nsCOMPtr<nsIContent> submitContent = do_QueryInterface(submitControl);
|
||||
NS_ASSERTION(submitContent, "Form control not implementing nsIContent?!");
|
||||
// Fire the button's onclick handler and let the button handle
|
||||
// submitting the form.
|
||||
|
@ -1610,9 +1595,9 @@ nsHTMLInputElement::MaybeSubmitForm(nsPresContext* aPresContext)
|
|||
// bug 592124.
|
||||
// If there's only one text control, just submit the form
|
||||
// Hold strong ref across the event
|
||||
nsRefPtr<nsHTMLFormElement> form(mForm);
|
||||
nsRefPtr<nsHTMLFormElement> form = mForm;
|
||||
nsFormEvent event(true, NS_FORM_SUBMIT);
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
shell->HandleDOMEventWithTarget(mForm, &event, &status);
|
||||
}
|
||||
|
||||
|
@ -1622,14 +1607,10 @@ nsHTMLInputElement::MaybeSubmitForm(nsPresContext* aPresContext)
|
|||
void
|
||||
nsHTMLInputElement::SetCheckedInternal(bool aChecked, bool aNotify)
|
||||
{
|
||||
//
|
||||
// Set the value
|
||||
//
|
||||
SET_BOOLBIT(mBitField, BF_CHECKED, aChecked);
|
||||
|
||||
//
|
||||
// Notify the frame
|
||||
//
|
||||
if (mType == NS_FORM_INPUT_CHECKBOX || mType == NS_FORM_INPUT_RADIO) {
|
||||
nsIFrame* frame = GetPrimaryFrame();
|
||||
if (frame) {
|
||||
|
@ -1647,31 +1628,31 @@ nsHTMLInputElement::SetCheckedInternal(bool aChecked, bool aNotify)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::Focus()
|
||||
{
|
||||
if (mType == NS_FORM_INPUT_FILE) {
|
||||
// for file inputs, focus the button instead
|
||||
nsIFrame* frame = GetPrimaryFrame();
|
||||
if (frame) {
|
||||
nsIFrame* childFrame = frame->GetFirstPrincipalChild();
|
||||
while (childFrame) {
|
||||
// see if the child is a button control
|
||||
nsCOMPtr<nsIFormControl> formCtrl =
|
||||
do_QueryInterface(childFrame->GetContent());
|
||||
if (formCtrl && formCtrl->GetType() == NS_FORM_INPUT_BUTTON) {
|
||||
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(formCtrl));
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm && element)
|
||||
fm->SetFocus(element, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
childFrame = childFrame->GetNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
if (mType != NS_FORM_INPUT_FILE) {
|
||||
return nsGenericHTMLElement::Focus();
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::Focus();
|
||||
// For file inputs, focus the button instead.
|
||||
nsIFrame* frame = GetPrimaryFrame();
|
||||
if (frame) {
|
||||
for (nsIFrame* childFrame = frame->GetFirstPrincipalChild();
|
||||
childFrame;
|
||||
childFrame = childFrame->GetNextSibling()) {
|
||||
// See if the child is a button control.
|
||||
nsCOMPtr<nsIFormControl> formCtrl =
|
||||
do_QueryInterface(childFrame->GetContent());
|
||||
if (formCtrl && formCtrl->GetType() == NS_FORM_INPUT_BUTTON) {
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(formCtrl);
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm && element) {
|
||||
fm->SetFocus(element, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1768,21 +1749,21 @@ nsHTMLInputElement::NeedToInitializeEditorForEvent(nsEventChainPreVisitor& aVisi
|
|||
// certain types of events, because we know that those events are safe to be
|
||||
// handled without the editor being initialized. These events include:
|
||||
// mousein/move/out, and DOM mutation events.
|
||||
if (IsSingleLineTextControl(false) &&
|
||||
aVisitor.mEvent->eventStructType != NS_MUTATION_EVENT) {
|
||||
if (!IsSingleLineTextControl(false) ||
|
||||
aVisitor.mEvent->eventStructType == NS_MUTATION_EVENT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (aVisitor.mEvent->message) {
|
||||
case NS_MOUSE_MOVE:
|
||||
case NS_MOUSE_ENTER:
|
||||
case NS_MOUSE_EXIT:
|
||||
case NS_MOUSE_ENTER_SYNTH:
|
||||
case NS_MOUSE_EXIT_SYNTH:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
switch (aVisitor.mEvent->message) {
|
||||
case NS_MOUSE_MOVE:
|
||||
case NS_MOUSE_ENTER:
|
||||
case NS_MOUSE_EXIT:
|
||||
case NS_MOUSE_ENTER_SYNTH:
|
||||
case NS_MOUSE_EXIT_SYNTH:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1879,7 +1860,7 @@ nsHTMLInputElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
|||
|
||||
default:
|
||||
break;
|
||||
} //switch
|
||||
}
|
||||
}
|
||||
|
||||
if (originalCheckedValue) {
|
||||
|
@ -2009,7 +1990,7 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
|||
mForm->OnSubmitClickEnd();
|
||||
}
|
||||
break;
|
||||
} //switch
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the flag for other content besides this text field
|
||||
|
@ -2873,7 +2854,7 @@ nsHTMLInputElement::SetSelectionDirection(const nsAString& aDirection) {
|
|||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::GetPhonetic(nsAString& aPhonetic)
|
||||
{
|
||||
aPhonetic.Truncate(0);
|
||||
aPhonetic.Truncate();
|
||||
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
|
||||
|
||||
if (formControlFrame) {
|
||||
|
@ -2935,9 +2916,7 @@ nsHTMLInputElement::Reset()
|
|||
case VALUE_MODE_VALUE:
|
||||
return SetDefaultValueAsValue();
|
||||
case VALUE_MODE_DEFAULT_ON:
|
||||
bool resetVal;
|
||||
GetDefaultChecked(&resetVal);
|
||||
return DoSetChecked(resetVal, true, false);
|
||||
return DoSetChecked(DefaultChecked(), true, false);
|
||||
case VALUE_MODE_FILENAME:
|
||||
ClearFiles(false);
|
||||
return NS_OK;
|
||||
|
@ -2950,8 +2929,6 @@ nsHTMLInputElement::Reset()
|
|||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Disabled elements don't submit
|
||||
// For type=reset, and type=button, we just never submit, period.
|
||||
// For type=image and type=button, we only submit if we were the button
|
||||
|
@ -3012,7 +2989,7 @@ nsHTMLInputElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
|||
|
||||
// Get the value
|
||||
nsAutoString value;
|
||||
rv = GetValue(value);
|
||||
nsresult rv = GetValue(value);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -3034,7 +3011,7 @@ nsHTMLInputElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
|||
|
||||
const nsCOMArray<nsIDOMFile>& files = GetFiles();
|
||||
|
||||
for (PRUint32 i = 0; i < (PRUint32)files.Count(); ++i) {
|
||||
for (PRInt32 i = 0; i < files.Count(); ++i) {
|
||||
aFormSubmission->AddNameFilePair(name, files[i]);
|
||||
}
|
||||
|
||||
|
@ -3051,39 +3028,28 @@ nsHTMLInputElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
|||
if (mType == NS_FORM_INPUT_HIDDEN && name.EqualsLiteral("_charset_")) {
|
||||
nsCString charset;
|
||||
aFormSubmission->GetCharset(charset);
|
||||
rv = aFormSubmission->AddNameValuePair(name,
|
||||
NS_ConvertASCIItoUTF16(charset));
|
||||
return aFormSubmission->AddNameValuePair(name,
|
||||
NS_ConvertASCIItoUTF16(charset));
|
||||
}
|
||||
else if (IsSingleLineTextControl(true) &&
|
||||
name.EqualsLiteral("isindex") &&
|
||||
aFormSubmission->SupportsIsindexSubmission()) {
|
||||
rv = aFormSubmission->AddIsindex(value);
|
||||
if (IsSingleLineTextControl(true) &&
|
||||
name.EqualsLiteral("isindex") &&
|
||||
aFormSubmission->SupportsIsindexSubmission()) {
|
||||
return aFormSubmission->AddIsindex(value);
|
||||
}
|
||||
else {
|
||||
rv = aFormSubmission->AddNameValuePair(name, value);
|
||||
}
|
||||
|
||||
return rv;
|
||||
return aFormSubmission->AddNameValuePair(name, value);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::SaveState()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsRefPtr<nsHTMLInputElementState> inputState = nsnull;
|
||||
|
||||
nsRefPtr<nsHTMLInputElementState> inputState;
|
||||
switch (mType) {
|
||||
case NS_FORM_INPUT_CHECKBOX:
|
||||
case NS_FORM_INPUT_RADIO:
|
||||
{
|
||||
if (GetCheckedChanged()) {
|
||||
inputState = new nsHTMLInputElementState();
|
||||
if (!inputState) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
inputState->SetChecked(GetChecked());
|
||||
}
|
||||
break;
|
||||
|
@ -3101,13 +3067,10 @@ nsHTMLInputElement::SaveState()
|
|||
{
|
||||
if (GetValueChanged()) {
|
||||
inputState = new nsHTMLInputElementState();
|
||||
if (!inputState) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
GetValue(value);
|
||||
rv = nsLinebreakConverter::ConvertStringLineBreaks(
|
||||
DebugOnly<nsresult> rv =
|
||||
nsLinebreakConverter::ConvertStringLineBreaks(
|
||||
value,
|
||||
nsLinebreakConverter::eLinebreakPlatform,
|
||||
nsLinebreakConverter::eLinebreakContent);
|
||||
|
@ -3120,16 +3083,13 @@ nsHTMLInputElement::SaveState()
|
|||
{
|
||||
if (mFiles.Count()) {
|
||||
inputState = new nsHTMLInputElementState();
|
||||
if (!inputState) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
inputState->SetFiles(mFiles);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsPresState* state = nsnull;
|
||||
if (inputState) {
|
||||
rv = GetPrimaryPresState(this, &state);
|
||||
|
@ -3160,9 +3120,8 @@ nsHTMLInputElement::DoneCreatingElement()
|
|||
// types.
|
||||
//
|
||||
bool restoredCheckedState =
|
||||
GET_BOOLBIT(mBitField, BF_INHIBIT_RESTORATION) ?
|
||||
false :
|
||||
RestoreFormControlState(this, this);
|
||||
!GET_BOOLBIT(mBitField, BF_INHIBIT_RESTORATION) &&
|
||||
RestoreFormControlState(this, this);
|
||||
|
||||
//
|
||||
// If restore does not occur, we initialize .checked using the CHECKED
|
||||
|
@ -3170,9 +3129,7 @@ nsHTMLInputElement::DoneCreatingElement()
|
|||
//
|
||||
if (!restoredCheckedState &&
|
||||
GET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED)) {
|
||||
bool resetVal;
|
||||
GetDefaultChecked(&resetVal);
|
||||
DoSetChecked(resetVal, false, true);
|
||||
DoSetChecked(DefaultChecked(), false, true);
|
||||
DoSetCheckedChanged(false, false);
|
||||
}
|
||||
|
||||
|
@ -3205,11 +3162,7 @@ nsHTMLInputElement::IntrinsicState() const
|
|||
}
|
||||
|
||||
// Check whether we are the default checked element (:default)
|
||||
// The call is to an interface function, which makes it non-const, so we
|
||||
// use a nasty hack :(
|
||||
bool defaultState = false;
|
||||
const_cast<nsHTMLInputElement*>(this)->GetDefaultChecked(&defaultState);
|
||||
if (defaultState) {
|
||||
if (DefaultChecked()) {
|
||||
state |= NS_EVENT_STATE_DEFAULT;
|
||||
}
|
||||
} else if (mType == NS_FORM_INPUT_IMAGE) {
|
||||
|
@ -3755,10 +3708,8 @@ nsHTMLInputElement::UpdateValueMissingValidityStateForRadio(bool aIgnoreSelf)
|
|||
|
||||
// If there is no selection, that might mean the radio is not in a group.
|
||||
// In that case, we can look for the checked state of the radio.
|
||||
bool selected = selection ? true
|
||||
: aIgnoreSelf ? false : GetChecked();
|
||||
bool required = aIgnoreSelf ? false
|
||||
: HasAttr(kNameSpaceID_None, nsGkAtoms::required);
|
||||
bool selected = selection || (!aIgnoreSelf && GetChecked());
|
||||
bool required = !aIgnoreSelf && HasAttr(kNameSpaceID_None, nsGkAtoms::required);
|
||||
bool valueMissing = false;
|
||||
|
||||
nsCOMPtr<nsIRadioGroupContainer> container = GetRadioGroupContainer();
|
||||
|
@ -4120,9 +4071,9 @@ nsHTMLInputElement::OnValueChanged(bool aNotify)
|
|||
|
||||
// :-moz-placeholder pseudo-class may change when the value changes.
|
||||
// However, we don't want to waste cycles if the state doesn't apply.
|
||||
if (PlaceholderApplies()
|
||||
&& HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder)
|
||||
&& !nsContentUtils::IsFocusedContent((nsIContent*)(this))) {
|
||||
if (PlaceholderApplies() &&
|
||||
HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder) &&
|
||||
!nsContentUtils::IsFocusedContent(this)) {
|
||||
UpdateState(aNotify);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -320,6 +320,10 @@ public:
|
|||
*/
|
||||
void UpdateValidityUIBits(bool aIsFocused);
|
||||
|
||||
bool DefaultChecked() const {
|
||||
return HasAttr(kNameSpaceID_None, nsGkAtoms::checked);
|
||||
}
|
||||
|
||||
protected:
|
||||
// Pull IsSingleLineTextControl into our scope, otherwise it'd be hidden
|
||||
// by the nsITextControlElement version.
|
||||
|
|
|
@ -104,11 +104,8 @@ nsHTMLLabelElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLLabelElement::GetControl(nsIDOMHTMLElement** aElement)
|
||||
{
|
||||
*aElement = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLElement> element = do_QueryInterface(GetLabeledElement());
|
||||
|
||||
element.swap(*aElement);
|
||||
element.forget(aElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -170,7 +167,7 @@ DestroyMouseDownPoint(void * /*aObject*/,
|
|||
void * aPropertyValue,
|
||||
void * /*aData*/)
|
||||
{
|
||||
nsIntPoint *pt = (nsIntPoint *)aPropertyValue;
|
||||
nsIntPoint* pt = static_cast<nsIntPoint*>(aPropertyValue);
|
||||
delete pt;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ NS_IMPL_ELEMENT_CLONE(nsHTMLLegendElement)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLLegendElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
||||
{
|
||||
Element *form = GetFormElement();
|
||||
Element* form = GetFormElement();
|
||||
|
||||
return form ? CallQueryInterface(form, aForm) : NS_OK;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ nsHTMLLegendElement::GetFieldSet()
|
|||
{
|
||||
nsIContent* parent = GetParent();
|
||||
|
||||
if (parent && parent->IsHTML() && parent->Tag() == nsGkAtoms::fieldset) {
|
||||
if (parent && parent->IsHTML(nsGkAtoms::fieldset)) {
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,9 @@ public:
|
|||
|
||||
static nsHTMLLegendElement* FromContent(nsIContent *aContent)
|
||||
{
|
||||
if (aContent->IsHTML() && aContent->Tag() == nsGkAtoms::legend)
|
||||
if (aContent->IsHTML(nsGkAtoms::legend)) {
|
||||
return static_cast<nsHTMLLegendElement*>(aContent);
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ NS_IMPL_ELEMENT_CLONE(nsHTMLLinkElement)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLLinkElement::GetDisabled(bool* aDisabled)
|
||||
{
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss(do_QueryInterface(GetStyleSheet()));
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss = do_QueryInterface(GetStyleSheet());
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (ss) {
|
||||
|
@ -181,7 +181,7 @@ nsHTMLLinkElement::GetDisabled(bool* aDisabled)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLLinkElement::SetDisabled(bool aDisabled)
|
||||
{
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss(do_QueryInterface(GetStyleSheet()));
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss = do_QueryInterface(GetStyleSheet());
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (ss) {
|
||||
|
@ -281,11 +281,9 @@ nsHTMLLinkElement::CreateAndDispatchEvent(nsIDocument* aDoc,
|
|||
|
||||
nsRefPtr<nsPLDOMEvent> event = new nsPLDOMEvent(this, aEventName, true,
|
||||
true);
|
||||
if (event) {
|
||||
// Always run async in order to avoid running script when the content
|
||||
// sink isn't expecting it.
|
||||
event->PostDOMEvent();
|
||||
}
|
||||
// Always run async in order to avoid running script when the content
|
||||
// sink isn't expecting it.
|
||||
event->PostDOMEvent();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -116,7 +116,7 @@ nsHTMLMapElement::GetAreas(nsIDOMHTMLCollection** aAreas)
|
|||
if (!mAreas) {
|
||||
// Not using NS_GetContentList because this should not be cached
|
||||
mAreas = new nsContentList(this,
|
||||
mNodeInfo->NamespaceID(),
|
||||
kNameSpaceID_XHTML,
|
||||
nsGkAtoms::area,
|
||||
nsGkAtoms::area,
|
||||
false);
|
||||
|
|
|
@ -298,9 +298,8 @@ NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnStartRequest(nsIRequest*
|
|||
}
|
||||
|
||||
// Don't continue to load if the request failed or has been canceled.
|
||||
nsresult rv;
|
||||
nsresult status;
|
||||
rv = aRequest->GetStatus(&status);
|
||||
nsresult rv = aRequest->GetStatus(&status);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(status)) {
|
||||
if (element)
|
||||
|
@ -332,7 +331,7 @@ NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnStartRequest(nsIRequest*
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext,
|
||||
nsresult aStatus)
|
||||
nsresult aStatus)
|
||||
{
|
||||
if (mNextListener) {
|
||||
return mNextListener->OnStopRequest(aRequest, aContext, aStatus);
|
||||
|
@ -341,8 +340,8 @@ NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnStopRequest(nsIRequest* a
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
|
||||
nsIInputStream* aStream, PRUint32 aOffset,
|
||||
PRUint32 aCount)
|
||||
nsIInputStream* aStream, PRUint32 aOffset,
|
||||
PRUint32 aCount)
|
||||
{
|
||||
if (!mNextListener) {
|
||||
NS_ERROR("Must have a chained listener; OnStartRequest should have canceled this request");
|
||||
|
@ -635,11 +634,10 @@ void nsHTMLMediaElement::SelectResource()
|
|||
// AddRemoveSelfReference, since it must still be held
|
||||
DispatchAsyncEvent(NS_LITERAL_STRING("loadstart"));
|
||||
|
||||
nsAutoString src;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
||||
// If we have a 'src' attribute, use that exclusively.
|
||||
nsAutoString src;
|
||||
if (GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NewURIFromString(src, getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
LOG(PR_LOG_DEBUG, ("%p Trying load from src=%s", this, NS_ConvertUTF16toUTF8(src).get()));
|
||||
|
@ -728,7 +726,6 @@ void nsHTMLMediaElement::LoadFromSourceChildren()
|
|||
NS_ASSERTION(mIsLoadingFromSourceChildren,
|
||||
"Must remember we're loading from source children");
|
||||
while (true) {
|
||||
nsresult rv;
|
||||
nsIContent* child = GetNextSource();
|
||||
if (!child) {
|
||||
// Exhausted candidates, wait for more candidates to be appended to
|
||||
|
@ -739,25 +736,24 @@ void nsHTMLMediaElement::LoadFromSourceChildren()
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsAutoString src,type;
|
||||
|
||||
// Must have src attribute.
|
||||
nsAutoString src;
|
||||
if (!child->GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
|
||||
DispatchAsyncSourceError(child);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we have a type attribute, it must be a supported type.
|
||||
if (child->HasAttr(kNameSpaceID_None, nsGkAtoms::type) &&
|
||||
child->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type) &&
|
||||
GetCanPlay(type) == CANPLAY_NO)
|
||||
{
|
||||
nsAutoString type;
|
||||
if (child->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type) &&
|
||||
GetCanPlay(type) == CANPLAY_NO) {
|
||||
DispatchAsyncSourceError(child);
|
||||
continue;
|
||||
}
|
||||
LOG(PR_LOG_DEBUG, ("%p Trying load from <source>=%s type=%s", this,
|
||||
NS_ConvertUTF16toUTF8(src).get(), NS_ConvertUTF16toUTF8(type).get()));
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NewURIFromString(src, getter_AddRefs(uri));
|
||||
if (!uri) {
|
||||
DispatchAsyncSourceError(child);
|
||||
|
@ -775,9 +771,9 @@ void nsHTMLMediaElement::LoadFromSourceChildren()
|
|||
return;
|
||||
}
|
||||
|
||||
rv = LoadResource(uri);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(LoadResource(uri))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we fail to load, loop back and try loading the next resource.
|
||||
DispatchAsyncSourceError(child);
|
||||
|
@ -892,15 +888,12 @@ void nsHTMLMediaElement::UpdatePreloadAction()
|
|||
ResumeLoad(PRELOAD_METADATA);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult nsHTMLMediaElement::LoadResource(nsIURI* aURI)
|
||||
{
|
||||
NS_ASSERTION(mDelayingLoadEvent,
|
||||
"Should delay load event (if in document) during load");
|
||||
nsresult rv;
|
||||
|
||||
// If a previous call to mozSetup() was made, kill that media stream
|
||||
// in order to use this new src instead.
|
||||
|
@ -915,17 +908,19 @@ nsresult nsHTMLMediaElement::LoadResource(nsIURI* aURI)
|
|||
}
|
||||
|
||||
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_MEDIA,
|
||||
aURI,
|
||||
NodePrincipal(),
|
||||
static_cast<nsGenericElement*>(this),
|
||||
EmptyCString(), // mime type
|
||||
nsnull, // extra
|
||||
&shouldLoad,
|
||||
nsContentUtils::GetContentPolicy(),
|
||||
nsContentUtils::GetSecurityManager());
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (NS_CP_REJECTED(shouldLoad)) return NS_ERROR_FAILURE;
|
||||
nsresult rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_MEDIA,
|
||||
aURI,
|
||||
NodePrincipal(),
|
||||
static_cast<nsGenericElement*>(this),
|
||||
EmptyCString(), // mime type
|
||||
nsnull, // extra
|
||||
&shouldLoad,
|
||||
nsContentUtils::GetContentPolicy(),
|
||||
nsContentUtils::GetSecurityManager());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_CP_REJECTED(shouldLoad)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = GetDocumentLoadGroup();
|
||||
|
||||
|
@ -1122,12 +1117,11 @@ NS_IMETHODIMP nsHTMLMediaElement::GetDuration(double *aDuration)
|
|||
/* readonly attribute nsIDOMHTMLTimeRanges seekable; */
|
||||
NS_IMETHODIMP nsHTMLMediaElement::GetSeekable(nsIDOMTimeRanges** aSeekable)
|
||||
{
|
||||
nsTimeRanges* ranges = new nsTimeRanges();
|
||||
NS_ADDREF(*aSeekable = ranges);
|
||||
|
||||
nsRefPtr<nsTimeRanges> ranges = new nsTimeRanges();
|
||||
if (mDecoder && mReadyState > nsIDOMHTMLMediaElement::HAVE_NOTHING) {
|
||||
mDecoder->GetSeekable(ranges);
|
||||
}
|
||||
ranges.forget(aSeekable);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1175,7 +1169,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetVolume(double *aVolume)
|
|||
|
||||
NS_IMETHODIMP nsHTMLMediaElement::SetVolume(double aVolume)
|
||||
{
|
||||
if (aVolume < 0.0f || aVolume > 1.0f)
|
||||
if (aVolume < 0.0 || aVolume > 1.0)
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
|
||||
if (aVolume == mVolume)
|
||||
|
@ -1346,14 +1340,17 @@ void nsHTMLMediaElement::StopSuspendingAfterFirstFrame()
|
|||
|
||||
void nsHTMLMediaElement::SetPlayedOrSeeked(bool aValue)
|
||||
{
|
||||
if (aValue == mHasPlayedOrSeeked)
|
||||
if (aValue == mHasPlayedOrSeeked) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHasPlayedOrSeeked = aValue;
|
||||
|
||||
// Force a reflow so that the poster frame hides or shows immediately.
|
||||
nsIFrame* frame = GetPrimaryFrame();
|
||||
if (!frame) return;
|
||||
if (!frame) {
|
||||
return;
|
||||
}
|
||||
frame->PresContext()->PresShell()->FrameNeedsReflow(frame,
|
||||
nsIPresShell::eTreeChange,
|
||||
NS_FRAME_IS_DIRTY);
|
||||
|
@ -1367,7 +1364,7 @@ NS_IMETHODIMP nsHTMLMediaElement::Play()
|
|||
if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
|
||||
nsresult rv = Load();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else if (mLoadIsSuspended) {
|
||||
} else if (mLoadIsSuspended) {
|
||||
ResumeLoad(PRELOAD_ENOUGH);
|
||||
} else if (mDecoder) {
|
||||
if (mDecoder->IsEnded()) {
|
||||
|
@ -1425,16 +1422,16 @@ bool nsHTMLMediaElement::ParseAttribute(PRInt32 aNamespaceID,
|
|||
};
|
||||
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (aAttribute == nsGkAtoms::loopstart
|
||||
|| aAttribute == nsGkAtoms::loopend
|
||||
|| aAttribute == nsGkAtoms::start
|
||||
|| aAttribute == nsGkAtoms::end) {
|
||||
if (aAttribute == nsGkAtoms::loopstart ||
|
||||
aAttribute == nsGkAtoms::loopend ||
|
||||
aAttribute == nsGkAtoms::start ||
|
||||
aAttribute == nsGkAtoms::end) {
|
||||
return aResult.ParseDoubleValue(aValue);
|
||||
}
|
||||
else if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
||||
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
||||
return true;
|
||||
}
|
||||
else if (aAttribute == nsGkAtoms::preload) {
|
||||
if (aAttribute == nsGkAtoms::preload) {
|
||||
return aResult.ParseEnumValue(aValue, kPreloadTable, false);
|
||||
}
|
||||
}
|
||||
|
@ -1449,7 +1446,7 @@ nsresult nsHTMLMediaElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|||
{
|
||||
nsresult rv =
|
||||
nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue,
|
||||
aNotify);
|
||||
aNotify);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::src) {
|
||||
|
@ -1536,12 +1533,16 @@ static bool IsRawEnabled()
|
|||
|
||||
static bool IsRawType(const nsACString& aType)
|
||||
{
|
||||
if (!IsRawEnabled())
|
||||
if (!IsRawEnabled()) {
|
||||
return false;
|
||||
for (PRUint32 i = 0; i < ArrayLength(gRawTypes); ++i) {
|
||||
if (aType.EqualsASCII(gRawTypes[i]))
|
||||
return true;
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < ArrayLength(gRawTypes); ++i) {
|
||||
if (aType.EqualsASCII(gRawTypes[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -1569,12 +1570,16 @@ nsHTMLMediaElement::IsOggEnabled()
|
|||
bool
|
||||
nsHTMLMediaElement::IsOggType(const nsACString& aType)
|
||||
{
|
||||
if (!IsOggEnabled())
|
||||
if (!IsOggEnabled()) {
|
||||
return false;
|
||||
for (PRUint32 i = 0; i < ArrayLength(gOggTypes); ++i) {
|
||||
if (aType.EqualsASCII(gOggTypes[i]))
|
||||
return true;
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < ArrayLength(gOggTypes); ++i) {
|
||||
if (aType.EqualsASCII(gOggTypes[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -1604,12 +1609,16 @@ nsHTMLMediaElement::IsWaveEnabled()
|
|||
bool
|
||||
nsHTMLMediaElement::IsWaveType(const nsACString& aType)
|
||||
{
|
||||
if (!IsWaveEnabled())
|
||||
if (!IsWaveEnabled()) {
|
||||
return false;
|
||||
for (PRUint32 i = 0; i < ArrayLength(gWaveTypes); ++i) {
|
||||
if (aType.EqualsASCII(gWaveTypes[i]))
|
||||
return true;
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < ArrayLength(gWaveTypes); ++i) {
|
||||
if (aType.EqualsASCII(gWaveTypes[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -1636,12 +1645,16 @@ nsHTMLMediaElement::IsWebMEnabled()
|
|||
bool
|
||||
nsHTMLMediaElement::IsWebMType(const nsACString& aType)
|
||||
{
|
||||
if (!IsWebMEnabled())
|
||||
if (!IsWebMEnabled()) {
|
||||
return false;
|
||||
for (PRUint32 i = 0; i < ArrayLength(gWebMTypes); ++i) {
|
||||
if (aType.EqualsASCII(gWebMTypes[i]))
|
||||
return true;
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < ArrayLength(gWebMTypes); ++i) {
|
||||
if (aType.EqualsASCII(gWebMTypes[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -1760,10 +1773,16 @@ NS_IMETHODIMP
|
|||
nsHTMLMediaElement::CanPlayType(const nsAString& aType, nsAString& aResult)
|
||||
{
|
||||
switch (GetCanPlay(aType)) {
|
||||
case CANPLAY_NO: aResult.AssignLiteral(""); break;
|
||||
case CANPLAY_YES: aResult.AssignLiteral("probably"); break;
|
||||
case CANPLAY_NO:
|
||||
aResult.Truncate();
|
||||
break;
|
||||
case CANPLAY_YES:
|
||||
aResult.AssignLiteral("probably");
|
||||
break;
|
||||
default:
|
||||
case CANPLAY_MAYBE: aResult.AssignLiteral("maybe"); break;
|
||||
case CANPLAY_MAYBE:
|
||||
aResult.AssignLiteral("maybe");
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1774,32 +1793,32 @@ nsHTMLMediaElement::CreateDecoder(const nsACString& aType)
|
|||
#ifdef MOZ_RAW
|
||||
if (IsRawType(aType)) {
|
||||
nsRefPtr<nsRawDecoder> decoder = new nsRawDecoder();
|
||||
if (decoder && decoder->Init(this)) {
|
||||
return decoder.forget().get();
|
||||
if (decoder->Init(this)) {
|
||||
return decoder.forget();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_OGG
|
||||
if (IsOggType(aType)) {
|
||||
nsRefPtr<nsOggDecoder> decoder = new nsOggDecoder();
|
||||
if (decoder && decoder->Init(this)) {
|
||||
return decoder.forget().get();
|
||||
if (decoder->Init(this)) {
|
||||
return decoder.forget();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_WAVE
|
||||
if (IsWaveType(aType)) {
|
||||
nsRefPtr<nsWaveDecoder> decoder = new nsWaveDecoder();
|
||||
if (decoder && decoder->Init(this)) {
|
||||
return decoder.forget().get();
|
||||
if (decoder->Init(this)) {
|
||||
return decoder.forget();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_WEBM
|
||||
if (IsWebMType(aType)) {
|
||||
nsRefPtr<nsWebMDecoder> decoder = new nsWebMDecoder();
|
||||
if (decoder && decoder->Init(this)) {
|
||||
return decoder.forget().get();
|
||||
if (decoder->Init(this)) {
|
||||
return decoder.forget();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1913,7 +1932,8 @@ nsresult nsHTMLMediaElement::NewURIFromString(const nsAutoString& aURISpec, nsIU
|
|||
nsCOMPtr<nsIDocument> doc = OwnerDoc();
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsresult rv = nsContentUtils::NewURIWithDocumentCharset(aURI,
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
|
||||
aURISpec,
|
||||
doc,
|
||||
baseURI);
|
||||
|
@ -1922,16 +1942,16 @@ nsresult nsHTMLMediaElement::NewURIFromString(const nsAutoString& aURISpec, nsIU
|
|||
bool equal;
|
||||
if (aURISpec.IsEmpty() &&
|
||||
doc->GetDocumentURI() &&
|
||||
NS_SUCCEEDED(doc->GetDocumentURI()->Equals(*aURI, &equal)) &&
|
||||
NS_SUCCEEDED(doc->GetDocumentURI()->Equals(uri, &equal)) &&
|
||||
equal) {
|
||||
// It's not possible for a media resource to be embedded in the current
|
||||
// document we extracted aURISpec from, so there's no point returning
|
||||
// the current document URI just to let the caller attempt and fail to
|
||||
// decode it.
|
||||
NS_RELEASE(*aURI);
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
|
||||
uri.forget(aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2485,11 +2505,11 @@ void nsHTMLMediaElement::NotifyAddedSource()
|
|||
|
||||
nsIContent* nsHTMLMediaElement::GetNextSource()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOMNode> thisDomNode = do_QueryObject(this);
|
||||
|
||||
mSourceLoadCandidate = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (!mSourcePointer) {
|
||||
// First time this has been run, create a selection to cover children.
|
||||
mSourcePointer = do_CreateInstance("@mozilla.org/content/range;1");
|
||||
|
@ -2518,14 +2538,13 @@ nsIContent* nsHTMLMediaElement::GetNextSource()
|
|||
return nsnull; // No more children.
|
||||
|
||||
// Advance the range to the next child.
|
||||
rv = mSourcePointer->SetStart(thisDomNode, startOffset+1);
|
||||
rv = mSourcePointer->SetStart(thisDomNode, startOffset + 1);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
nsIContent* child = GetChildAt(startOffset);
|
||||
|
||||
// If child is a <source> element, it is the next candidate.
|
||||
if (child && child->IsHTML(nsGkAtoms::source))
|
||||
{
|
||||
if (child && child->IsHTML(nsGkAtoms::source)) {
|
||||
mSourceLoadCandidate = child;
|
||||
return child;
|
||||
}
|
||||
|
@ -2534,7 +2553,8 @@ nsIContent* nsHTMLMediaElement::GetNextSource()
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
void nsHTMLMediaElement::ChangeDelayLoadStatus(bool aDelay) {
|
||||
void nsHTMLMediaElement::ChangeDelayLoadStatus(bool aDelay)
|
||||
{
|
||||
if (mDelayingLoadEvent == aDelay)
|
||||
return;
|
||||
|
||||
|
@ -2599,13 +2619,13 @@ nsHTMLMediaElement::CopyInnerTo(nsGenericElement* aDest) const
|
|||
|
||||
nsresult nsHTMLMediaElement::GetBuffered(nsIDOMTimeRanges** aBuffered)
|
||||
{
|
||||
nsTimeRanges* ranges = new nsTimeRanges();
|
||||
NS_ADDREF(*aBuffered = ranges);
|
||||
nsRefPtr<nsTimeRanges> ranges = new nsTimeRanges();
|
||||
if (mReadyState >= nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA && mDecoder) {
|
||||
// If GetBuffered fails we ignore the error result and just return the
|
||||
// time ranges we found up till the error.
|
||||
mDecoder->GetBuffered(ranges);
|
||||
}
|
||||
ranges.forget(aBuffered);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2620,7 +2640,7 @@ void nsHTMLMediaElement::SetRequestHeaders(nsIHttpChannel* aChannel)
|
|||
// So, disable the standard "Accept-Encoding: gzip,deflate" that we usually send.
|
||||
// See bug 614760.
|
||||
aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept-Encoding"),
|
||||
NS_LITERAL_CSTRING(""), false);
|
||||
EmptyCString(), false);
|
||||
|
||||
// Set the Referer header
|
||||
aChannel->SetReferrer(OwnerDoc()->GetDocumentURI());
|
||||
|
|
|
@ -150,7 +150,5 @@ nsHTMLMetaElement::CreateAndDispatchEvent(nsIDocument* aDoc,
|
|||
|
||||
nsRefPtr<nsPLDOMEvent> event = new nsPLDOMEvent(this, aEventName, true,
|
||||
true);
|
||||
if (event) {
|
||||
event->PostDOMEvent();
|
||||
}
|
||||
event->PostDOMEvent();
|
||||
}
|
||||
|
|
|
@ -173,9 +173,7 @@ NS_IMETHODIMP
|
|||
nsHTMLOutputElement::Reset()
|
||||
{
|
||||
mValueModeFlag = eModeDefault;
|
||||
nsresult rv = nsContentUtils::SetNodeTextContent(this, mDefaultValue,
|
||||
true);
|
||||
return rv;
|
||||
return nsContentUtils::SetNodeTextContent(this, mDefaultValue, true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -273,7 +273,7 @@ nsHTMLSelectElement::InsertOptionsIntoList(nsIContent* aOptions,
|
|||
// Actually select the options if the added options warrant it
|
||||
nsCOMPtr<nsIDOMNode> optionNode;
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> option;
|
||||
for (PRInt32 i=aListIndex;i<insertIndex;i++) {
|
||||
for (PRInt32 i = aListIndex; i < insertIndex; i++) {
|
||||
// Notify the frame that the option is added
|
||||
if (!didGetFrame || (selectFrame && !weakSelectFrame.IsAlive())) {
|
||||
selectFrame = GetSelectFrame();
|
||||
|
@ -326,7 +326,7 @@ nsHTMLSelectElement::RemoveOptionsFromList(nsIContent* aOptions,
|
|||
nsISelectControlFrame* selectFrame = GetSelectFrame();
|
||||
if (selectFrame) {
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
for (int i = aListIndex; i < aListIndex + numRemoved; ++i) {
|
||||
for (PRInt32 i = aListIndex; i < aListIndex + numRemoved; ++i) {
|
||||
selectFrame->RemoveOption(i);
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ nsHTMLSelectElement::InsertOptionsIntoListRecurse(nsIContent* aOptions,
|
|||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
nsresult rv = InsertOptionsIntoListRecurse(child,
|
||||
aInsertIndex, aDepth+1);
|
||||
aInsertIndex, aDepth + 1);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +438,6 @@ nsHTMLSelectElement::RemoveOptionsFromListRecurse(nsIContent* aOptions,
|
|||
for (nsIContent* child = aOptions->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
nsresult rv = RemoveOptionsFromListRecurse(child,
|
||||
aRemoveIndex,
|
||||
aNumRemoved,
|
||||
|
@ -765,19 +764,15 @@ nsHTMLSelectElement::GetLength(PRUint32* aLength)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLSelectElement::SetLength(PRUint32 aLength)
|
||||
{
|
||||
nsresult rv=NS_OK;
|
||||
|
||||
PRUint32 curlen;
|
||||
PRUint32 i;
|
||||
|
||||
rv = GetLength(&curlen);
|
||||
nsresult rv = GetLength(&curlen);
|
||||
if (NS_FAILED(rv)) {
|
||||
curlen = 0;
|
||||
}
|
||||
|
||||
if (curlen > aLength) { // Remove extra options
|
||||
for (i = curlen; i > aLength && NS_SUCCEEDED(rv); --i) {
|
||||
rv = Remove(i-1);
|
||||
for (PRUint32 i = curlen; i > aLength && NS_SUCCEEDED(rv); --i) {
|
||||
rv = Remove(i - 1);
|
||||
}
|
||||
} else if (aLength > curlen) {
|
||||
if (aLength > MAX_DYNAMIC_SELECT_LENGTH) {
|
||||
|
@ -804,7 +799,7 @@ nsHTMLSelectElement::SetLength(PRUint32 aLength)
|
|||
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(element));
|
||||
|
||||
for (i = curlen; i < aLength; i++) {
|
||||
for (PRUint32 i = curlen; i < aLength; i++) {
|
||||
nsCOMPtr<nsIDOMNode> tmpNode;
|
||||
|
||||
rv = AppendChild(node, getter_AddRefs(tmpNode));
|
||||
|
@ -892,7 +887,7 @@ nsHTMLSelectElement::OnOptionSelected(nsISelectControlFrame* aSelectFrame,
|
|||
mSelectedIndex = aIndex;
|
||||
SetSelectionChanged(true, aNotify);
|
||||
} else if (!aSelected && aIndex == mSelectedIndex) {
|
||||
FindSelectedIndex(aIndex+1, aNotify);
|
||||
FindSelectedIndex(aIndex + 1, aNotify);
|
||||
}
|
||||
|
||||
if (aChangeOptionState) {
|
||||
|
@ -922,7 +917,7 @@ nsHTMLSelectElement::FindSelectedIndex(PRInt32 aStartIndex, bool aNotify)
|
|||
SetSelectionChanged(true, aNotify);
|
||||
PRUint32 len;
|
||||
GetLength(&len);
|
||||
for (PRInt32 i=aStartIndex; i<(PRInt32)len; i++) {
|
||||
for (PRInt32 i = aStartIndex; i < PRInt32(len); i++) {
|
||||
if (IsOptionSelectedByIndex(i)) {
|
||||
mSelectedIndex = i;
|
||||
SetSelectionChanged(true, aNotify);
|
||||
|
@ -1070,7 +1065,7 @@ nsHTMLSelectElement::SetOptionsSelectedByIndex(PRInt32 aStartIndex,
|
|||
|| aStartIndex == -1)
|
||||
&& previousSelectedIndex != -1) {
|
||||
for (PRInt32 optIndex = previousSelectedIndex;
|
||||
optIndex < (PRInt32)numItems;
|
||||
optIndex < PRInt32(numItems);
|
||||
optIndex++) {
|
||||
if (optIndex < aStartIndex || optIndex > aEndIndex) {
|
||||
nsIDOMHTMLOptionElement *option = mOptions->ItemAsOption(optIndex);
|
||||
|
@ -1232,42 +1227,35 @@ nsHTMLSelectElement::GetValue(nsAString& aValue)
|
|||
}
|
||||
}
|
||||
|
||||
aValue.Truncate(0);
|
||||
aValue.Truncate();
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLSelectElement::SetValue(const nsAString& aValue)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRUint32 length;
|
||||
rv = GetLength(&length);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRUint32 i;
|
||||
for (i = 0; i < length; i++) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsresult rv = GetLength(&length);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = Item(i, getter_AddRefs(node));
|
||||
for (PRUint32 i = 0; i < length; i++) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
rv = Item(i, getter_AddRefs(node));
|
||||
if (NS_FAILED(rv) || !node) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && node) {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> option = do_QueryInterface(node);
|
||||
|
||||
if (option) {
|
||||
nsAutoString optionVal;
|
||||
|
||||
option->GetValue(optionVal);
|
||||
|
||||
if (optionVal.Equals(aValue)) {
|
||||
SetSelectedIndexInternal((PRInt32)i, true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> option = do_QueryInterface(node);
|
||||
if (!option) {
|
||||
continue;
|
||||
}
|
||||
nsAutoString optionVal;
|
||||
option->GetValue(optionVal);
|
||||
if (optionVal.Equals(aValue)) {
|
||||
SetSelectedIndexInternal(PRInt32(i), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1327,7 +1315,7 @@ nsHTMLSelectElement::SelectSomething(bool aNotify)
|
|||
|
||||
PRUint32 count;
|
||||
GetLength(&count);
|
||||
for (PRUint32 i=0; i<count; i++) {
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
bool disabled;
|
||||
nsresult rv = IsOptionDisabled(i, &disabled);
|
||||
|
||||
|
@ -1625,9 +1613,6 @@ NS_IMETHODIMP
|
|||
nsHTMLSelectElement::SaveState()
|
||||
{
|
||||
nsRefPtr<nsSelectState> state = new nsSelectState();
|
||||
if (!state) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PRUint32 len;
|
||||
GetLength(&len);
|
||||
|
@ -1697,7 +1682,7 @@ nsHTMLSelectElement::RestoreStateTo(nsSelectState* aNewSelected)
|
|||
SetOptionsSelectedByIndex(-1, -1, true, true, true, true, nsnull);
|
||||
|
||||
// Next set the proper ones
|
||||
for (PRInt32 i = 0; i < (PRInt32)len; i++) {
|
||||
for (PRInt32 i = 0; i < PRInt32(len); i++) {
|
||||
nsIDOMHTMLOptionElement *option = mOptions->ItemAsOption(i);
|
||||
if (option) {
|
||||
nsAutoString value;
|
||||
|
@ -1707,8 +1692,6 @@ nsHTMLSelectElement::RestoreStateTo(nsSelectState* aNewSelected)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//CheckSelectSomething();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1770,8 +1753,6 @@ static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID);
|
|||
NS_IMETHODIMP
|
||||
nsHTMLSelectElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Disabled elements don't submit
|
||||
if (IsDisabled()) {
|
||||
return NS_OK;
|
||||
|
@ -1796,13 +1777,13 @@ nsHTMLSelectElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
|||
nsCOMPtr<nsIFormProcessor> keyGenProcessor;
|
||||
if (GetAttr(kNameSpaceID_None, nsGkAtoms::_moz_type, mozType) &&
|
||||
mozType.EqualsLiteral("-mozilla-keygen")) {
|
||||
keyGenProcessor = do_GetService(kFormProcessorCID, &rv);
|
||||
keyGenProcessor = do_GetService(kFormProcessorCID);
|
||||
}
|
||||
|
||||
for (PRUint32 optIndex = 0; optIndex < len; optIndex++) {
|
||||
// Don't send disabled options
|
||||
bool disabled;
|
||||
rv = IsOptionDisabled(optIndex, &disabled);
|
||||
nsresult rv = IsOptionDisabled(optIndex, &disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1845,7 +1826,9 @@ nsHTMLSelectElement::GetHasOptGroups(bool* aHasGroups)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsHTMLSelectElement::DispatchContentReset() {
|
||||
void
|
||||
nsHTMLSelectElement::DispatchContentReset()
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = GetFormControlFrame(false);
|
||||
if (formControlFrame) {
|
||||
// Only dispatch content reset notification if this is a list control
|
||||
|
@ -1896,20 +1879,18 @@ nsHTMLSelectElement::IsValueMissing()
|
|||
}
|
||||
|
||||
PRUint32 length;
|
||||
nsIDOMHTMLOptionElement* option = nsnull;
|
||||
bool disabled;
|
||||
bool selected;
|
||||
|
||||
mOptions->GetLength(&length);
|
||||
|
||||
for (PRUint32 i=0; i<length; ++i) {
|
||||
option = mOptions->ItemAsOption(i);
|
||||
for (PRUint32 i = 0; i < length; ++i) {
|
||||
nsIDOMHTMLOptionElement* option = mOptions->ItemAsOption(i);
|
||||
bool selected;
|
||||
NS_ENSURE_SUCCESS(option->GetSelected(&selected), false);
|
||||
|
||||
if (!selected) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool disabled;
|
||||
IsOptionDisabled(i, &disabled);
|
||||
if (disabled) {
|
||||
continue;
|
||||
|
@ -1933,28 +1914,21 @@ nsHTMLSelectElement::UpdateValueMissingValidityState()
|
|||
|
||||
nsresult
|
||||
nsHTMLSelectElement::GetValidationMessage(nsAString& aValidationMessage,
|
||||
ValidityStateType aType)
|
||||
ValidityStateType aType)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
switch (aType)
|
||||
{
|
||||
case VALIDITY_STATE_VALUE_MISSING:
|
||||
{
|
||||
nsXPIDLString message;
|
||||
|
||||
rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
|
||||
"FormValidationSelectMissing",
|
||||
message);
|
||||
|
||||
aValidationMessage = message;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rv = nsIConstraintValidation::GetValidationMessage(aValidationMessage, aType);
|
||||
switch (aType) {
|
||||
case VALIDITY_STATE_VALUE_MISSING: {
|
||||
nsXPIDLString message;
|
||||
nsresult rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
|
||||
"FormValidationSelectMissing",
|
||||
message);
|
||||
aValidationMessage = message;
|
||||
return rv;
|
||||
}
|
||||
default: {
|
||||
return nsIConstraintValidation::GetValidationMessage(aValidationMessage, aType);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -2300,4 +2274,3 @@ nsHTMLSelectElement::SetSelectionChanged(bool aValue, bool aNotify)
|
|||
UpdateState(aNotify);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -382,8 +382,8 @@ nsHTMLSharedElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|||
nsIAtom* aPrefix, const nsAString& aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
|
||||
aValue, aNotify);
|
||||
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
|
||||
aValue, aNotify);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// If the href attribute of a <base> tag is changing, we may need to update
|
||||
|
|
|
@ -50,13 +50,6 @@
|
|||
#include "nsIDOMGetSVGDocument.h"
|
||||
#include "nsIDOMSVGDocument.h"
|
||||
|
||||
// XXX this is to get around conflicts with windows.h defines
|
||||
// introduced through jni.h
|
||||
#ifdef XP_WIN
|
||||
#undef GetClassName
|
||||
#undef GetObject
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
|
|
|
@ -170,36 +170,24 @@ NS_IMPL_ELEMENT_CLONE(nsHTMLStyleElement)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLStyleElement::GetDisabled(bool* aDisabled)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (GetStyleSheet()) {
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss(do_QueryInterface(GetStyleSheet()));
|
||||
|
||||
if (ss) {
|
||||
result = ss->GetDisabled(aDisabled);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss = do_QueryInterface(GetStyleSheet());
|
||||
if (!ss) {
|
||||
*aDisabled = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return result;
|
||||
return ss->GetDisabled(aDisabled);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLStyleElement::SetDisabled(bool aDisabled)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (GetStyleSheet()) {
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss(do_QueryInterface(GetStyleSheet()));
|
||||
|
||||
if (ss) {
|
||||
result = ss->SetDisabled(aDisabled);
|
||||
}
|
||||
nsCOMPtr<nsIDOMStyleSheet> ss = do_QueryInterface(GetStyleSheet());
|
||||
if (!ss) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return result;
|
||||
return ss->SetDisabled(aDisabled);
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLStyleElement, Media, media)
|
||||
|
@ -367,6 +355,4 @@ nsHTMLStyleElement::GetStyleSheetInfo(nsAString& aTitle,
|
|||
// If we get here we assume that we're loading a css file, so set the
|
||||
// type to 'text/css'
|
||||
aType.AssignLiteral("text/css");
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -88,10 +88,9 @@ public:
|
|||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
protected:
|
||||
// This does not return a nsresult since all we care about is if we
|
||||
// found the row element that this cell is in or not.
|
||||
void GetRow(nsIDOMHTMLTableRowElement** aRow);
|
||||
nsIContent * GetTable();
|
||||
nsHTMLTableElement* GetTable() const;
|
||||
|
||||
already_AddRefed<nsIDOMHTMLTableRowElement> GetRow() const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -127,40 +126,40 @@ NS_IMPL_ELEMENT_CLONE(nsHTMLTableCellElement)
|
|||
|
||||
|
||||
// protected method
|
||||
void
|
||||
nsHTMLTableCellElement::GetRow(nsIDOMHTMLTableRowElement** aRow)
|
||||
already_AddRefed<nsIDOMHTMLTableRowElement>
|
||||
nsHTMLTableCellElement::GetRow() const
|
||||
{
|
||||
*aRow = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> rowNode;
|
||||
GetParentNode(getter_AddRefs(rowNode));
|
||||
|
||||
if (rowNode) {
|
||||
CallQueryInterface(rowNode, aRow);
|
||||
}
|
||||
nsCOMPtr<nsIDOMHTMLTableRowElement> row = do_QueryInterface(GetParent());
|
||||
return row.forget();
|
||||
}
|
||||
|
||||
// protected method
|
||||
nsIContent*
|
||||
nsHTMLTableCellElement::GetTable()
|
||||
nsHTMLTableElement*
|
||||
nsHTMLTableCellElement::GetTable() const
|
||||
{
|
||||
nsIContent *result = nsnull;
|
||||
|
||||
nsIContent *parent = GetParent();
|
||||
if (parent) { // GetParent() should be a row
|
||||
nsIContent* section = parent->GetParent();
|
||||
if (section) {
|
||||
if (section->IsHTML() &&
|
||||
section->NodeInfo()->Equals(nsGkAtoms::table)) {
|
||||
// XHTML, without a row group
|
||||
result = section;
|
||||
} else {
|
||||
// we have a row group.
|
||||
result = section->GetParent();
|
||||
}
|
||||
}
|
||||
if (!parent) {
|
||||
return nsnull;
|
||||
}
|
||||
return result;
|
||||
|
||||
// parent should be a row.
|
||||
nsIContent* section = parent->GetParent();
|
||||
if (!section) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
if (section->IsHTML(nsGkAtoms::table)) {
|
||||
// XHTML, without a row group.
|
||||
return static_cast<nsHTMLTableElement*>(section);
|
||||
}
|
||||
|
||||
// We have a row group.
|
||||
nsIContent* result = section->GetParent();
|
||||
if (result && result->IsHTML(nsGkAtoms::table)) {
|
||||
return static_cast<nsHTMLTableElement*>(result);
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -168,10 +167,7 @@ nsHTMLTableCellElement::GetCellIndex(PRInt32* aCellIndex)
|
|||
{
|
||||
*aCellIndex = -1;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableRowElement> row;
|
||||
|
||||
GetRow(getter_AddRefs(row));
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableRowElement> row = GetRow();
|
||||
if (!row) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -187,16 +183,13 @@ nsHTMLTableCellElement::GetCellIndex(PRInt32* aCellIndex)
|
|||
PRUint32 numCells;
|
||||
cells->GetLength(&numCells);
|
||||
|
||||
bool found = false;
|
||||
PRUint32 i;
|
||||
|
||||
for (i = 0; (i < numCells) && !found; i++) {
|
||||
for (PRUint32 i = 0; i < numCells; i++) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
cells->Item(i, getter_AddRefs(node));
|
||||
|
||||
if (node.get() == static_cast<nsIDOMNode *>(this)) {
|
||||
*aCellIndex = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,13 +203,12 @@ nsHTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
|||
nsresult rv = nsGenericHTMLElement::WalkContentStyleRules(aRuleWalker);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIContent* node = GetTable();
|
||||
if (node && node->IsHTML(nsGkAtoms::table)) {
|
||||
nsHTMLTableElement* table = static_cast<nsHTMLTableElement*>(node);
|
||||
if (nsHTMLTableElement* table = GetTable()) {
|
||||
nsMappedAttributes* tableInheritedAttributes =
|
||||
table->GetAttributesMappedForCell();
|
||||
if (tableInheritedAttributes)
|
||||
if (tableInheritedAttributes) {
|
||||
aRuleWalker->Forward(tableInheritedAttributes);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -242,10 +234,7 @@ nsHTMLTableCellElement::GetAlign(nsAString& aValue)
|
|||
{
|
||||
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::align, aValue)) {
|
||||
// There's no align attribute, ask the row for the alignment.
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableRowElement> row;
|
||||
GetRow(getter_AddRefs(row));
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableRowElement> row = GetRow();
|
||||
if (row) {
|
||||
return row->GetAlign(aValue);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ protected:
|
|||
TableRowsCollection::TableRowsCollection(nsHTMLTableElement *aParent)
|
||||
: mParent(aParent)
|
||||
, mOrphanRows(new nsContentList(mParent,
|
||||
mParent->NodeInfo()->NamespaceID(),
|
||||
kNameSpaceID_XHTML,
|
||||
nsGkAtoms::tr,
|
||||
nsGkAtoms::tr,
|
||||
false))
|
||||
|
@ -383,27 +383,23 @@ NS_IMPL_STRING_ATTR(nsHTMLTableElement, Summary, summary)
|
|||
NS_IMPL_STRING_ATTR(nsHTMLTableElement, Width, width)
|
||||
|
||||
|
||||
already_AddRefed<nsIDOMHTMLTableCaptionElement>
|
||||
nsHTMLTableElement::GetCaption()
|
||||
{
|
||||
for (nsIContent* cur = nsINode::GetFirstChild(); cur; cur = cur->GetNextSibling()) {
|
||||
nsCOMPtr<nsIDOMHTMLTableCaptionElement> caption = do_QueryInterface(cur);
|
||||
if (caption) {
|
||||
return caption.forget();
|
||||
}
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableElement::GetCaption(nsIDOMHTMLTableCaptionElement** aValue)
|
||||
{
|
||||
*aValue = nsnull;
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
GetFirstChild(getter_AddRefs(child));
|
||||
|
||||
while (child) {
|
||||
nsCOMPtr<nsIDOMHTMLTableCaptionElement> caption(do_QueryInterface(child));
|
||||
|
||||
if (caption) {
|
||||
*aValue = caption;
|
||||
NS_ADDREF(*aValue);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
nsIDOMNode *temp = child.get();
|
||||
temp->GetNextSibling(getter_AddRefs(child));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableCaptionElement> caption = GetCaption();
|
||||
caption.forget(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -425,22 +421,14 @@ nsHTMLTableElement::SetCaption(nsIDOMHTMLTableCaptionElement* aValue)
|
|||
already_AddRefed<nsIDOMHTMLTableSectionElement>
|
||||
nsHTMLTableElement::GetSection(nsIAtom *aTag)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section;
|
||||
|
||||
for (nsIContent* child = nsINode::GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
|
||||
section = do_QueryInterface(child);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section = do_QueryInterface(child);
|
||||
if (section && child->NodeInfo()->Equals(aTag)) {
|
||||
nsIDOMHTMLTableSectionElement *result = section;
|
||||
NS_ADDREF(result);
|
||||
|
||||
return result;
|
||||
return section.forget();
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
@ -536,7 +524,7 @@ nsHTMLTableElement::TBodies()
|
|||
if (!mTBodies) {
|
||||
// Not using NS_GetContentList because this should not be cached
|
||||
mTBodies = new nsContentList(this,
|
||||
mNodeInfo->NamespaceID(),
|
||||
kNameSpaceID_XHTML,
|
||||
nsGkAtoms::tbody,
|
||||
nsGkAtoms::tbody,
|
||||
false);
|
||||
|
@ -549,41 +537,34 @@ NS_IMETHODIMP
|
|||
nsHTMLTableElement::CreateTHead(nsIDOMHTMLElement** aValue)
|
||||
{
|
||||
*aValue = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> head;
|
||||
|
||||
GetTHead(getter_AddRefs(head));
|
||||
|
||||
if (head) { // return the existing thead
|
||||
CallQueryInterface(head, aValue);
|
||||
|
||||
NS_ASSERTION(*aValue, "head must be a DOMHTMLElement");
|
||||
}
|
||||
else
|
||||
{ // create a new head rowgroup
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
|
||||
nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::thead,
|
||||
getter_AddRefs(nodeInfo));
|
||||
|
||||
nsCOMPtr<nsIContent> newHead = NS_NewHTMLTableSectionElement(nodeInfo.forget());
|
||||
|
||||
if (newHead) {
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
|
||||
rv = GetFirstChild(getter_AddRefs(child));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
CallQueryInterface(newHead, aValue);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> resultChild;
|
||||
rv = InsertBefore(*aValue, child, getter_AddRefs(resultChild));
|
||||
}
|
||||
nsRefPtr<nsIDOMHTMLTableSectionElement> head = GetTHead();
|
||||
if (head) {
|
||||
// return the existing thead
|
||||
head.forget(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::thead,
|
||||
getter_AddRefs(nodeInfo));
|
||||
|
||||
nsCOMPtr<nsIContent> newHead =
|
||||
NS_NewHTMLTableSectionElement(nodeInfo.forget());
|
||||
|
||||
if (!newHead) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
nsresult rv = GetFirstChild(getter_AddRefs(child));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLElement> newHeadAsDOMElement = do_QueryInterface(newHead);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> resultChild;
|
||||
InsertBefore(newHeadAsDOMElement, child, getter_AddRefs(resultChild));
|
||||
newHeadAsDOMElement.forget(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -606,30 +587,26 @@ NS_IMETHODIMP
|
|||
nsHTMLTableElement::CreateTFoot(nsIDOMHTMLElement** aValue)
|
||||
{
|
||||
*aValue = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> foot;
|
||||
|
||||
GetTFoot(getter_AddRefs(foot));
|
||||
|
||||
if (foot) { // return the existing tfoot
|
||||
CallQueryInterface(foot, aValue);
|
||||
|
||||
NS_ASSERTION(*aValue, "foot must be a DOMHTMLElement");
|
||||
nsRefPtr<nsIDOMHTMLTableSectionElement> foot = GetTFoot();
|
||||
if (foot) {
|
||||
// return the existing tfoot
|
||||
foot.forget(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
{ // create a new foot rowgroup
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tfoot,
|
||||
getter_AddRefs(nodeInfo));
|
||||
// create a new foot rowgroup
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tfoot,
|
||||
getter_AddRefs(nodeInfo));
|
||||
|
||||
nsCOMPtr<nsIContent> newFoot = NS_NewHTMLTableSectionElement(nodeInfo.forget());
|
||||
nsCOMPtr<nsIContent> newFoot = NS_NewHTMLTableSectionElement(nodeInfo.forget());
|
||||
|
||||
if (newFoot) {
|
||||
rv = AppendChildTo(newFoot, true);
|
||||
CallQueryInterface(newFoot, aValue);
|
||||
}
|
||||
if (!newFoot) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
AppendChildTo(newFoot, true);
|
||||
nsCOMPtr<nsIDOMHTMLElement> newFootAsDOMElement = do_QueryInterface(newFoot);
|
||||
newFootAsDOMElement.forget(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -652,30 +629,28 @@ NS_IMETHODIMP
|
|||
nsHTMLTableElement::CreateCaption(nsIDOMHTMLElement** aValue)
|
||||
{
|
||||
*aValue = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOMHTMLTableCaptionElement> caption;
|
||||
|
||||
GetCaption(getter_AddRefs(caption));
|
||||
|
||||
if (caption) { // return the existing thead
|
||||
CallQueryInterface(caption, aValue);
|
||||
|
||||
NS_ASSERTION(*aValue, "caption must be a DOMHTMLElement");
|
||||
}
|
||||
else
|
||||
{ // create a new head rowgroup
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::caption,
|
||||
getter_AddRefs(nodeInfo));
|
||||
|
||||
nsCOMPtr<nsIContent> newCaption = NS_NewHTMLTableCaptionElement(nodeInfo.forget());
|
||||
|
||||
if (newCaption) {
|
||||
rv = AppendChildTo(newCaption, true);
|
||||
CallQueryInterface(newCaption, aValue);
|
||||
}
|
||||
if (nsRefPtr<nsIDOMHTMLTableCaptionElement> caption = GetCaption()) {
|
||||
// return the existing caption
|
||||
caption.forget(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// create a new head rowgroup
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::caption,
|
||||
getter_AddRefs(nodeInfo));
|
||||
|
||||
nsCOMPtr<nsIContent> newCaption = NS_NewHTMLTableCaptionElement(nodeInfo.forget());
|
||||
|
||||
if (!newCaption) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
AppendChildTo(newCaption, true);
|
||||
nsCOMPtr<nsIDOMHTMLElement> captionAsDOMElement =
|
||||
do_QueryInterface(newCaption);
|
||||
captionAsDOMElement.forget(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -710,8 +685,6 @@ nsHTMLTableElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue)
|
|||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> rows;
|
||||
GetRows(getter_AddRefs(rows));
|
||||
|
||||
|
@ -725,6 +698,7 @@ nsHTMLTableElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue)
|
|||
// use local variable refIndex so we can remember original aIndex
|
||||
PRUint32 refIndex = (PRUint32)aIndex;
|
||||
|
||||
nsresult rv;
|
||||
if (rowCount > 0) {
|
||||
if (refIndex == rowCount || aIndex == -1) {
|
||||
// we set refIndex to the last row so we can get the last row's
|
||||
|
@ -766,19 +740,17 @@ nsHTMLTableElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue)
|
|||
CallQueryInterface(retChild, aValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // the row count was 0, so
|
||||
} else {
|
||||
// the row count was 0, so
|
||||
// find the first row group and insert there as first child
|
||||
nsCOMPtr<nsIDOMNode> rowGroup;
|
||||
|
||||
PRInt32 namespaceID = mNodeInfo->NamespaceID();
|
||||
for (nsIContent* child = nsINode::GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
nsINodeInfo *childInfo = child->NodeInfo();
|
||||
nsIAtom *localName = childInfo->NameAtom();
|
||||
if (childInfo->NamespaceID() == namespaceID &&
|
||||
if (childInfo->NamespaceID() == kNameSpaceID_XHTML &&
|
||||
(localName == nsGkAtoms::thead ||
|
||||
localName == nsGkAtoms::tbody ||
|
||||
localName == nsGkAtoms::tfoot)) {
|
||||
|
|
|
@ -100,6 +100,7 @@ public:
|
|||
already_AddRefed<nsIDOMHTMLTableSectionElement> GetTFoot() {
|
||||
return GetSection(nsGkAtoms::tfoot);
|
||||
}
|
||||
already_AddRefed<nsIDOMHTMLTableCaptionElement> GetCaption();
|
||||
nsContentList* TBodies();
|
||||
protected:
|
||||
already_AddRefed<nsIDOMHTMLTableSectionElement> GetSection(nsIAtom *aTag);
|
||||
|
|
|
@ -134,15 +134,10 @@ nsresult
|
|||
nsHTMLTableRowElement::GetSection(nsIDOMHTMLTableSectionElement** aSection)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSection);
|
||||
*aSection = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> sectionNode;
|
||||
nsresult rv = GetParentNode(getter_AddRefs(sectionNode));
|
||||
if (NS_SUCCEEDED(rv) && sectionNode) {
|
||||
rv = CallQueryInterface(sectionNode, aSection);
|
||||
}
|
||||
|
||||
return rv;
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section =
|
||||
do_QueryInterface(GetParent());
|
||||
section.forget(aSection);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// protected method
|
||||
|
@ -152,25 +147,25 @@ nsHTMLTableRowElement::GetTable(nsIDOMHTMLTableElement** aTable)
|
|||
NS_ENSURE_ARG_POINTER(aTable);
|
||||
*aTable = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> sectionNode;
|
||||
nsresult rv = GetParentNode(getter_AddRefs(sectionNode));
|
||||
if (!sectionNode) {
|
||||
return rv;
|
||||
nsIContent* parent = GetParent();
|
||||
if (!parent) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We may not be in a section
|
||||
rv = CallQueryInterface(sectionNode, aTable);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return rv;
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table = do_QueryInterface(parent);
|
||||
if (table) {
|
||||
table.forget(aTable);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> tableNode;
|
||||
rv = sectionNode->GetParentNode(getter_AddRefs(tableNode));
|
||||
if (!tableNode) {
|
||||
return rv;
|
||||
parent = parent->GetParent();
|
||||
if (!parent) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(tableNode, aTable);
|
||||
table = do_QueryInterface(parent);
|
||||
table.forget(aTable);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -178,62 +173,46 @@ nsHTMLTableRowElement::GetRowIndex(PRInt32* aValue)
|
|||
{
|
||||
*aValue = -1;
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table;
|
||||
|
||||
nsresult result = GetTable(getter_AddRefs(table));
|
||||
|
||||
if (NS_SUCCEEDED(result) && table) {
|
||||
nsCOMPtr<nsIDOMHTMLCollection> rows;
|
||||
|
||||
table->GetRows(getter_AddRefs(rows));
|
||||
|
||||
PRUint32 numRows;
|
||||
rows->GetLength(&numRows);
|
||||
|
||||
bool found = false;
|
||||
|
||||
for (PRUint32 i = 0; (i < numRows) && !found; i++) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
|
||||
rows->Item(i, getter_AddRefs(node));
|
||||
|
||||
if (node.get() == static_cast<nsIDOMNode *>(this)) {
|
||||
*aValue = i;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
nsresult rv = GetTable(getter_AddRefs(table));
|
||||
if (NS_FAILED(rv) || !table) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return result;
|
||||
nsCOMPtr<nsIDOMHTMLCollection> rows;
|
||||
table->GetRows(getter_AddRefs(rows));
|
||||
|
||||
PRUint32 numRows;
|
||||
rows->GetLength(&numRows);
|
||||
|
||||
for (PRUint32 i = 0; i < numRows; i++) {
|
||||
if (rows->GetNodeAt(i) == static_cast<nsIContent*>(this)) {
|
||||
*aValue = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableRowElement::GetSectionRowIndex(PRInt32* aValue)
|
||||
{
|
||||
*aValue = -1;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section;
|
||||
nsresult rv = GetSection(getter_AddRefs(section));
|
||||
if (NS_FAILED(rv) || !section) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult result = GetSection(getter_AddRefs(section));
|
||||
nsCOMPtr<nsIDOMHTMLCollection> rows;
|
||||
section->GetRows(getter_AddRefs(rows));
|
||||
|
||||
if (NS_SUCCEEDED(result) && section) {
|
||||
nsCOMPtr<nsIDOMHTMLCollection> rows;
|
||||
|
||||
section->GetRows(getter_AddRefs(rows));
|
||||
|
||||
bool found = false;
|
||||
PRUint32 numRows;
|
||||
|
||||
rows->GetLength(&numRows);
|
||||
|
||||
for (PRUint32 i = 0; (i < numRows) && !found; i++) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
rows->Item(i, getter_AddRefs(node));
|
||||
|
||||
if (node.get() == static_cast<nsIDOMNode *>(this)) {
|
||||
*aValue = i;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
PRUint32 numRows;
|
||||
rows->GetLength(&numRows);
|
||||
for (PRUint32 i = 0; i < numRows; i++) {
|
||||
if (rows->GetNodeAt(i) == static_cast<nsIContent*>(this)) {
|
||||
*aValue = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -261,8 +240,6 @@ nsHTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue)
|
|||
nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
false);
|
||||
|
||||
NS_ENSURE_TRUE(mCells, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
NS_ADDREF(*aValue = mCells);
|
||||
|
@ -470,4 +447,3 @@ nsHTMLTableRowElement::GetAttributeMappingFunction() const
|
|||
{
|
||||
return &MapAttributesIntoRule;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,16 +135,12 @@ NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, ChOff, charoff)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue)
|
||||
{
|
||||
*aValue = nsnull;
|
||||
|
||||
if (!mRows) {
|
||||
mRows = new nsContentList(this,
|
||||
mNodeInfo->NamespaceID(),
|
||||
nsGkAtoms::tr,
|
||||
nsGkAtoms::tr,
|
||||
false);
|
||||
|
||||
NS_ENSURE_TRUE(mRows, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
NS_ADDREF(*aValue = mRows);
|
||||
|
|
|
@ -1035,8 +1035,6 @@ nsHTMLTextAreaElement::Reset()
|
|||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Disabled elements don't submit
|
||||
if (IsDisabled()) {
|
||||
return NS_OK;
|
||||
|
@ -1060,9 +1058,7 @@ nsHTMLTextAreaElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
|||
//
|
||||
// Submit
|
||||
//
|
||||
rv = aFormSubmission->AddNameValuePair(name, value);
|
||||
|
||||
return rv;
|
||||
return aFormSubmission->AddNameValuePair(name, value);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1084,8 +1080,8 @@ nsHTMLTextAreaElement::SaveState()
|
|||
nsLinebreakConverter::eLinebreakContent);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Converting linebreaks failed!");
|
||||
|
||||
nsCOMPtr<nsISupportsString> pState
|
||||
(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
|
||||
nsCOMPtr<nsISupportsString> pState =
|
||||
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID);
|
||||
if (!pState) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1307,7 +1303,7 @@ nsHTMLTextAreaElement::CopyInnerTo(nsGenericElement* aDest) const
|
|||
|
||||
if (aDest->OwnerDoc()->IsStaticDocument()) {
|
||||
nsAutoString value;
|
||||
const_cast<nsHTMLTextAreaElement*>(this)->GetValue(value);
|
||||
GetValueInternal(value, true);
|
||||
static_cast<nsHTMLTextAreaElement*>(aDest)->SetValue(value);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -1567,4 +1563,3 @@ nsHTMLTextAreaElement::FieldSetDisabledChanged(bool aNotify)
|
|||
|
||||
nsGenericHTMLFormElement::FieldSetDisabledChanged(aNotify);
|
||||
}
|
||||
|
||||
|
|
|
@ -165,22 +165,22 @@ nsHTMLVideoElement::GetAttributeMappingFunction() const
|
|||
|
||||
nsresult nsHTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel)
|
||||
{
|
||||
nsCAutoString value(
|
||||
nsCAutoString value(
|
||||
#ifdef MOZ_WEBM
|
||||
"video/webm,"
|
||||
"video/webm,"
|
||||
#endif
|
||||
#ifdef MOZ_OGG
|
||||
"video/ogg,"
|
||||
"video/ogg,"
|
||||
#endif
|
||||
"video/*;q=0.9,"
|
||||
"video/*;q=0.9,"
|
||||
#ifdef MOZ_OGG
|
||||
"application/ogg;q=0.7,"
|
||||
"application/ogg;q=0.7,"
|
||||
#endif
|
||||
"audio/*;q=0.6,*/*;q=0.5");
|
||||
"audio/*;q=0.6,*/*;q=0.5");
|
||||
|
||||
return aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
|
||||
value,
|
||||
false);
|
||||
return aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
|
||||
value,
|
||||
false);
|
||||
}
|
||||
|
||||
NS_IMPL_URI_ATTR(nsHTMLVideoElement, Poster, poster)
|
||||
|
|
Загрузка…
Ссылка в новой задаче