Пример #1
0
NS_IMETHODIMP
nsLocation::Replace(const nsAString& aUrl)
{
  nsresult rv = NS_OK;

  // Get JSContext from stack.
  nsCOMPtr<nsIJSContextStack>
  stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));

  if (stack) {
    JSContext *cx;

    rv = GetContextFromStack(stack, &cx);
    NS_ENSURE_SUCCESS(rv, rv);
    if (cx) {
      return SetHrefWithContext(cx, aUrl, PR_TRUE);
    }
  }

  nsAutoString oldHref;

  rv = GetHref(oldHref);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIURI> oldUri;

  rv = NS_NewURI(getter_AddRefs(oldUri), oldHref);
  NS_ENSURE_SUCCESS(rv, rv);

  return SetHrefWithBase(aUrl, oldUri, PR_TRUE);
}
Пример #2
0
//**********************************************************************************
// SetScreenCaptureAttachment
//**********************************************************************************
int SetScreenCaptureAttachment(struct soap* soap,
							   BYTE* data,
							   int dataSize,
                               BYTE command,
							   char* mimeType,
                               struct ns1__captureScreenResponse &r)
{
	// alloc soap memory for attachment
	char* soapAttachment = (char*)soap_malloc(soap, dataSize );
	memcpy( soapAttachment, data, dataSize );

	// get & set href for attachment
	char href[MAX_HREF_LEN];
	GetHref(href, command);
	r._returnAttachment.href = (char*)soap_malloc(soap, strlen(href)+1 );
	strcpy( r._returnAttachment.href, href );

	// default mimetype is bmp
	if ( !( mimeType ? strlen( mimeType ) : 0 ) )
        mimeType = "image/bmp";

	// set mimetype
	r._returnAttachment.mimeType = (char*)soap_malloc(soap, strlen(mimeType)+1 );
	strcpy( r._returnAttachment.mimeType, mimeType );

	// set the attahcment
	soap_set_dime(soap);
	return soap_set_dime_attachment(soap, soapAttachment, dataSize,
	                                mimeType, href, 0, NULL);
}
Пример #3
0
void
Location::Assign(const nsAString& aUrl,
                 nsIPrincipal& aSubjectPrincipal,
                 ErrorResult& aRv)
{
  if (!CallerSubsumes(&aSubjectPrincipal)) {
    aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
    return;
  }

  if (JSContext *cx = nsContentUtils::GetCurrentJSContext()) {
    aRv = SetHrefWithContext(cx, aUrl, false);
    return;
  }

  nsAutoString oldHref;
  aRv = GetHref(oldHref);
  if (NS_WARN_IF(aRv.Failed())) {
    return;
  }

  nsCOMPtr<nsIURI> oldUri;
  aRv = NS_NewURI(getter_AddRefs(oldUri), oldHref);
  if (NS_WARN_IF(aRv.Failed())) {
    return;
  }

  if (oldUri) {
    aRv = SetHrefWithBase(aUrl, oldUri, false);
  }
}
Пример #4
0
void
Location::Replace(const nsAString& aUrl,
                  nsIPrincipal& aSubjectPrincipal,
                  ErrorResult& aRv)
{
  if (JSContext *cx = nsContentUtils::GetCurrentJSContext()) {
    aRv = SetHrefWithContext(cx, aUrl, true);
    return;
  }

  nsAutoString oldHref;
  aRv = GetHref(oldHref);
  if (NS_WARN_IF(aRv.Failed())) {
    return;
  }

  nsCOMPtr<nsIURI> oldUri;

  aRv = NS_NewURI(getter_AddRefs(oldUri), oldHref);
  if (NS_WARN_IF(aRv.Failed())) {
    return;
  }

  aRv = SetHrefWithBase(aUrl, oldUri, true);
}
Пример #5
0
void
Location::SetHref(const nsAString& aHref,
                  ErrorResult& aRv)
{
  JSContext *cx = nsContentUtils::GetCurrentJSContext();
  if (cx) {
    aRv = SetHrefWithContext(cx, aHref, false);
    return;
  }

  nsAutoString oldHref;
  aRv = GetHref(oldHref);
  if (NS_WARN_IF(aRv.Failed())) {
    return;
  }

  nsCOMPtr<nsIURI> oldUri;
  aRv = NS_NewURI(getter_AddRefs(oldUri), oldHref);
  if (NS_WARN_IF(aRv.Failed())) {
    return;
  }

  aRv = SetHrefWithBase(aHref, oldUri, false);
  if (NS_WARN_IF(aRv.Failed())) {
    return;
  }
}
NS_IMETHODIMP
Location::SetHref(const nsAString& aHref)
{
  nsAutoString oldHref;
  nsresult rv = NS_OK;

  JSContext *cx = nsContentUtils::GetCurrentJSContext();
  if (cx) {
    rv = SetHrefWithContext(cx, aHref, false);
  } else {
    rv = GetHref(oldHref);

    if (NS_SUCCEEDED(rv)) {
      nsCOMPtr<nsIURI> oldUri;

      rv = NS_NewURI(getter_AddRefs(oldUri), oldHref);

      if (oldUri) {
        rv = SetHrefWithBase(aHref, oldUri, false);
      }
    }
  }

  return rv;
}
Пример #7
0
NS_IMETHODIMP
nsLocation::Assign(const nsAString& aUrl)
{
  nsAutoString oldHref;
  nsresult result = NS_OK;

  result = GetHref(oldHref);

  if (NS_SUCCEEDED(result)) {
    nsCOMPtr<nsIURI> oldUri;

    result = NS_NewURI(getter_AddRefs(oldUri), oldHref);

    if (oldUri) {
      result = SetHrefWithBase(aUrl, oldUri, PR_FALSE);
    }
  }

  return result;
}
NS_IMETHODIMP
Location::Replace(const nsAString& aUrl)
{
  nsresult rv = NS_OK;
  if (JSContext *cx = nsContentUtils::GetCurrentJSContext()) {
    return SetHrefWithContext(cx, aUrl, true);
  }

  nsAutoString oldHref;

  rv = GetHref(oldHref);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIURI> oldUri;

  rv = NS_NewURI(getter_AddRefs(oldUri), oldHref);
  NS_ENSURE_SUCCESS(rv, rv);

  return SetHrefWithBase(aUrl, oldUri, true);
}
Пример #9
0
//**********************************************************************************
// SetDeltaScreenCaptureAttachment
//**********************************************************************************
int SetDeltaScreenCaptureAttachment(struct soap* soap,
							        BYTE* data,
							        int dataSize,
                                    BYTE command,
							        char* mimeType,
                                    struct ns1__captureDeltaScreenResponse &r)
{
	// Set rectangle
	r._returnDeltaAttachment.rect.topLeftX     = *(WORD*)data; data+=2;
	r._returnDeltaAttachment.rect.topLeftY     = *(WORD*)data; data+=2;
	r._returnDeltaAttachment.rect.bottomRightX = *(WORD*)data; data+=2;
	r._returnDeltaAttachment.rect.bottomRightY = *(WORD*)data; data+=2;
	dataSize -= 2*4;

	// No attachment?
	if ( dataSize == 0 )
		return SOAP_OK;

	// alloc soap memory for attachment
	char* soapAttachment = (char*)soap_malloc(soap, dataSize );
	memcpy( soapAttachment, data, dataSize );

	// get & set href for attachment
	char href[MAX_HREF_LEN];
	GetHref(href, command);
	r._returnDeltaAttachment.href = (char*)soap_malloc(soap, strlen(href)+1 );
	strcpy( r._returnDeltaAttachment.href, href );

	// default mimetype is bmp
	if ( !( mimeType ? strlen( mimeType ) : 0 ) )
        mimeType = "image/bmp";

	// set mimetype
	r._returnDeltaAttachment.mimeType = (char*)soap_malloc(soap, strlen(mimeType)+1 );
	strcpy( r._returnDeltaAttachment.mimeType, mimeType );

	// set the attahcment
	soap_set_dime(soap);
	return soap_set_dime_attachment(soap, soapAttachment, dataSize,
	                                mimeType, href, 0, NULL);
}
Пример #10
0
NS_IMETHODIMP
nsLocation::Assign(const nsAString& aUrl)
{
  if (!CallerSubsumes())
    return NS_ERROR_DOM_SECURITY_ERR;

  nsAutoString oldHref;
  nsresult result = NS_OK;

  result = GetHref(oldHref);

  if (NS_SUCCEEDED(result)) {
    nsCOMPtr<nsIURI> oldUri;

    result = NS_NewURI(getter_AddRefs(oldUri), oldHref);

    if (oldUri) {
      result = SetHrefWithBase(aUrl, oldUri, false);
    }
  }

  return result;
}
Пример #11
0
NS_IMETHODIMP
nsLocation::SetHref(const nsAString& aHref)
{
  nsAutoString oldHref;
  nsresult rv = NS_OK;

  // Get JSContext from stack.
  nsCOMPtr<nsIJSContextStack>
    stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv));

  if (NS_FAILED(rv))
    return NS_ERROR_FAILURE;

  JSContext *cx;

  if (NS_FAILED(GetContextFromStack(stack, &cx)))
    return NS_ERROR_FAILURE;

  if (cx) {
    rv = SetHrefWithContext(cx, aHref, PR_FALSE);
  } else {
    rv = GetHref(oldHref);

    if (NS_SUCCEEDED(rv)) {
      nsCOMPtr<nsIURI> oldUri;

      rv = NS_NewURI(getter_AddRefs(oldUri), oldHref);

      if (oldUri) {
        rv = SetHrefWithBase(aHref, oldUri, PR_FALSE);
      }
    }
  }

  return rv;
}
Пример #12
0
nsresult
HTMLAnchorElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
                           nsIAtom* aPrefix, const nsAString& aValue,
                           bool aNotify)
{
  bool reset = false;
  if (aName == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
    // If we do not have a cached URI, we have some value here so we must reset
    // our link state after calling the parent.
    if (!Link::HasCachedURI()) {
      reset = true;
    }
    // However, if we have a cached URI, we'll want to see if the value changed.
    else {
      nsAutoString val;
      GetHref(val);
      if (!val.Equals(aValue)) {
        reset = true;
      }
    }
  }

  nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
                                              aValue, aNotify);

  // The ordering of the parent class's SetAttr call and Link::ResetLinkState
  // is important here!  The attribute is not set until SetAttr returns, and
  // we will need the updated attribute value because notifying the document
  // that content states have changed will call IntrinsicState, which will try
  // to get updated information about the visitedness from Link.
  if (reset) {
    Link::ResetLinkState(!!aNotify, true);
  }

  return rv;
}
Пример #13
0
NS_IMETHODIMP
Location::Assign(const nsAString& aUrl)
{
  if (JSContext *cx = nsContentUtils::GetCurrentJSContext()) {
    return SetHrefWithContext(cx, aUrl, false);
  }

  nsAutoString oldHref;
  nsresult result = NS_OK;

  result = GetHref(oldHref);

  if (NS_SUCCEEDED(result)) {
    nsCOMPtr<nsIURI> oldUri;

    result = NS_NewURI(getter_AddRefs(oldUri), oldHref);

    if (oldUri) {
      result = SetHrefWithBase(aUrl, oldUri, false);
    }
  }

  return result;
}
Пример #14
0
void HTMLAreaElement::ToString(nsAString& aSource) { GetHref(aSource); }
Пример #15
0
NS_IMETHODIMP
Location::ToString(nsAString& aReturn)
{
  return GetHref(aReturn);
}
NS_IMETHODIMP
nsLocation::SetHref(const nsAString& aHref)
{
  nsAutoString oldHref;
  nsresult rv = NS_OK;

  JSContext *cx = nsContentUtils::GetCurrentJSContext();

  // According to HTML5 spec, |location.href = ...| must act as if
  // it were |location.replace(...)| before the page load finishes.
  //
  // http://www.w3.org/TR/2011/WD-html5-20110113/history.html#location
  //
  // > The href attribute must return the current address of the
  // > associated Document object, as an absolute URL.
  // >
  // > On setting, if the Location object's associated Document
  // > object has completely loaded, then the user agent must act
  // > as if the assign() method had been called with the new value
  // > as its argument. Otherwise, the user agent must act as if
  // > the replace() method had been called with the new value as its
  // > argument.
  //
  // Note: The spec says the condition is "Document object has completely
  //       loaded", but that may break some websites. If the user was
  //       willing to move from one page to another, and was able to do
  //       so, we should not overwrite the session history entry even
  //       if the loading has not finished yet.
  //
  //       https://www.w3.org/Bugs/Public/show_bug.cgi?id=17041 
  //
  // See bug 39938, bug 72197, bug 178729 and bug 754029.
  // About other browsers:
  // http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2010-July/027372.html

  bool replace = false;
  if (!nsEventStateManager::IsHandlingUserInput()) {
    // "completely loaded" is defined at:
    //
    // http://www.w3.org/TR/2012/WD-html5-20120329/the-end.html#completely-loaded
    //
    // > 7.  document readiness to "complete", and fire "load".
    // >
    // > 8.  "pageshow"
    // >
    // > 9.  ApplicationCache
    // >
    // > 10. Print in the pending list.
    // >
    // > 12. Queue a task to mark the Document as completely loaded.
    //
    // Since Gecko doesn't (yet) have a flag corresponding to no. "12.
    // ... completely loaded", here the logic is a little tricky.

    nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
    nsCOMPtr<nsIDocument> document(do_GetInterface(docShell));
    if (document) {
      replace =
        nsIDocument::READYSTATE_COMPLETE != document->GetReadyStateEnum();

      // nsIDocShell::isExecutingOnLoadHandler is true while
      // the document is handling "load", "pageshow",
      // "readystatechange" for "complete" and "beforeprint"/"afterprint".
      //
      // Maybe this API property needs a better name.
      if (!replace) {
        docShell->GetIsExecutingOnLoadHandler(&replace);
      }
    }
  }

  if (cx) {
    rv = SetHrefWithContext(cx, aHref, replace);
  } else {
    rv = GetHref(oldHref);

    if (NS_SUCCEEDED(rv)) {
      nsCOMPtr<nsIURI> oldUri;

      rv = NS_NewURI(getter_AddRefs(oldUri), oldHref);

      if (oldUri) {
        rv = SetHrefWithBase(aHref, oldUri, replace);
      }
    }
  }

  return rv;
}
Пример #17
0
NS_IMETHODIMP
HTMLAreaElement::ToString(nsAString& aSource)
{
  return GetHref(aSource);
}
void
HTMLLinkElement::GetItemValueText(nsAString& aValue)
{
  GetHref(aValue);
}
Пример #19
0
NS_IMETHODIMP
nsLocation::ToString(nsAString& aReturn)
{
  // NB: GetHref checks CallerSubsumes().
  return GetHref(aReturn);
}
Пример #20
0
void
HTMLAnchorElement::ToString(nsAString& aSource)
{
  return GetHref(aSource);
}