зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1185236 - Add adjustPrintJobName in order to avoid IPP job name limit. r=karlt
MozReview-Commit-ID: n2k9lwfoyW --HG-- extra : rebase_source : 0a9b2ee4235a4a1000abec15434fe1d37ecdab0d
This commit is contained in:
Родитель
70ca353a57
Коммит
4570ca2e69
|
@ -15,6 +15,13 @@
|
|||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/HelpersCairo.h"
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsUTF8Utils.h"
|
||||
|
||||
// IPP spec disallow the job-name which is over 255 characters.
|
||||
// RFC: https://tools.ietf.org/html/rfc2911#section-4.1.2
|
||||
#define IPP_JOB_NAME_LIMIT_LENGTH 255
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
@ -160,6 +167,22 @@ PrintTarget::GetReferenceDrawTarget(DrawEventRecorder* aRecorder)
|
|||
return do_AddRef(mRefDT);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
PrintTarget::AdjustPrintJobNameForIPP(const nsAString& aJobName,
|
||||
nsCString& aAdjustedJobName)
|
||||
{
|
||||
CopyUTF16toUTF8(aJobName, aAdjustedJobName);
|
||||
|
||||
if (aAdjustedJobName.Length() > IPP_JOB_NAME_LIMIT_LENGTH) {
|
||||
uint32_t length =
|
||||
RewindToPriorUTF8Codepoint(aAdjustedJobName.get(),
|
||||
(IPP_JOB_NAME_LIMIT_LENGTH - 3U));
|
||||
aAdjustedJobName.SetLength(length);
|
||||
aAdjustedJobName.AppendLiteral("...");
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DrawTarget>
|
||||
PrintTarget::CreateWrapAndRecordDrawTarget(DrawEventRecorder* aRecorder,
|
||||
DrawTarget* aDrawTarget)
|
||||
|
|
|
@ -136,6 +136,9 @@ public:
|
|||
*/
|
||||
virtual already_AddRefed<DrawTarget> GetReferenceDrawTarget(DrawEventRecorder* aRecorder);
|
||||
|
||||
static void AdjustPrintJobNameForIPP(const nsAString& aJobName,
|
||||
nsCString& aAdjustedJobName);
|
||||
|
||||
protected:
|
||||
|
||||
// Only created via subclass's constructors
|
||||
|
|
Загрузка…
Ссылка в новой задаче