Ejemplo n.º 1
0
void
nsSVGViewBox::GetBaseValueString(nsAString& aValue) const
{
  if (mBaseVal.none) {
    aValue.AssignLiteral("none");
    return;
  }
  char16_t buf[200];
  nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t),
                            MOZ_UTF16("%g %g %g %g"),
                            (double)mBaseVal.x, (double)mBaseVal.y,
                            (double)mBaseVal.width, (double)mBaseVal.height);
  aValue.Assign(buf);
}
Ejemplo n.º 2
0
NS_IMETHODIMP
ImageAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
{
  aName.Truncate();

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  if (IsLongDescIndex(aIndex) && HasLongDesc()) {
    aName.AssignLiteral("showlongdesc"); 
    return NS_OK;
  }
  return LinkableAccessible::GetActionName(aIndex, aName);
}
void
XULTreeGridCellAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
{
  aName.Truncate();

  if (aIndex != eAction_Click || !mTreeView)
    return;

  if (mColumn->Cycler()) {
    aName.AssignLiteral("cycle");
    return;
  }

  if (mColumn->Type() == dom::TreeColumn_Binding::TYPE_CHECKBOX &&
      IsEditable()) {
    nsAutoString value;
    mTreeView->GetCellValue(mRow, mColumn, value);
    if (value.EqualsLiteral("true"))
      aName.AssignLiteral("uncheck");
    else
      aName.AssignLiteral("check");
  }
}
Ejemplo n.º 4
0
void
nsSVGViewBox::GetBaseValueString(nsAString& aValue) const
{
  if (mBaseVal.none) {
    aValue.AssignLiteral("none");
    return;
  }
  PRUnichar buf[200];
  nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(PRUnichar),
                            NS_LITERAL_STRING("%g %g %g %g").get(),
                            (double)mBaseVal.x, (double)mBaseVal.y,
                            (double)mBaseVal.width, (double)mBaseVal.height);
  aValue.Assign(buf);
}
NS_IMETHODIMP
nsHTMLImageAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
{
  aName.Truncate();

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  if (IsValidLongDescIndex(aIndex)) {
    aName.AssignLiteral("showlongdesc"); 
    return NS_OK;
  }
  return nsLinkableAccessible::GetActionName(aIndex, aName);
}
Ejemplo n.º 6
0
NS_METHOD nsKeygenFormProcessor::ProvideContent(const nsAString& aFormType, 
						nsTArray<nsString>& aContent, 
						nsAString& aAttribute) 
{ 
  if (Compare(aFormType, NS_LITERAL_STRING("SELECT"), 
    nsCaseInsensitiveStringComparator()) == 0) {

    for (size_t i = 0; i < number_of_key_size_choices; ++i) {
      aContent.AppendElement(mSECKeySizeChoiceList[i].name);
    }
    aAttribute.AssignLiteral("-mozilla-keygen");
  }
  return NS_OK;
} 
Ejemplo n.º 7
0
void
HTMLLinkAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
{
  aName.Truncate();

  if (!IsLinked()) {
    HyperTextAccessible::ActionNameAt(aIndex, aName);
    return;
  }

  // Action 0 (default action): Jump to link
  if (aIndex == eAction_Jump)
    aName.AssignLiteral("jump");
}
Ejemplo n.º 8
0
void
nsXBLPrototypeHandler::GetEventType(nsAString& aEvent)
{
  nsCOMPtr<nsIContent> handlerElement = GetHandlerElement();
  if (!handlerElement) {
    aEvent.Truncate();
    return;
  }
  handlerElement->GetAttr(kNameSpaceID_None, nsGkAtoms::event, aEvent);
  
  if (aEvent.IsEmpty() && (mType & NS_HANDLER_TYPE_XUL))
    // If no type is specified for a XUL <key> element, let's assume that we're "keypress".
    aEvent.AssignLiteral("keypress");
}
Ejemplo n.º 9
0
NS_IMETHODIMP
SmsRequest::GetError(nsAString& aError)
{
  if (!mDone) {
    NS_ASSERTION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR,
                 "There should be no error if the request is still processing!");

    SetDOMStringToNull(aError);
    return NS_OK;
  }

  NS_ASSERTION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR ||
               mResult == JSVAL_VOID,
               "mResult should be void when there is an error!");

  switch (mError) {
    case nsISmsRequestManager::SUCCESS_NO_ERROR:
      SetDOMStringToNull(aError);
      break;
    case nsISmsRequestManager::NO_SIGNAL_ERROR:
      aError.AssignLiteral("NoSignalError");
      break;
    case nsISmsRequestManager::NOT_FOUND_ERROR:
      aError.AssignLiteral("NotFoundError");
      break;
    case nsISmsRequestManager::UNKNOWN_ERROR:
      aError.AssignLiteral("UnknownError");
      break;
    case nsISmsRequestManager::INTERNAL_ERROR:
      aError.AssignLiteral("InternalError");
      break;
    default:
      MOZ_ASSERT(false, "Unknown error value.");
  }

  return NS_OK;
}
Ejemplo n.º 10
0
NS_IMETHODIMP
nsPopupBoxObject::GetPopupState(nsAString& aState)
{
  aState.AssignLiteral("closed");

  nsMenuPopupFrame *menuPopupFrame = GetMenuPopupFrame();
  if (menuPopupFrame) {
    switch (menuPopupFrame->PopupState()) {
      case ePopupShowing:
      case ePopupOpen:
        aState.AssignLiteral("showing");
        break;
      case ePopupOpenAndVisible:
        aState.AssignLiteral("open");
        break;
      case ePopupHiding:
      case ePopupInvisible:
        aState.AssignLiteral("hiding");
        break;
    }
  }

  return NS_OK;
}
NS_IMETHODIMP
sbOriginPageImagePropertyInfo::GetCellProperties(const nsAString& aValue,
                                                 nsAString& _retval)
{
  if(aValue.EqualsLiteral("unknownOrigin") ||
     aValue.IsEmpty() ||
     aValue.IsVoid()) {
    _retval.AssignLiteral("image unknownOrigin");
    return NS_OK;
  }

  if(aValue.EqualsLiteral("webOrigin") ||
     StringBeginsWith(aValue, NS_LITERAL_STRING("http://"), CaseInsensitiveCompare) ||
     StringBeginsWith(aValue, NS_LITERAL_STRING("https://"), CaseInsensitiveCompare) ||
     StringBeginsWith(aValue, NS_LITERAL_STRING("ftp://"), CaseInsensitiveCompare)) {
    
    _retval.AssignLiteral("image webOrigin");
    return NS_OK;
  }

  _retval.AssignLiteral("image");

  return NS_OK;
}
Ejemplo n.º 12
0
nsresult
Link::GetProtocol(nsAString &_protocol)
{
  nsCOMPtr<nsIURI> uri(GetURI());
  if (!uri) {
    _protocol.AssignLiteral("http");
  }
  else {
    nsAutoCString scheme;
    (void)uri->GetScheme(scheme);
    CopyASCIItoUTF16(scheme, _protocol);
  }
  _protocol.Append(PRUnichar(':'));
  return NS_OK;
}
NS_IMETHODIMP
nsXULTreeItemAccessibleBase::GetActionName(PRUint8 aIndex, nsAString& aName)
{
  if (IsDefunct())
    return NS_ERROR_FAILURE;

  if (aIndex == eAction_Click) {
    aName.AssignLiteral("activate");
    return NS_OK;
  }

  if (aIndex == eAction_Expand && IsExpandable()) {
    PRBool isContainerOpen;
    mTreeView->IsContainerOpen(mRow, &isContainerOpen);
    if (isContainerOpen)
      aName.AssignLiteral("collapse");
    else
      aName.AssignLiteral("expand");

    return NS_OK;
  }

  return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
nsHTMLLinkAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
{
  aName.Truncate();

  if (!IsLinked())
    return nsHyperTextAccessible::GetActionName(aIndex, aName);

  // Action 0 (default action): Jump to link
  if (aIndex != eAction_Jump)
    return NS_ERROR_INVALID_ARG;

  aName.AssignLiteral("jump");
  return NS_OK;
}
Ejemplo n.º 15
0
NS_IMETHODIMP
CSSNameSpaceRuleImpl::GetCssText(nsAString& aCssText)
{
  aCssText.AssignLiteral("@namespace ");
  if (mPrefix) {
    nsString atomStr;
    mPrefix->ToString(atomStr);
    aCssText.Append(atomStr);
    aCssText.AppendLiteral(" ");
  }
  aCssText.AppendLiteral("url(");
  aCssText.Append(mURLSpec);
  aCssText.Append(NS_LITERAL_STRING(");"));
  return NS_OK;
}
Ejemplo n.º 16
0
NS_IMETHODIMP
IDBTransaction::GetMode(nsAString& aMode)
{
  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

  switch (mMode) {
    case READ_ONLY:
      aMode.AssignLiteral("readonly");
      break;
    case READ_WRITE:
      aMode.AssignLiteral("readwrite");
      break;
    case VERSION_CHANGE:
      aMode.AssignLiteral("versionchange");
      break;

    case MODE_INVALID:
    default:
      NS_NOTREACHED("Bad mode value!");
      return NS_ERROR_UNEXPECTED;
  }

  return NS_OK;
}
Ejemplo n.º 17
0
void
Link::GetProtocol(nsAString &_protocol, ErrorResult& aError)
{
  nsCOMPtr<nsIURI> uri(GetURI());
  if (!uri) {
    _protocol.AssignLiteral("http");
  }
  else {
    nsAutoCString scheme;
    (void)uri->GetScheme(scheme);
    CopyASCIItoUTF16(scheme, _protocol);
  }
  _protocol.Append(char16_t(':'));
  return;
}
Ejemplo n.º 18
0
void
ImportRule::GetCssText(nsAString& aCssText) const
{
  aCssText.AssignLiteral("@import url(");
  nsStyleUtil::AppendEscapedCSSString(mURLSpec, aCssText);
  aCssText.Append(')');
  if (mMedia) {
    nsAutoString mediaText;
    mMedia->GetText(mediaText);
    if (!mediaText.IsEmpty()) {
      aCssText.Append(' ');
      aCssText.Append(mediaText);
    }
  }
  aCssText.Append(';');
}
Ejemplo n.º 19
0
/* readonly attribute DOMString DisplayChipset; */
NS_IMETHODIMP nsSystemInfo::GetDisplayChipset(nsAString & aDisplayChipset)
{
  nsCString deviceId(mDeviceID);
  ToUpperCase(deviceId);
  PRInt32 pos = deviceId.Find(NS_LITERAL_CSTRING("&DEV_"));
  if (pos != -1) {
    deviceId.Cut(0, pos + 5);
  }
  pos = deviceId.Find(NS_LITERAL_CSTRING("&"));
  if (pos != -1) {
    deviceId.Cut(pos, deviceId.Length());
  }
  aDisplayChipset.AssignLiteral("0x");
  aDisplayChipset.AppendLiteral(deviceId.BeginReading());
  return NS_OK;
}
nsresult
nsDASHWebMODParser::GetAttribute(nsIDOMElement* aElem,
                                 const nsAString& aAttribute,
                                 nsAString& aValue)
{
  bool bAttributePresent;
  nsresult rv = aElem->HasAttribute(aAttribute, &bAttributePresent);
  NS_ENSURE_SUCCESS(rv, rv);
  if (!bAttributePresent)
    aValue.AssignLiteral("");
  else {
    rv = aElem->GetAttribute(aAttribute, aValue);
    NS_ENSURE_SUCCESS(rv, rv);
  }
  return NS_OK;
}
Ejemplo n.º 21
0
NS_IMETHODIMP
CSSImportRuleImpl::GetCssText(nsAString& aCssText)
{
  aCssText.AssignLiteral("@import url(");
  aCssText.Append(mURLSpec);
  aCssText.Append(NS_LITERAL_STRING(")"));
  if (mMedia) {
    nsAutoString mediaText;
    mMedia->GetText(mediaText);
    if (!mediaText.IsEmpty()) {
      aCssText.AppendLiteral(" ");
      aCssText.Append(mediaText);
    }
  }
  aCssText.AppendLiteral(";");
  return NS_OK;
}
Ejemplo n.º 22
0
NS_IMETHODIMP
nsAOLCiter::GetCiteString(const nsAString& aInString, nsAString& aOutString)
{
  aOutString.AssignLiteral("\n\n>> ");
  aOutString += aInString;

  // See if the last char is a newline, and replace it if so
  PRUnichar newline ('\n');
  if (aOutString.Last() == newline)
  {
    aOutString.SetLength(aOutString.Length() - 1);
  }

  aOutString.AppendLiteral(" <<\n");

  return NS_OK;
}
NS_IMETHODIMP
nsXPathNSResolver::LookupNamespaceURI(const nsAString & aPrefix,
                                      nsAString & aResult)
{
    if (aPrefix.EqualsLiteral("xml")) {
        aResult.AssignLiteral("http://www.w3.org/XML/1998/namespace");

        return NS_OK;
    }

    if (!mNode) {
        SetDOMStringToNull(aResult);

        return NS_OK;
    }

    return mNode->LookupNamespaceURI(aPrefix, aResult);
}
Ejemplo n.º 24
0
NS_IMETHODIMP
nsOS2Locale::GetXPLocale(const char* os2Locale, nsAString& locale)
{
  char  country_code[MAX_COUNTRY_CODE_LEN];
  char  lang_code[MAX_LANGUAGE_CODE_LEN];
  char  extra[MAX_EXTRA_LEN];
  char  os2_locale[MAX_LOCALE_LEN];

  if (os2Locale!=nsnull) {
    if (strcmp(os2Locale,"C")==0 || strcmp(os2Locale,"OS2")==0) {
      locale.AssignLiteral("en-US");
      return NS_OK;
    }
    if (!ParseLocaleString(os2Locale,lang_code,country_code,extra,'_')) {
//      * locale = "x-user-defined";
      // use os2 if parse failed
      CopyASCIItoUTF16(nsDependentCString(os2Locale), locale);  
      return NS_OK;
    }

    if (*country_code) {
      if (*extra) {
        PR_snprintf(os2_locale,MAX_LOCALE_LEN,"%s-%s.%s",lang_code,country_code,extra);
      }
      else {
        PR_snprintf(os2_locale,MAX_LOCALE_LEN,"%s-%s",lang_code,country_code);
      }
    } 
    else {
      if (*extra) {
        PR_snprintf(os2_locale,MAX_LOCALE_LEN,"%s.%s",lang_code,extra);
      }
      else {
        PR_snprintf(os2_locale,MAX_LOCALE_LEN,"%s",lang_code);
      }
    }

    CopyASCIItoUTF16(nsDependentCString(os2_locale), locale);  
    return NS_OK;

  }

  return NS_ERROR_FAILURE;
}
Ejemplo n.º 25
0
/* static */
already_AddRefed<imgIEncoder>
ImageEncoder::GetImageEncoder(nsAString& aType)
{
  // Get an image encoder for the media type.
  nsCString encoderCID("@mozilla.org/image/encoder;2?type=");
  NS_ConvertUTF16toUTF8 encoderType(aType);
  encoderCID += encoderType;
  nsCOMPtr<imgIEncoder> encoder = do_CreateInstance(encoderCID.get());

  if (!encoder && aType != NS_LITERAL_STRING("image/png")) {
    // Unable to create an encoder instance of the specified type. Falling back
    // to PNG.
    aType.AssignLiteral("image/png");
    nsCString PNGEncoderCID("@mozilla.org/image/encoder;2?type=image/png");
    encoder = do_CreateInstance(PNGEncoderCID.get());
  }

  return encoder.forget();
}
nsresult
nsDOMFileReader::GetAsDataURL(nsIDOMBlob *aFile,
                              const char *aFileData,
                              uint32_t aDataLen,
                              nsAString& aResult)
{
  aResult.AssignLiteral("data:");

  nsresult rv;
  nsString contentType;
  rv = aFile->GetType(contentType);
  if (NS_SUCCEEDED(rv) && !contentType.IsEmpty()) {
    aResult.Append(contentType);
  } else {
    aResult.AppendLiteral("application/octet-stream");
  }
  aResult.AppendLiteral(";base64,");

  uint32_t totalRead = 0;
  while (aDataLen > totalRead) {
    uint32_t numEncode = 4096;
    uint32_t amtRemaining = aDataLen - totalRead;
    if (numEncode > amtRemaining)
      numEncode = amtRemaining;

    //Unless this is the end of the file, encode in multiples of 3
    if (numEncode > 3) {
      uint32_t leftOver = numEncode % 3;
      numEncode -= leftOver;
    }

    //Out buffer should be at least 4/3rds the read buf, plus a terminator
    char *base64 = PL_Base64Encode(aFileData + totalRead, numEncode, nullptr);
    AppendASCIItoUTF16(nsDependentCString(base64), aResult);
    PR_Free(base64);

    totalRead += numEncode;
  }

  return NS_OK;
}
Ejemplo n.º 27
0
nsresult
nsPosixLocale::GetXPLocale(const char* posixLocale, nsAString& locale)
{
  char  country_code[MAX_COUNTRY_CODE_LEN+1];
  char  lang_code[MAX_LANGUAGE_CODE_LEN+1];
  char  extra[MAX_EXTRA_LEN+1];
  char  posix_locale[MAX_LOCALE_LEN+1];

  if (posixLocale!=nsnull) {
    if (strcmp(posixLocale,"C")==0 || strcmp(posixLocale,"POSIX")==0) {
      locale.AssignLiteral("en-US");
      return NS_OK;
    }
    if (!ParseLocaleString(posixLocale,lang_code,country_code,extra,'_')) {
//      * locale = "x-user-defined";
      // use posix if parse failed
      CopyASCIItoUTF16(nsDependentCString(posixLocale), locale);
      return NS_OK;
    }

    // Special case: substitute "nb" (Norwegian Bokmal) for macrolanguage
    // code "no" (Norwegian)
    if (nsDependentCString(lang_code).LowerCaseEqualsLiteral("no")) {
      lang_code[1] = 'b';
    }

    if (*country_code) {
      PR_snprintf(posix_locale,sizeof(posix_locale),"%s-%s",lang_code,country_code);
    } 
    else {
      PR_snprintf(posix_locale,sizeof(posix_locale),"%s",lang_code);
    }

    CopyASCIItoUTF16(nsDependentCString(posix_locale), locale);
    return NS_OK;

  }

    return NS_ERROR_FAILURE;

}
Ejemplo n.º 28
0
void AccessibleWrap::GetRoleDescription(role aRole,
                                        nsIPersistentProperties* aAttributes,
                                        nsAString& aGeckoRole,
                                        nsAString& aRoleDescription) {
  nsresult rv = NS_OK;

  nsCOMPtr<nsIStringBundleService> sbs =
      do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
  if (NS_FAILED(rv)) {
    NS_WARNING("Failed to get string bundle service");
    return;
  }

  nsCOMPtr<nsIStringBundle> bundle;
  rv = sbs->CreateBundle(ROLE_STRINGS_URL, getter_AddRefs(bundle));
  if (NS_FAILED(rv)) {
    NS_WARNING("Failed to get string bundle");
    return;
  }

  if (aRole == roles::HEADING) {
    nsString level;
    rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("level"), level);
    if (NS_SUCCEEDED(rv)) {
      const char16_t* formatString[] = {level.get()};
      rv = bundle->FormatStringFromName("headingLevel", formatString, 1,
                                        aRoleDescription);
      if (NS_SUCCEEDED(rv)) {
        return;
      }
    }
  }

  GetAccService()->GetStringRole(aRole, aGeckoRole);
  rv = bundle->GetStringFromName(NS_ConvertUTF16toUTF8(aGeckoRole).get(),
                                 aRoleDescription);
  if (NS_FAILED(rv)) {
    aRoleDescription.AssignLiteral("");
  }
}
Ejemplo n.º 29
0
void nsMathMLElement::GetLinkTarget(nsAString& aTarget) {
  const nsAttrValue* target =
      mAttrs.GetAttr(nsGkAtoms::target, kNameSpaceID_XLink);
  if (target) {
    target->ToString(aTarget);
  }

  if (aTarget.IsEmpty()) {
    static Element::AttrValuesArray sShowVals[] = {nsGkAtoms::_new,
                                                   nsGkAtoms::replace, nullptr};

    switch (FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::show, sShowVals,
                            eCaseMatters)) {
      case 0:
        aTarget.AssignLiteral("_blank");
        return;
      case 1:
        return;
    }
    OwnerDoc()->GetBaseTarget(aTarget);
  }
}
Ejemplo n.º 30
0
void
UuidToString(bt_uuid_t* aUuid, nsAString& aString) {
  char uuidStr[37];

  uint32_t uuid0, uuid4;
  uint16_t uuid1, uuid2, uuid3, uuid5;

  memcpy(&uuid0, &(aUuid->uu[0]), sizeof(uint32_t));
  memcpy(&uuid1, &(aUuid->uu[4]), sizeof(uint16_t));
  memcpy(&uuid2, &(aUuid->uu[6]), sizeof(uint16_t));
  memcpy(&uuid3, &(aUuid->uu[8]), sizeof(uint16_t));
  memcpy(&uuid4, &(aUuid->uu[10]), sizeof(uint32_t));
  memcpy(&uuid5, &(aUuid->uu[14]), sizeof(uint16_t));

  sprintf(uuidStr, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x",
          ntohl(uuid0), ntohs(uuid1),
          ntohs(uuid2), ntohs(uuid3),
          ntohl(uuid4), ntohs(uuid5));

  aString.Truncate();
  aString.AssignLiteral(uuidStr);
}