mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
7d2b02d5fd
- Bug 1233109 - Refactor module parsing to instantiate ModuleBuilder earlier r=shu (ae6693165a) - Bug 1233109 - Call into the ModuleBuilder as we parse rather than traversing the AST again afterwards r=shu (c28f785d33) - Bug 1233109 - Check for duplicate exported names using the data in the ModuleBuilder and remove ModuleBox::exportNames r=shu (03999c3ebf) - Bug 1233109 - Make the getters in Import/ExportEntryObject const r=shu (ed6c2e5dca) - Bug 1228211 (part 1) - Rearrange nsDisplayCanvasBackgroundImage::Paint(). r=dholbert. (00f3aacb07) - Bug 1228211 (part 2) - Remove unused functions in nsRenderingContext. r=dholbert. (86d9983e82) - Bug 1231550 - Use DrawTarget instead of gfxContext and/or nsRenderingContext in many places in font/text code. r=jfkthame. (b0962c9b17) - Bug 1234418 - Not trust glyph run starts from a cluster start character. r=jfkthame (b0920d8072) - more of Bug 1222166 - use gcc/clang warning f (690640c6c7) - Bug 1064843 part 1 - Make nsImageFrame inherit nsContainerFrame. r=dholbert (bd5efe0a93) - Bug 1238660 part 1 - Make mWinsInCascade initially false; r=hiro (8420017e68) - Bug 1238660 part 2 - Preserve "wins in cascade" state when updating animations; r=hiro (348a8ef769) - Bug 1230408 - Move suppress line break check out from control of SkipParentDisplayBasedStyleFixup. r=dbaron (ca853b3162) - Bug 1238660 part 3 - Add crashtest; r=hiro (ab4daba520) - Bug 1230005: Factor out relocation style decision; r=jolesen (03ea0e9ba0) - Bug 1230005: Hide specifics of the LDR instruction; r=jolesen (92b0396f81) - Bug 1230005: Flush the assembler buffer at the end of asm.js compilation; r=luke (06e0911bfb) - Bug 1230005: Delay buffer flushing in asm.js until the last minute; r=luke (d3be91cca5) - Bug 1233111 - Share method lists for SIMD types. r=bbouvier (70ec039259) - Bug 1229642 - Fix unified build duplicate static name error (rs=jandem) (eb05c13fec) - Bug 1231338 - SAB gating test cases. r=luke (a8c6740745) - Bug 1233111 - Remove geometry altering SIMD conversions. r=bbouvier (a9c93d7694) - Bug 1233111 - Add unsigned SIMD types to interpreter. r=bbouvier (6187dc7a1e) - Bug 1233111 - Add ecma_7 shift tests. r=bbouvier (17c612dac5) - Bug 1233111 - Implement SIMD shiftRightByScalar(). r=bbouvie (b9b0c848b7) - Bug 1233111 - Add a new ToUint8() function. r=efaust (f1bc50a229) - ug 1233111 - Implement saturating arithmetic for SIMD. r=bbouvier (42a98a07d6) - Bug 1229642 - Factor out StringToNewUTF8CharsZ (r=jandem) (3c4f71214b) - revert PM modification to setProfilingEnabled (4a05202975) - Bug 1229642 - Split wasm::Module out of AsmJSModule (r=bbouvier) (75a1832b1a) - Bug 1229642 - change to AsmJSActivation to WasmActivation (r=bbouvier) (a2e8513369) - Bug 1229642 - Factor AsmJSLink.cpp into wasm/asm.js and consolidate AsmJS* into AsmJS.cpp (r=bbouvier) (3a489c6410)
142 lines
4.1 KiB
C++
142 lines
4.1 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
|
#include "mozilla/RefPtr.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsTArray.h"
|
|
#include "nsString.h"
|
|
#include "nsDependentString.h"
|
|
|
|
#include "prinrval.h"
|
|
|
|
#include "gfxContext.h"
|
|
#include "gfxFont.h"
|
|
#include "gfxPlatform.h"
|
|
|
|
#include "gfxFontTest.h"
|
|
#include "mozilla/Attributes.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::gfx;
|
|
|
|
class FrameTextRunCache;
|
|
|
|
static FrameTextRunCache *gTextRuns = nullptr;
|
|
|
|
/*
|
|
* Cache textruns and expire them after 3*10 seconds of no use.
|
|
*/
|
|
class FrameTextRunCache final : public nsExpirationTracker<gfxTextRun,3> {
|
|
public:
|
|
enum { TIMEOUT_SECONDS = 10 };
|
|
FrameTextRunCache()
|
|
: nsExpirationTracker<gfxTextRun,3>(TIMEOUT_SECONDS * 1000,
|
|
"FrameTextRunCache")
|
|
{}
|
|
~FrameTextRunCache() {
|
|
AgeAllGenerations();
|
|
}
|
|
|
|
void RemoveFromCache(gfxTextRun* aTextRun) {
|
|
if (aTextRun->GetExpirationState()->IsTracked()) {
|
|
RemoveObject(aTextRun);
|
|
}
|
|
}
|
|
|
|
// This gets called when the timeout has expired on a gfxTextRun
|
|
virtual void NotifyExpired(gfxTextRun* aTextRun) {
|
|
RemoveFromCache(aTextRun);
|
|
delete aTextRun;
|
|
}
|
|
};
|
|
|
|
static gfxTextRun *
|
|
MakeTextRun(const char16_t *aText, uint32_t aLength, gfxFontGroup *aFontGroup,
|
|
const gfxFontGroup::Parameters* aParams, uint32_t aFlags)
|
|
{
|
|
nsAutoPtr<gfxTextRun> textRun;
|
|
if (aLength == 0) {
|
|
abort();
|
|
//textRun = aFontGroup->MakeEmptyTextRun(aParams, aFlags);
|
|
} else if (aLength == 1 && aText[0] == ' ') {
|
|
abort();
|
|
//textRun = aFontGroup->MakeSpaceTextRun(aParams, aFlags);
|
|
} else {
|
|
textRun = aFontGroup->MakeTextRun(aText, aLength, aParams, aFlags);
|
|
}
|
|
if (!textRun) {
|
|
return nullptr;
|
|
}
|
|
nsresult rv = gTextRuns->AddObject(textRun);
|
|
if (NS_FAILED(rv)) {
|
|
gTextRuns->RemoveFromCache(textRun);
|
|
return nullptr;
|
|
}
|
|
return textRun.forget();
|
|
}
|
|
|
|
static already_AddRefed<DrawTarget>
|
|
MakeDrawTarget()
|
|
{
|
|
const int size = 200;
|
|
|
|
RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
|
|
CreateOffscreenContentDrawTarget(IntSize(size, size),
|
|
SurfaceFormat::B8G8R8X8);
|
|
return drawTarget.forget();
|
|
}
|
|
|
|
TEST(Gfx, WordCache) {
|
|
gTextRuns = new FrameTextRunCache();
|
|
|
|
RefPtr<DrawTarget> dt = MakeDrawTarget();
|
|
{
|
|
gfxFontStyle style(mozilla::gfx::FontStyle::NORMAL,
|
|
139,
|
|
10.0,
|
|
0,
|
|
NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
|
|
0.0,
|
|
false, false,
|
|
NS_LITERAL_STRING(""));
|
|
|
|
RefPtr<gfxFontGroup> fontGroup =
|
|
gfxPlatform::GetPlatform()->CreateFontGroup(
|
|
NS_LITERAL_STRING("Geneva, MS Sans Serif, Helvetica,serif"), &style,
|
|
nullptr, nullptr, 1.0);
|
|
|
|
gfxTextRunFactory::Parameters params = {
|
|
dt, nullptr, nullptr, nullptr, 0, 60
|
|
};
|
|
|
|
uint32_t flags = gfxTextRunFactory::TEXT_IS_PERSISTENT;
|
|
|
|
// First load an Arabic word into the cache
|
|
const char cString[] = "\xd8\xaa\xd9\x85";
|
|
nsDependentCString cStr(cString);
|
|
NS_ConvertUTF8toUTF16 str(cStr);
|
|
gfxTextRun *tr =
|
|
MakeTextRun(str.get(), str.Length(), fontGroup, ¶ms, flags);
|
|
tr->GetAdvanceWidth(0, str.Length(), nullptr);
|
|
|
|
// Now try to trigger an assertion with a word cache bug. The first
|
|
// word is in the cache so it gets added to the new textrun directly.
|
|
// The second word is not in the cache.
|
|
const char cString2[] = "\xd8\xaa\xd9\x85\n\xd8\xaa\xd8\x85 ";
|
|
nsDependentCString cStr2(cString2);
|
|
NS_ConvertUTF8toUTF16 str2(cStr2);
|
|
gfxTextRun *tr2 =
|
|
MakeTextRun(str2.get(), str2.Length(), fontGroup, ¶ms, flags);
|
|
tr2->GetAdvanceWidth(0, str2.Length(), nullptr);
|
|
}
|
|
|
|
delete gTextRuns;
|
|
gTextRuns = nullptr;
|
|
}
|