mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
ebda1f73c4
- Bug 1208341 - Make NativeObject::goodElementsAllocationAmount fallible. r=Waldo (64eac96aa2) - minor reformat (95d27e5332) - Bug 1214049 - Use ReportOutOfMemory in NativeObject::goodElementsAllocationAmount. r=Waldo (6779dd81c6) - Bug 1206700 - Fix an bug in property assignment, recently exposed by Reflect.set. r=waldo (0a7484ab70) - Bug 1186810 (part 1) - Replace nsBaseHashtable::EnumerateRead() calls in dom/workers/ with iterators. r=nsm. (05a550c94f) - Bug 1186810 (part 2) - Replace nsBaseHashtable::EnumerateRead() calls in dom/workers/ with iterators. r=nsm. (f1659abf38) - Bug 1186810 (part 3) - Replace nsBaseHashtable::EnumerateRead() calls in dom/workers/ with iterators. r=nsm. (cda73950f3) - Bug 1186810 (part 4) - Replace nsBaseHashtable::EnumerateRead() calls in dom/workers/ with iterators. r=nsm. (555e83bacb) - Bug 1186810 (part 5) - Replace nsBaseHashtable::EnumerateRead() calls in dom/workers/ with iterators. r=nsm. (c9520dbc5f) - Bug 1186810 (part 6) - Replace nsBaseHashtable::EnumerateRead() calls in dom/workers/ with iterators. r=khuey. (24fcdfd772) - Bug 1186810 (part 7) - Replace nsBaseHashtable::EnumerateRead() calls in dom/workers/ with iterators. r=khuey. (657cd575fb) - Bug 1186810 (part 8) - Replace nsBaseHashtable::Enumerate() calls in dom/workers/ with iterators. r=khuey. (0ff6a5e5ff) - Bug 1205020 - Disable optimizations in TestTuple.cpp since it breaks the build on VS2013 Windows 10. r=froydnj (1c98d8485c) - Bug 1199068 - Soothe a unused variable warning in TestSplayTree.cpp. r=nfroyd (d4d4ab56fe) - Bug 1209751 - Make sync decoding more reliable when nsImageRenderer is used with -moz-element. r=roc (95c99bb907) - Bug 1209731 - Return DrawResult::NOT_READY from PaintBackgroundWithSC if we couldn't prepare the nsImageRenderer. r=tn (8bd98872cb) - Bug 1209715 - Add operator overloads for combining DrawResults. r=tn (f3a9806d03) - Bug 1209725 - Use DrawResult combining operators in nsCSSRendering::PaintBackgroundWithSC. r=tn (420cfde63e) - Bug 1211363. Calculate min inset blur with max border radius. r=mstange (5e408bc67f) - Bug 1213545. Carry x,y offsets with inset box shadows. r=mstange (52c20715bc) - Bug 1209739 - Make nsImageRenderer::PrepareImage() fail unless an image has STATUS_LOAD_COMPLETE. r=tn (c1cc4d79d8) - Bug 1209765 (Part 1) - Support sync decoding of border-image in nsCSSRendering. r=tn (3a54b7d117) - Bug 1209765 (Part 2) - Support sync decoding and track draw results in nsDisplayBorder. r=tn (03abe63e67) - Bug 1209765 (Part 3) - Support sync decoding and track draw results when drawing borders in nsButtonFrameRenderer. r=tn (107b9bb851) - Bug 1209765 (Part 4) - Support sync decoding and track draw results when drawing borders in nsFieldSetFrame. r=tn (16fd30aba3) - Bug 1209765 (Part 5) - Support sync decoding and track draw results when drawing borders in nsRangeFrame. r=tn (289de3c17e) - Bug 1209765 (Part 6) - Support sync decoding and track draw results when drawing borders in nsColumnSetFrame. r=tn (0317d6a914) - Bug 1143267 - Make nsDisplayAltFeedback use nsGenericImageGeometry. r=tn (8fc6372d48) - Bug 1176081. Add a pref to control drawing of the image loading place holder icon and border, and disable it. r=seth (792e8ec9b3) - Bug 1209765 (Part 7) - Support sync decoding and track draw results when drawing borders in nsImageFrame. r=tn (70d9af60a3) - Bug 1209765 (Part 8) - Support sync decoding and track draw results when drawing borders in MathML code. r=tn (555bff2635) - Bug 1209765 (Part 9) - Support sync decoding and track draw results when drawing borders in nsTableFrame. r=tn (d242dc5c79) - Bug 1209765 (Part 10) - Support sync decoding and track draw results when drawing borders in nsGroupBoxFrame. r=tn (a7187cfa5d) - Bug 1209765 (Part 11) - Support sync decoding and track draw results when drawing borders in nsTreeBodyFrame. r=tn (21bd2b3285) - Bug 1209765 (Followup) - Add very minor fuzz to underline-button-2.html on OS X 10.10. r=me (04cff3c2ff) - Bug 1209765 (Followup) - Add very minor fuzz to underline-button-1.html on OS X 10.10. r=me DONTBUILD (187fdb4106) - Bug 1217069 - Don't attempt to mis-optimize JSON.stringify's filter-list creation for replacer arrays with trailing holes. r=arai (04fb907d42) - Bug 1156463 - Add a preference option to disable the scale transform applied to MathML operators. r=karl (415a041117) - Bug 1174143 - Remove private tables for Standard Symbols L and MathJax fonts. r=karlt (1f58d14229) - Bug 1222297 - Use channel->Open2() in netwerk/base/nsNetUtil.cpp (r=sicking) (cbd12ebb0a) - Bug 1139709. Remove unused parameters from nsMathMLChar::GetMaxWidth. r=mats (6ea90a0a02) - Bug 1160635 patch 1 - Add reftests. r=dholbert (b58f8fd7fa) - Bug 1160635 patch 2 - Stop making image resizing optimization when image has percent width or height. r=dholbert (9ae3621baf) - Bug 1156097 - Make nsImageFrame::mImageMap an nsRefPtr; r=roc (b49157e424) - Bug 1176156. Make sure images are asked to decode if we are drawing the alt feedback instead of the image. r=seth (8d7a09622e) - Bug 1207355 (Part 2) - Stop requesting decodes in nsImageLoadingContent. r=tn (c781285098) - Bug 1207355 (Part 3) - Request decodes intelligently in nsImageFrame. r=tn (c61b7591fb) - Bug 1156028 - Teach clang-analyzer about XPCOM assertion macros; r=froydnj (4d8b7ecf03) - Bug 1207355 (Part 4) - Request decodes intelligently in nsBulletFrame. r=tn (2d7ced9c0f) - Bug 1207355 (Part 5) - Request decodes intelligently in MultipartImage. r=tn (c0cb580838) - Bug 1207355 (Part 6) - Only respect StartDecoding() in imgRequest/imgRequestProxy. r=tn (0e108cda4c) - Bug 1207355 (Part 7) - Only trigger intrinsic size decode in FinalizeDecoder() if StartDecoding() was called. r=tn (a71fc0d1b7) - Bug 1207355 (Part 8) - Remove imgIContainer::RequestDecode() and imgIRequest::RequestDecode(). r=tn (fbce1ccbe1) - Bug 1215596 - outline: auto; will render as outline: solid; when disabled. r=roc (b8ea369628) - Bug 1180966. Remove code that made no sense. r=mstange (eac62913ef) - Bug 1217905. Don't transform dest rects if destination context has a rotation with inset box shadows. r=mstange (53cf4d6f86) - Bug 1189010. In ScrollFrameHelper::BuildDisplayList decide if we are building a scrollable layer before we call AppendScrollPartsTo because it needs this information. r=mstange (a008c7e34d) - Bug 1204535 - Flatten conditional structure one level. r=tn (152ff398a0) - Bug 1204535 - Remove no-op code. r=tn (95d17e64c3) - Bug 1204535 - Collapse redundant conditional block. r=tn (d0e90b8d80) - Bug 1204535 - Rename usingDisplayport to usingDisplayPort for consistency. r=tn (516757a933) - Bug 1204535 - Relocate comment to go with the line of code it's commenting. r=tn (70ae0c5e71) - Bug 1204535 - Hoist out the code to initially compute usingDisplayPort. r=tn (4a5336a480) - Bug 1210578. Part 1. Rename mShouldBuildScrollableLayer to mWillBuildScrollableLayer to better capture the meaning of the variable. r=mstange (d13bb100f4) - Bug 1210578. Part 2. Rename shouldBuildLayer to couldBuildLayer to better reflect it's actual meaning. r=mstange (ae21c687c2) - Bug 1151663 - Only call GetOrMaybeCreateDisplayPort() in nsLayoutUtils::PaintFrame() if we are using containers for root scroll frames. r=tn (2bef3f9457) - Bug 1195431 - Small refactoring to use conditionals consistently. r=tn (897eb0f42a) - Bug 1167069 - Initialize nsPluginFrame::mInstanceOwner to null. r=jmathies (6ce1fcb8c2) - Bug 1137944 - Add support for hiding plugin windows during async dom scroll operations managed in the content process. r=roc (730a0ed004) - Bug 1210578. Part 3. Create DecideScrollableLayer that encapsulates all logic to create display ports and build scrollable layers. r=mstange (994ac6ec5e) - Bug 376679 part.1 Change the result of EventStateManager::ComputeScrollTarget() from nsIScrollableFrame* to nsIFrame* r=smaug (914878edbd) - Bug 376679 part.2 EventStateManager should treat plugin frame as scrollable frame if the plugin wants to handle wheel events as default action r=smaug (58c146b7ba) - Bug 376679 part.3 Compute default action target frame for wheel event before deciding the action because plugin should decide what is the default action when the target is a plugin frame r=smaug (334cbfcf53) - Bug 376679 part.4 Manage wheel transaction at sending a wheel event to target plugin r=smaug (d76062a429) - Bug 376679 part.5 nsPluginInstanceOwner::ProcessEvent() should create WM_MOUSE*WHEEL message from WidgetWheelEvent data r=smaug+jimm (56ee6bdf90) - Bug 376679 part.6 nsPluginInstanceOwner::ProcessEvent() should refer both deltaMode and system scroll amount settings when it generates WM_MOSUE*WHEEL messages r=jimm (927cb10a3b) - Bug 1145546 - Add missing nsBidiPresUtils.h include to nsGfxScrollFrame.cpp to fix non-unified bustage. r=jfkthame (af4043c024) - Bug 1137944 - Add plugin window handling for apz related notifications received by the content process. r=mstange (798e9676fd) - Bug 1208819 - Fix irregexp overrecursion check to ignore interrupts. r=bhackett (c845e65a2e) - Bug 1218640 - IonMonkey: MIPS64: Add support into irregexp. r=arai (613ddd95ef) - Bug 1211964 - Fix a couple of OOM handling issues in regexp code r=terrence (bb269eef3e) - Bug 1200734 - Use stable hashing for LiveScopesMap; r=shu (1d717c8f53) - Bug 1223853 - Use stable hashing for ObjectValueMap; r=jonco (c91f3b1b21) - Bug 1223863 - Use stable hashing for WeakGlobalObjectSet; r=jonco (eb29e841f1) - Bug 1223918 - Use stable hashing for WatchPointMap; r=jonco (7a69630c83) - Bug 1212011 - Replace more uses of CrashAtUnhandlableOOM() with AutoEnterOOMUnsafeRegion r=terrence (0079439d90) - Bug 1224347 - Use stable hashing for DebuggerWeakMaps; r=jonco (d2a627e077) - Bug 1219418 - Always access minEmptyChunkCount under the GC lock; r=jonco (f67f74ca57) - Bug 1202923 - Encapsulate GC begin and end notification callbacks in an RAII guard; r=jonco (46f63fd090) - Bug 1212624 - Tests for LinkedList, r=Waldo (3d48b12918) - Bug 1215752 - Weakmap refactoring, r=terrence (90cbf4d294) - Bug 1216744 - Move weakKeys to the zone, r=terrence (5fdb1d57bf) - Bug 1215336 - Measure unmark gray time, r=terrence (278e0ee562) - Bug 1211939 - Don't call JSRuntime::onOutOfMemory from helper threads. r=jonco (86c6906421) - Bug 1218638 - IonMonkey: MIPS64: Add support into jit/shared. r=lth (e4f2904c53) - Bug 1216277 - Don't assert properties of the buffer location if the assembler is out of memory r=jandem (65556e83ce) - Bug 1211962 - addNativeToBytecodeEntry: Check that the masm.currentOffset() returns a valid result. r=djvj (3c5723c65a) - Bug 1090957 - IonMonkey: Add temp registers for mips atomics. r=lth (00f23fe2e9) - Bug 1218967 - Do not stop executing autospider.sh on test failure. r=sfink (75f912efbb) - Bug 1213881 - Run jsapi-tests in the arm64-sim autospider. r=sfink (2e731f14e7) - Bug 1216607 - Fix assertion failure ARM assembler on OOM r=jandem (0bc2dcb5db) - Bug 1209515 part 1 - IonBuilder: Attach hit counts on the MIRGraph. r=bhackett (f5448d9596) - Bug 1209515 part 2 - Ensure that MPhi removal considers removed uses. r=bhackett (95de413c50) - Bug 1209515 part 3 - IonMonkey: Add branch pruning based on code coverage counters. r=bhackett (fb71022658) - Bug 1209515 part 0 - Move callerResumePoint field next to other resume points of basic blocks. r=bbouvier (394b52860d) - Bug 1209515 part 4 - Increment code coverage counters on bailouts. r=bhackett (22edac5c24) - Bug 1209515 part 5 - Ensure that we recompile when we have frequent bailouts caused by the first execution. r=jandem (bca0fa4118) - Bug 1209515 part 7 - IonBuilder: pushLoop should not infer the continuepc from the entry block. r=jandem (025d10fd57) - Bug 1209515 part 8 - IonBuilder: newOsrPreheader should not use the hit-count of the loop. r=jandem (5db05ef17f) - Bug 1209515 part 9 - IonBuilder: Loop header should use the hit count of the loop, instead of before the loop. r=jandem (b259b490bf) - Bug 1209515 part 10 - Prevent PruneUnusedBranches from being greedy while removing branches which have only be visited a few times. r=bhackett (4a1a7b34b6) - Bug 1209515 part 11 - Increase JitSpewer mask size to avoid overflow. r=bbouvier (28546de94e) - Bug 1219401 - Don't call script->hasIonScript() off-thread, fixes a TSan race. r=h4writer (8f31724484) - Bug 1172076 - Assert that SnapshotIterator::initInstructionResults always match the recover instructions data. r=jandem (6ed0eebc65) - Bug 1209260 - Don't use sincos on iOS r=npb (eaa3cacac7) - Bug 1222499 - "JitSpew/IonSpew: warmupCounter should use PRIu32 instead of PRIuSIZE". r=nbp (50b80b985a) - Bug 1216182: Rename MODE_MASK to MODE_BITS_MASK, r=hv1989 (f28e461d94) - Bug 1137944 - Add a pref to control plugin window hiding. r=roc (691dc99b94) - Bug 1214878 - When async scrolling with e10s hide windowed plugins in sub documents. r=roc (79c0eac459) - Bug 1215434 part.1 If scroll target is a plugin frame, EventStateManager::PostHandleEvent() should send the wheel event to the plugin frame even if APZC already handled it r=smaug (f2e8e33d7f) - Bug 1215434 part.2 Add plugin frame rect to dispatch-to-content region if it wants to handle wheel event as default action r=mstange (dbecb1e256) - Fix inactive scroll frames sometimes creating very large, incorrect hit regions. (bug 1190112, r=tn) (2056d8d63e) - Fix scrollbars on subframes not directing APZ events to the correct scrollframe. (bug 1213324, r=tn) (0594923ab2) - Bug 1182017. Call Send__delete__ immediately rather than through an event. r=nical (90714b065b) - Bug 1212656 - ARM64: Fix automation build failures. (r=efaust) (5695518dd1) - Bug 1137944 - Simplify the api associated with hiding e10s plugin widgets. r=roc (dfbfda4d31) - Bug 1137944 - Fire before and after composite events. r=matt.woodrow (0048aeb8cb) - Bug 1201660 - When layer tree updates get dropped, hide plugins associated with the tree. Fixes a bug where we were hiding all plugins associated with the window. r=matt.woodrow (9352150c73) - Bug 1137944 - Backout compositor bits (cset b4711fa5f734) which caused a telemetry metric regression. r=backout (241659d6a8) - Bug 1127270: Only acquire a hold on the compositor thread once the channel for a parent actor has been succesfully connected. r=nical (1d1b077d68) - Bug 1207270 - Ensure that the TaskThrottler objects are created on the main thread. r=botond (b43af025f1) - Bug 1194876 - Add test. r=botond (440c72ec81) - Bug 1152051 - Gtest. r=Cwiiis,kats (011f066f37) - Bug 1144112 - Update the FlingStop tests to check if events are flowing properly after the fast-motion blocks are done. r=botond (25f71629d7) - Bug 1092128 - Ensure that when touch-action is enabled the gtests always provide default touch behaviours where expected. r=botond (3f0d1229f3) - Bug 1144112 - Only set the default allowed touch behaviour if the event is not consumed, to have the tests better reflect reality. r=botond (1548bd14bb) - Bug 1163845 - Unify handling of time in APZ gtests. r=kats (b73a16ef5e) - Bug 1159398 - Set the controller thread when running APZ gtests. r=dvander (96b551036e) - Bug 1159985 - Gtest. r=kats (23d7d86492) - Bug 1159985 - In APZ gtests, allow panning in both directions. r=kats (14f4b1156a) - Bug 1169695 - Make the test timestamp privately held by the MockContentControllerDelayed. r=botond (ffe04249c1) - Bug 1198900 - Add a gtest to ensure we don't crash when prevent-defaulting a wheel event. r=botond, a=topcrash (c9e5993f18) - Bug 1169690 - Gtests. r=kats (7e825b34ac) - Bug 1207270 - Update tests to ensure that TaskThrottlers are created as appropriate. r=botond (7bb6f1f406) - Bug 1169695 - Ensure timed tasks are dispatched appropriately when advancing the time. r=botond (af1fbe0a85) - Bug 1204837, Part 1: Make ClosingService thread Nuwa-friedly. r=khuey (eb790b5215) - Bug 1204837, Part 2: Cloned ImageBridgeParent and CompositorParent should hold a reference to the compositor thread. r=nical (cd742df2e2) - Bug 1205016: double ClosingService thread stack size to avoid stack overflow r=glandium (cb9acc828f) - Bug 1163570 - Ignore pending plugin updates and hide plugin windows when a remote layer tree associated with a tab is no longer in use. r=roc (ae852ad442) - Bug 1196539 - Apply plugin config using AutoResolveRefLayers during composition. r=matt.woodrow (12dbdb6222) - Bug 1137944 - Cache compositor plugin update data to avoid sending updates to the main thread when the data doesn't change. r=roc (63c503d2f6) - Bug 1137944 - On Windows defer composition until we receive confirmation plugin window metrics have been updated. r=roc (39d5786519) - Bug 1137944 - Move plugin window metrics updates to a point during comososition where we know the remote layer tree is hooked up to the chrome layer tree. r=matt.woodrow (a32f77ffb1) - Bug 1213671 - CompositorParent::UpdatePluginWindowState should always return an accurate result indicating when an ipc request for plugin geometry updates was sent. r=roc (311e65a8ce) - Bug 1214267 - Send the side to which fixed-pos items are attached so that we can move them in the compositor more correctly when the viewport size is changing. r=mattwoodrow (fa2de207cd) - Bug 1209964 - In AlignFixedAndStickyLayers(), properly handle the case where a fixed or sticky layer is its own subtree root and has a local transform. r=kats (1a6922699a) - Bug 1213762 - Clear AsyncCompositionManager::mIsFirstPaint on non-Android platforms, too. r=mstange (c4cf2b722a) - Bug 1223436 - Fix AsyncCompositionManager so that mLayersUpdated is only set to false after SyncFrameMetrics has been called. r=kats (f3fa84325b) - bits of 1073545 (3bc7d76081) - Bug 1213795, Part 1: Don't fire timers in the Nuwa process to fix test case test_NuwaProcessDeadlock.html. r=khuey (5ebca946e5) - Bug 1213795, Part 2: Fix protocol cloning of actor CrossProcessCompositorParent. r=khuey (92969e2b06) - spacing (f4857ed898) - Bug 1213758 - Aquire the inderect layer trees data lock during plugin window update calculations. r=matt.woodrow (ae70d955ec) - Bug 1208502 - Use more smart pointers in XULDocument. r=smaug (20a92d72e8) - Bug 1193086 - Remove some null checks of infallible new code in XUL. r=baku (2f463c5a3d) - Bug 1217190 - Make PrintingParent return an nsresult when attempting to show print progress. r=bobowen (addf31f3a7) - Bug 1217190 - Make sure to initialize outparam in PrintingParent::RecvShowProgress. r=bobowen (f6c11a0181) - Bug 1152921 - Don't send an uninitialized PrintData over IPC when cancelling print dialog (or failing ShowPrintDialog for other reasons). r=mconley (4ea146ccf1) - Bug 1178233 - [non-e10s] The update process doesn't work within about:serviceworkers in non-e10s mode. r=baku (7a08441bec) - Bug 929846 - Considering key size when calculating quota usage. r=jdm (a97ddc7906) - Bug 1194049 - Part 3: support device update; r=fabrice (6ba600a03d) - Bug 1194049 - Part 1: add thread assertion; r=schien (68c4658ae0) - Bug 1194049 - Part 2: add discovery timeout support; r=schien (14f5f537d5) - Bug 1194049 - Part 4: clear discovered devices when re-discover; r=schien (e2ecdb573f) - Bug 1136565 - report session request from device provider. r=xeonchen,junior,seanlin. (19daa67751) - Bug 1216398 - support non-discoverable controlling device. r=junior,xeonchen. (7383401dbc) - Bug 1200132 - Use adderss to create socketTransport, r=schien, junior (263d253562) - Bug 1200132 - Part1: Get address info after service resolved, r=mcmanus (9bcc344d20) - Bug 1200132 - Part2: Get IP address by calling InetAddress.getHostAddress(), r=mcmanus, rnewman (502c243314) - Bug 1173334: Open nfcd connections with socket type SOCK_SEQPACKET, allstars.chh (03a11dc077) - Bug 1173802: Move NFC socket and messaging code into |NfcConsumer|, r=allstars.chh (f92946b40e) - Bug 1173802: Run |NfcConsumer| on NFC thread, r=allstars.chh (87989483a7) - Bug 1173802: Clean up |NfcEventDispatcher|, r=allstars.chh (87f58b7310) - Bug 1173802: Replace |assertIsNfcServiceThread| with thread-safe checks, r=allstars.chh (1a6a76ae05) - Bug 1173802: Store global NFC service in ref-counted variable, r=allstars.chh (a33c025976) - Bug 1188639 - Fix typo in BrowserElement.webidl and add tests for it. r=yoshi,bz (7b657a335d) - Bug 1175387 - close file descriptor after detached from STS. r=mcmanus (377943bad5) - Bug 1190069 - Fix uninitialized variable in MDNSResponderOperator.cpp. r=xeonchen (ebf47b613e) - Bug 1217807 - Part 1: use ServiceWatcher to extend life cycle of mDNS operators; r=schien (70201259d2) - missing namespace (c6bccda1e5) - Bug 1209843 - Stop checking for UNKNOWN_APP_ID in all places except those where AppId() is explicitly queried. r=sicking (e364223906) - Bug 1168337: Kill the processes on startup of the Nuwa test case fix the abort in the preallocated process. r=khuey (501a30cb9b) - Bug 1202424 - Free shared memory when IPC system shuts down, not after. r=mrbkap (f718cbf801) - Bug 1209987 - webrtc.org Engine creation and destruction should happen on the WebRTC threads. r=jesup (4bbab795cf) - Bug 1214675 - Factor out cleanup functions to avoid deadlock/dispatch-without-IPC. r=jesup (bd466c85e4) - Bug 1210560 - Part 2: Convert some simple users to use PushGroupForBlendBack. r=jrmuizel (158b532f9f) - Bug 1174785 - Part 0: Use mozilla/StaticPtr.h in signaling. r=jesup (c98ec23ee0) - Bug 1174785 - Part 1: Add LogModule, LogModuleManager, and LazyLogModule. r=froydnj (e797bca424) - Bug 1195867 - Hoist StateWatching and StateMirroring into XPCOM. r=froydnj (a62fbbf749) - Bug 1194631 - Make firefox build with --disable-logging. r=jrmuizel (ba8238dc42) - Bug 1174785 - Part 2: Convert xpcom over to LogModule. r=froydnj (ccb119d496) - Bug 1205237 - Part 2: add PresentationNetworkHelper; r=schien (be47702ffe) - Bug 1205237 - Part 3: get self Wi-Fi IP address; r=seanlin (f31163e895) - Bug 1217683 - Add sendIceCandidate and implement |close(aReason)| in TCPControlChannel. r=fabrice (0004ea93f1) - Bug 1217807 - Part 2: Handle network online/offline event in TCPPresentationServer; r=junior (48c9236adb) - Bug 1217807 - disable MDNS discovery. r=xeonchen. (ee3cb0ddb6)
1568 lines
45 KiB
C++
1568 lines
45 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/. */
|
|
|
|
/*
|
|
* A base class which implements nsIImageLoadingContent and can be
|
|
* subclassed by various content nodes that want to provide image
|
|
* loading functionality (eg <img>, <object>, etc).
|
|
*/
|
|
|
|
#include "nsImageLoadingContent.h"
|
|
#include "nsAutoPtr.h"
|
|
#include "nsError.h"
|
|
#include "nsIContent.h"
|
|
#include "nsIDocument.h"
|
|
#include "nsIScriptGlobalObject.h"
|
|
#include "nsIDOMWindow.h"
|
|
#include "nsServiceManagerUtils.h"
|
|
#include "nsContentPolicyUtils.h"
|
|
#include "nsIURI.h"
|
|
#include "nsILoadGroup.h"
|
|
#include "imgIContainer.h"
|
|
#include "imgLoader.h"
|
|
#include "imgRequestProxy.h"
|
|
#include "nsThreadUtils.h"
|
|
#include "nsNetUtil.h"
|
|
#include "nsImageFrame.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIChannel.h"
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIFrame.h"
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
#include "nsLayoutUtils.h"
|
|
#include "nsIContentPolicy.h"
|
|
#include "nsSVGEffects.h"
|
|
|
|
#include "gfxPrefs.h"
|
|
|
|
#include "mozAutoDocUpdate.h"
|
|
#include "mozilla/AsyncEventDispatcher.h"
|
|
#include "mozilla/EventStates.h"
|
|
#include "mozilla/dom/Element.h"
|
|
#include "mozilla/dom/ScriptSettings.h"
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#ifdef LoadImage
|
|
// Undefine LoadImage to prevent naming conflict with Windows.
|
|
#undef LoadImage
|
|
#endif
|
|
|
|
using namespace mozilla;
|
|
|
|
#ifdef DEBUG_chb
|
|
static void PrintReqURL(imgIRequest* req) {
|
|
if (!req) {
|
|
printf("(null req)\n");
|
|
return;
|
|
}
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
req->GetURI(getter_AddRefs(uri));
|
|
if (!uri) {
|
|
printf("(null uri)\n");
|
|
return;
|
|
}
|
|
|
|
nsAutoCString spec;
|
|
uri->GetSpec(spec);
|
|
printf("spec='%s'\n", spec.get());
|
|
}
|
|
#endif /* DEBUG_chb */
|
|
|
|
|
|
nsImageLoadingContent::nsImageLoadingContent()
|
|
: mCurrentRequestFlags(0),
|
|
mPendingRequestFlags(0),
|
|
mObserverList(nullptr),
|
|
mImageBlockingStatus(nsIContentPolicy::ACCEPT),
|
|
mLoadingEnabled(true),
|
|
mIsImageStateForced(false),
|
|
mLoading(false),
|
|
// mBroken starts out true, since an image without a URI is broken....
|
|
mBroken(true),
|
|
mUserDisabled(false),
|
|
mSuppressed(false),
|
|
mNewRequestsWillNeedAnimationReset(false),
|
|
mStateChangerDepth(0),
|
|
mCurrentRequestRegistered(false),
|
|
mPendingRequestRegistered(false),
|
|
mFrameCreateCalled(false),
|
|
mVisibleCount(0)
|
|
{
|
|
if (!nsContentUtils::GetImgLoaderForChannel(nullptr, nullptr)) {
|
|
mLoadingEnabled = false;
|
|
}
|
|
|
|
bool isInconsistent;
|
|
mMostRecentRequestChange = TimeStamp::ProcessCreation(isInconsistent);
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::DestroyImageLoadingContent()
|
|
{
|
|
// Cancel our requests so they won't hold stale refs to us
|
|
// NB: Don't ask to discard the images here.
|
|
ClearCurrentRequest(NS_BINDING_ABORTED, ON_NONVISIBLE_NO_ACTION);
|
|
ClearPendingRequest(NS_BINDING_ABORTED, ON_NONVISIBLE_NO_ACTION);
|
|
}
|
|
|
|
nsImageLoadingContent::~nsImageLoadingContent()
|
|
{
|
|
NS_ASSERTION(!mCurrentRequest && !mPendingRequest,
|
|
"DestroyImageLoadingContent not called");
|
|
NS_ASSERTION(!mObserverList.mObserver && !mObserverList.mNext,
|
|
"Observers still registered?");
|
|
}
|
|
|
|
/*
|
|
* imgINotificationObserver impl
|
|
*/
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::Notify(imgIRequest* aRequest,
|
|
int32_t aType,
|
|
const nsIntRect* aData)
|
|
{
|
|
if (aType == imgINotificationObserver::IS_ANIMATED) {
|
|
return OnImageIsAnimated(aRequest);
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::UNLOCKED_DRAW) {
|
|
OnUnlockedDraw();
|
|
return NS_OK;
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
|
|
// We should definitely have a request here
|
|
MOZ_ASSERT(aRequest, "no request?");
|
|
|
|
NS_PRECONDITION(aRequest == mCurrentRequest || aRequest == mPendingRequest,
|
|
"Unknown request");
|
|
}
|
|
|
|
{
|
|
// Calling Notify on observers can modify the list of observers so make
|
|
// a local copy.
|
|
nsAutoTArray<nsCOMPtr<imgINotificationObserver>, 2> observers;
|
|
|
|
for (ImageObserver* observer = &mObserverList, *next; observer;
|
|
observer = next) {
|
|
next = observer->mNext;
|
|
if (observer->mObserver) {
|
|
observers.AppendElement(observer->mObserver);
|
|
}
|
|
}
|
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
|
|
|
for (auto& observer : observers) {
|
|
observer->Notify(aRequest, aType, aData);
|
|
}
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
|
|
// Have to check for state changes here, since we might have been in
|
|
// the LOADING state before.
|
|
UpdateImageState(true);
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
|
|
uint32_t reqStatus;
|
|
aRequest->GetImageStatus(&reqStatus);
|
|
/* triage STATUS_ERROR */
|
|
if (reqStatus & imgIRequest::STATUS_ERROR) {
|
|
nsresult errorCode = NS_OK;
|
|
aRequest->GetImageErrorCode(&errorCode);
|
|
|
|
/* Handle image not loading error because source was a tracking URL.
|
|
* We make a note of this image node by including it in a dedicated
|
|
* array of blocked tracking nodes under its parent document.
|
|
*/
|
|
if (errorCode == NS_ERROR_TRACKING_URI) {
|
|
nsCOMPtr<nsIContent> thisNode
|
|
= do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
nsIDocument *doc = GetOurOwnerDoc();
|
|
doc->AddBlockedTrackingNode(thisNode);
|
|
}
|
|
}
|
|
nsresult status =
|
|
reqStatus & imgIRequest::STATUS_ERROR ? NS_ERROR_FAILURE : NS_OK;
|
|
return OnLoadComplete(aRequest, status);
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::DECODE_COMPLETE) {
|
|
nsCOMPtr<imgIContainer> container;
|
|
aRequest->GetImage(getter_AddRefs(container));
|
|
if (container) {
|
|
container->PropagateUseCounters(GetOurOwnerDoc());
|
|
}
|
|
|
|
UpdateImageState(true);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult
|
|
nsImageLoadingContent::OnLoadComplete(imgIRequest* aRequest, nsresult aStatus)
|
|
{
|
|
uint32_t oldStatus;
|
|
aRequest->GetImageStatus(&oldStatus);
|
|
|
|
//XXXjdm This occurs when we have a pending request created, then another
|
|
// pending request replaces it before the first one is finished.
|
|
// This begs the question of what the correct behaviour is; we used
|
|
// to not have to care because we ran this code in OnStopDecode which
|
|
// wasn't called when the first request was cancelled. For now, I choose
|
|
// to punt when the given request doesn't appear to have terminated in
|
|
// an expected state.
|
|
if (!(oldStatus & (imgIRequest::STATUS_ERROR | imgIRequest::STATUS_LOAD_COMPLETE)))
|
|
return NS_OK;
|
|
|
|
// Our state may change. Watch it.
|
|
AutoStateChanger changer(this, true);
|
|
|
|
// If the pending request is loaded, switch to it.
|
|
if (aRequest == mPendingRequest) {
|
|
MakePendingRequestCurrent();
|
|
}
|
|
MOZ_ASSERT(aRequest == mCurrentRequest,
|
|
"One way or another, we should be current by now");
|
|
|
|
// Fire the appropriate DOM event.
|
|
if (NS_SUCCEEDED(aStatus)) {
|
|
FireEvent(NS_LITERAL_STRING("load"));
|
|
} else {
|
|
FireEvent(NS_LITERAL_STRING("error"));
|
|
}
|
|
|
|
nsCOMPtr<nsINode> thisNode = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
nsSVGEffects::InvalidateDirectRenderingObservers(thisNode->AsElement());
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
static bool
|
|
ImageIsAnimated(imgIRequest* aRequest)
|
|
{
|
|
if (!aRequest) {
|
|
return false;
|
|
}
|
|
|
|
nsCOMPtr<imgIContainer> image;
|
|
if (NS_SUCCEEDED(aRequest->GetImage(getter_AddRefs(image)))) {
|
|
bool isAnimated = false;
|
|
nsresult rv = image->GetAnimated(&isAnimated);
|
|
if (NS_SUCCEEDED(rv) && isAnimated) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::OnUnlockedDraw()
|
|
{
|
|
if (mVisibleCount > 0) {
|
|
// We should already be marked as visible, there is nothing more we can do.
|
|
return;
|
|
}
|
|
|
|
// It's OK for non-animated images to wait until the next image visibility
|
|
// update to become locked. (And that's preferable, since in the case of
|
|
// scrolling it keeps memory usage minimal.) For animated images, though, we
|
|
// want to mark them visible right away so we can call
|
|
// IncrementAnimationConsumers() on them and they'll start animating.
|
|
if (!ImageIsAnimated(mCurrentRequest) && !ImageIsAnimated(mPendingRequest)) {
|
|
return;
|
|
}
|
|
|
|
nsPresContext* presContext = GetFramePresContext();
|
|
if (!presContext)
|
|
return;
|
|
|
|
nsIPresShell* presShell = presContext->PresShell();
|
|
if (!presShell)
|
|
return;
|
|
|
|
presShell->EnsureImageInVisibleList(this);
|
|
}
|
|
|
|
nsresult
|
|
nsImageLoadingContent::OnImageIsAnimated(imgIRequest *aRequest)
|
|
{
|
|
bool* requestFlag = GetRegisteredFlagForRequest(aRequest);
|
|
if (requestFlag) {
|
|
nsLayoutUtils::RegisterImageRequest(GetFramePresContext(),
|
|
aRequest, requestFlag);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
/*
|
|
* nsIImageLoadingContent impl
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::GetLoadingEnabled(bool *aLoadingEnabled)
|
|
{
|
|
*aLoadingEnabled = mLoadingEnabled;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::SetLoadingEnabled(bool aLoadingEnabled)
|
|
{
|
|
if (nsContentUtils::GetImgLoaderForChannel(nullptr, nullptr)) {
|
|
mLoadingEnabled = aLoadingEnabled;
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::GetImageBlockingStatus(int16_t* aStatus)
|
|
{
|
|
NS_PRECONDITION(aStatus, "Null out param");
|
|
*aStatus = ImageBlockingStatus();
|
|
return NS_OK;
|
|
}
|
|
|
|
static void
|
|
ReplayImageStatus(imgIRequest* aRequest, imgINotificationObserver* aObserver)
|
|
{
|
|
if (!aRequest) {
|
|
return;
|
|
}
|
|
|
|
uint32_t status = 0;
|
|
nsresult rv = aRequest->GetImageStatus(&status);
|
|
if (NS_FAILED(rv)) {
|
|
return;
|
|
}
|
|
|
|
if (status & imgIRequest::STATUS_SIZE_AVAILABLE) {
|
|
aObserver->Notify(aRequest, imgINotificationObserver::SIZE_AVAILABLE, nullptr);
|
|
}
|
|
if (status & imgIRequest::STATUS_FRAME_COMPLETE) {
|
|
aObserver->Notify(aRequest, imgINotificationObserver::FRAME_COMPLETE, nullptr);
|
|
}
|
|
if (status & imgIRequest::STATUS_HAS_TRANSPARENCY) {
|
|
aObserver->Notify(aRequest, imgINotificationObserver::HAS_TRANSPARENCY, nullptr);
|
|
}
|
|
if (status & imgIRequest::STATUS_IS_ANIMATED) {
|
|
aObserver->Notify(aRequest, imgINotificationObserver::IS_ANIMATED, nullptr);
|
|
}
|
|
if (status & imgIRequest::STATUS_DECODE_COMPLETE) {
|
|
aObserver->Notify(aRequest, imgINotificationObserver::DECODE_COMPLETE, nullptr);
|
|
}
|
|
if (status & imgIRequest::STATUS_LOAD_COMPLETE) {
|
|
aObserver->Notify(aRequest, imgINotificationObserver::LOAD_COMPLETE, nullptr);
|
|
}
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::AddObserver(imgINotificationObserver* aObserver)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aObserver);
|
|
|
|
if (!mObserverList.mObserver) {
|
|
// Don't touch the linking of the list!
|
|
mObserverList.mObserver = aObserver;
|
|
|
|
ReplayImageStatus(mCurrentRequest, aObserver);
|
|
ReplayImageStatus(mPendingRequest, aObserver);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
// otherwise we have to create a new entry
|
|
|
|
ImageObserver* observer = &mObserverList;
|
|
while (observer->mNext) {
|
|
observer = observer->mNext;
|
|
}
|
|
|
|
observer->mNext = new ImageObserver(aObserver);
|
|
if (! observer->mNext) {
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
}
|
|
|
|
ReplayImageStatus(mCurrentRequest, aObserver);
|
|
ReplayImageStatus(mPendingRequest, aObserver);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::RemoveObserver(imgINotificationObserver* aObserver)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aObserver);
|
|
|
|
if (mObserverList.mObserver == aObserver) {
|
|
mObserverList.mObserver = nullptr;
|
|
// Don't touch the linking of the list!
|
|
return NS_OK;
|
|
}
|
|
|
|
// otherwise have to find it and splice it out
|
|
ImageObserver* observer = &mObserverList;
|
|
while (observer->mNext && observer->mNext->mObserver != aObserver) {
|
|
observer = observer->mNext;
|
|
}
|
|
|
|
// At this point, we are pointing to the list element whose mNext is
|
|
// the right observer (assuming of course that mNext is not null)
|
|
if (observer->mNext) {
|
|
// splice it out
|
|
ImageObserver* oldObserver = observer->mNext;
|
|
observer->mNext = oldObserver->mNext;
|
|
oldObserver->mNext = nullptr; // so we don't destroy them all
|
|
delete oldObserver;
|
|
}
|
|
#ifdef DEBUG
|
|
else {
|
|
NS_WARNING("Asked to remove nonexistent observer");
|
|
}
|
|
#endif
|
|
return NS_OK;
|
|
}
|
|
|
|
already_AddRefed<imgIRequest>
|
|
nsImageLoadingContent::GetRequest(int32_t aRequestType,
|
|
ErrorResult& aError)
|
|
{
|
|
nsCOMPtr<imgIRequest> request;
|
|
switch(aRequestType) {
|
|
case CURRENT_REQUEST:
|
|
request = mCurrentRequest;
|
|
break;
|
|
case PENDING_REQUEST:
|
|
request = mPendingRequest;
|
|
break;
|
|
default:
|
|
NS_ERROR("Unknown request type");
|
|
aError.Throw(NS_ERROR_UNEXPECTED);
|
|
}
|
|
|
|
return request.forget();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::GetRequest(int32_t aRequestType,
|
|
imgIRequest** aRequest)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aRequest);
|
|
|
|
ErrorResult result;
|
|
*aRequest = GetRequest(aRequestType, result).take();
|
|
|
|
return result.StealNSResult();
|
|
}
|
|
|
|
NS_IMETHODIMP_(bool)
|
|
nsImageLoadingContent::CurrentRequestHasSize()
|
|
{
|
|
return HaveSize(mCurrentRequest);
|
|
}
|
|
|
|
NS_IMETHODIMP_(void)
|
|
nsImageLoadingContent::FrameCreated(nsIFrame* aFrame)
|
|
{
|
|
NS_ASSERTION(aFrame, "aFrame is null");
|
|
|
|
mFrameCreateCalled = true;
|
|
|
|
if (aFrame->HasAnyStateBits(NS_FRAME_IN_POPUP)) {
|
|
// Assume all images in popups are visible.
|
|
IncrementVisibleCount();
|
|
}
|
|
|
|
TrackImage(mCurrentRequest);
|
|
TrackImage(mPendingRequest);
|
|
|
|
// We need to make sure that our image request is registered, if it should
|
|
// be registered.
|
|
nsPresContext* presContext = aFrame->PresContext();
|
|
if (mCurrentRequest) {
|
|
nsLayoutUtils::RegisterImageRequestIfAnimated(presContext, mCurrentRequest,
|
|
&mCurrentRequestRegistered);
|
|
}
|
|
|
|
if (mPendingRequest) {
|
|
nsLayoutUtils::RegisterImageRequestIfAnimated(presContext, mPendingRequest,
|
|
&mPendingRequestRegistered);
|
|
}
|
|
}
|
|
|
|
NS_IMETHODIMP_(void)
|
|
nsImageLoadingContent::FrameDestroyed(nsIFrame* aFrame)
|
|
{
|
|
NS_ASSERTION(aFrame, "aFrame is null");
|
|
|
|
mFrameCreateCalled = false;
|
|
|
|
// We need to make sure that our image request is deregistered.
|
|
nsPresContext* presContext = GetFramePresContext();
|
|
if (mCurrentRequest) {
|
|
nsLayoutUtils::DeregisterImageRequest(presContext,
|
|
mCurrentRequest,
|
|
&mCurrentRequestRegistered);
|
|
}
|
|
|
|
if (mPendingRequest) {
|
|
nsLayoutUtils::DeregisterImageRequest(presContext,
|
|
mPendingRequest,
|
|
&mPendingRequestRegistered);
|
|
}
|
|
|
|
UntrackImage(mCurrentRequest);
|
|
UntrackImage(mPendingRequest);
|
|
|
|
nsIPresShell* presShell = presContext ? presContext->GetPresShell() : nullptr;
|
|
if (presShell) {
|
|
presShell->RemoveImageFromVisibleList(this);
|
|
}
|
|
|
|
if (aFrame->HasAnyStateBits(NS_FRAME_IN_POPUP)) {
|
|
// We assume all images in popups are visible, so this decrement balances
|
|
// out the increment in FrameCreated above.
|
|
DecrementVisibleCount(ON_NONVISIBLE_NO_ACTION);
|
|
}
|
|
}
|
|
|
|
/* static */
|
|
nsContentPolicyType
|
|
nsImageLoadingContent::PolicyTypeForLoad(ImageLoadType aImageLoadType)
|
|
{
|
|
if (aImageLoadType == eImageLoadType_Imageset) {
|
|
return nsIContentPolicy::TYPE_IMAGESET;
|
|
}
|
|
|
|
MOZ_ASSERT(aImageLoadType == eImageLoadType_Normal,
|
|
"Unknown ImageLoadType type in PolicyTypeForLoad");
|
|
return nsIContentPolicy::TYPE_INTERNAL_IMAGE;
|
|
}
|
|
|
|
int32_t
|
|
nsImageLoadingContent::GetRequestType(imgIRequest* aRequest,
|
|
ErrorResult& aError)
|
|
{
|
|
if (aRequest == mCurrentRequest) {
|
|
return CURRENT_REQUEST;
|
|
}
|
|
|
|
if (aRequest == mPendingRequest) {
|
|
return PENDING_REQUEST;
|
|
}
|
|
|
|
NS_ERROR("Unknown request");
|
|
aError.Throw(NS_ERROR_UNEXPECTED);
|
|
return UNKNOWN_REQUEST;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::GetRequestType(imgIRequest* aRequest,
|
|
int32_t* aRequestType)
|
|
{
|
|
NS_PRECONDITION(aRequestType, "Null out param");
|
|
|
|
ErrorResult result;
|
|
*aRequestType = GetRequestType(aRequest, result);
|
|
return result.StealNSResult();
|
|
}
|
|
|
|
already_AddRefed<nsIURI>
|
|
nsImageLoadingContent::GetCurrentURI(ErrorResult& aError)
|
|
{
|
|
nsCOMPtr<nsIURI> uri;
|
|
if (mCurrentRequest) {
|
|
mCurrentRequest->GetURI(getter_AddRefs(uri));
|
|
} else if (mCurrentURI) {
|
|
nsresult rv = NS_EnsureSafeToReturn(mCurrentURI, getter_AddRefs(uri));
|
|
if (NS_FAILED(rv)) {
|
|
aError.Throw(rv);
|
|
}
|
|
}
|
|
|
|
return uri.forget();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::GetCurrentURI(nsIURI** aURI)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aURI);
|
|
|
|
ErrorResult result;
|
|
*aURI = GetCurrentURI(result).take();
|
|
return result.StealNSResult();
|
|
}
|
|
|
|
already_AddRefed<nsIStreamListener>
|
|
nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
|
|
ErrorResult& aError)
|
|
{
|
|
imgLoader* loader =
|
|
nsContentUtils::GetImgLoaderForChannel(aChannel, GetOurOwnerDoc());
|
|
if (!loader) {
|
|
aError.Throw(NS_ERROR_NULL_POINTER);
|
|
return nullptr;
|
|
}
|
|
|
|
nsCOMPtr<nsIDocument> doc = GetOurOwnerDoc();
|
|
if (!doc) {
|
|
// Don't bother
|
|
return nullptr;
|
|
}
|
|
|
|
// XXX what should we do with content policies here, if anything?
|
|
// Shouldn't that be done before the start of the load?
|
|
// XXX what about shouldProcess?
|
|
|
|
// Our state might change. Watch it.
|
|
AutoStateChanger changer(this, true);
|
|
|
|
// Do the load.
|
|
nsCOMPtr<nsIStreamListener> listener;
|
|
RefPtr<imgRequestProxy>& req = PrepareNextRequest(eImageLoadType_Normal);
|
|
nsresult rv = loader->
|
|
LoadImageWithChannel(aChannel, this, doc,
|
|
getter_AddRefs(listener),
|
|
getter_AddRefs(req));
|
|
if (NS_SUCCEEDED(rv)) {
|
|
TrackImage(req);
|
|
ResetAnimationIfNeeded();
|
|
} else {
|
|
MOZ_ASSERT(!req, "Shouldn't have non-null request here");
|
|
// If we don't have a current URI, we might as well store this URI so people
|
|
// know what we tried (and failed) to load.
|
|
if (!mCurrentRequest)
|
|
aChannel->GetURI(getter_AddRefs(mCurrentURI));
|
|
FireEvent(NS_LITERAL_STRING("error"));
|
|
aError.Throw(rv);
|
|
}
|
|
return listener.forget();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
|
|
nsIStreamListener** aListener)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aListener);
|
|
|
|
ErrorResult result;
|
|
*aListener = LoadImageWithChannel(aChannel, result).take();
|
|
return result.StealNSResult();
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::ForceReload(const mozilla::dom::Optional<bool>& aNotify,
|
|
mozilla::ErrorResult& aError)
|
|
{
|
|
nsCOMPtr<nsIURI> currentURI;
|
|
GetCurrentURI(getter_AddRefs(currentURI));
|
|
if (!currentURI) {
|
|
aError.Throw(NS_ERROR_NOT_AVAILABLE);
|
|
return;
|
|
}
|
|
|
|
// defaults to true
|
|
bool notify = !aNotify.WasPassed() || aNotify.Value();
|
|
|
|
// We keep this flag around along with the old URI even for failed requests
|
|
// without a live request object
|
|
ImageLoadType loadType = \
|
|
(mCurrentRequestFlags & REQUEST_IS_IMAGESET) ? eImageLoadType_Imageset
|
|
: eImageLoadType_Normal;
|
|
nsresult rv = LoadImage(currentURI, true, notify, loadType, nullptr,
|
|
nsIRequest::VALIDATE_ALWAYS);
|
|
if (NS_FAILED(rv)) {
|
|
aError.Throw(rv);
|
|
}
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::ForceReload(bool aNotify /* = true */,
|
|
uint8_t aArgc)
|
|
{
|
|
mozilla::dom::Optional<bool> notify;
|
|
if (aArgc >= 1) {
|
|
notify.Construct() = aNotify;
|
|
}
|
|
|
|
ErrorResult result;
|
|
ForceReload(notify, result);
|
|
return result.StealNSResult();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::BlockOnload(imgIRequest* aRequest)
|
|
{
|
|
if (aRequest == mCurrentRequest) {
|
|
NS_ASSERTION(!(mCurrentRequestFlags & REQUEST_BLOCKS_ONLOAD),
|
|
"Double BlockOnload!?");
|
|
mCurrentRequestFlags |= REQUEST_BLOCKS_ONLOAD;
|
|
} else if (aRequest == mPendingRequest) {
|
|
NS_ASSERTION(!(mPendingRequestFlags & REQUEST_BLOCKS_ONLOAD),
|
|
"Double BlockOnload!?");
|
|
mPendingRequestFlags |= REQUEST_BLOCKS_ONLOAD;
|
|
} else {
|
|
return NS_OK;
|
|
}
|
|
|
|
nsIDocument* doc = GetOurCurrentDoc();
|
|
if (doc) {
|
|
doc->BlockOnload();
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::UnblockOnload(imgIRequest* aRequest)
|
|
{
|
|
if (aRequest == mCurrentRequest) {
|
|
NS_ASSERTION(mCurrentRequestFlags & REQUEST_BLOCKS_ONLOAD,
|
|
"Double UnblockOnload!?");
|
|
mCurrentRequestFlags &= ~REQUEST_BLOCKS_ONLOAD;
|
|
} else if (aRequest == mPendingRequest) {
|
|
NS_ASSERTION(mPendingRequestFlags & REQUEST_BLOCKS_ONLOAD,
|
|
"Double UnblockOnload!?");
|
|
mPendingRequestFlags &= ~REQUEST_BLOCKS_ONLOAD;
|
|
} else {
|
|
return NS_OK;
|
|
}
|
|
|
|
nsIDocument* doc = GetOurCurrentDoc();
|
|
if (doc) {
|
|
doc->UnblockOnload(false);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::IncrementVisibleCount()
|
|
{
|
|
mVisibleCount++;
|
|
if (mVisibleCount == 1) {
|
|
TrackImage(mCurrentRequest);
|
|
TrackImage(mPendingRequest);
|
|
}
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::DecrementVisibleCount(uint32_t aNonvisibleAction)
|
|
{
|
|
NS_ASSERTION(mVisibleCount > 0, "visible count should be positive here");
|
|
mVisibleCount--;
|
|
|
|
if (mVisibleCount == 0) {
|
|
UntrackImage(mCurrentRequest, aNonvisibleAction);
|
|
UntrackImage(mPendingRequest, aNonvisibleAction);
|
|
}
|
|
}
|
|
|
|
uint32_t
|
|
nsImageLoadingContent::GetVisibleCount()
|
|
{
|
|
return mVisibleCount;
|
|
}
|
|
|
|
/*
|
|
* Non-interface methods
|
|
*/
|
|
|
|
nsresult
|
|
nsImageLoadingContent::LoadImage(const nsAString& aNewURI,
|
|
bool aForce,
|
|
bool aNotify,
|
|
ImageLoadType aImageLoadType)
|
|
{
|
|
// First, get a document (needed for security checks and the like)
|
|
nsIDocument* doc = GetOurOwnerDoc();
|
|
if (!doc) {
|
|
// No reason to bother, I think...
|
|
return NS_OK;
|
|
}
|
|
|
|
nsCOMPtr<nsIURI> imageURI;
|
|
nsresult rv = StringToURI(aNewURI, doc, getter_AddRefs(imageURI));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
// XXXbiesi fire onerror if that failed?
|
|
|
|
bool equal;
|
|
|
|
if (aNewURI.IsEmpty() &&
|
|
doc->GetDocumentURI() &&
|
|
NS_SUCCEEDED(doc->GetDocumentURI()->EqualsExceptRef(imageURI, &equal)) &&
|
|
equal) {
|
|
|
|
// Loading an embedded img from the same URI as the document URI will not work
|
|
// as a resource cannot recursively embed itself. Attempting to do so generally
|
|
// results in having to pre-emptively close down an in-flight HTTP transaction
|
|
// and then incurring the significant cost of establishing a new TCP channel.
|
|
// This is generally triggered from <img src="">
|
|
// In light of that, just skip loading it..
|
|
// Do make sure to drop our existing image, if any
|
|
CancelImageRequests(aNotify);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_TryToSetImmutable(imageURI);
|
|
|
|
return LoadImage(imageURI, aForce, aNotify, aImageLoadType, doc);
|
|
}
|
|
|
|
nsresult
|
|
nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
|
|
bool aForce,
|
|
bool aNotify,
|
|
ImageLoadType aImageLoadType,
|
|
nsIDocument* aDocument,
|
|
nsLoadFlags aLoadFlags)
|
|
{
|
|
if (!mLoadingEnabled) {
|
|
// XXX Why fire an error here? seems like the callers to SetLoadingEnabled
|
|
// don't want/need it.
|
|
FireEvent(NS_LITERAL_STRING("error"));
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_ASSERTION(!aDocument || aDocument == GetOurOwnerDoc(),
|
|
"Bogus document passed in");
|
|
// First, get a document (needed for security checks and the like)
|
|
if (!aDocument) {
|
|
aDocument = GetOurOwnerDoc();
|
|
if (!aDocument) {
|
|
// No reason to bother, I think...
|
|
return NS_OK;
|
|
}
|
|
}
|
|
|
|
// URI equality check.
|
|
//
|
|
// We skip the equality check if our current image was blocked, since in that
|
|
// case we really do want to try loading again.
|
|
if (!aForce && NS_CP_ACCEPTED(mImageBlockingStatus)) {
|
|
nsCOMPtr<nsIURI> currentURI;
|
|
GetCurrentURI(getter_AddRefs(currentURI));
|
|
bool equal;
|
|
if (currentURI &&
|
|
NS_SUCCEEDED(currentURI->Equals(aNewURI, &equal)) &&
|
|
equal) {
|
|
// Nothing to do here.
|
|
return NS_OK;
|
|
}
|
|
}
|
|
|
|
// From this point on, our image state could change. Watch it.
|
|
AutoStateChanger changer(this, aNotify);
|
|
|
|
// Sanity check.
|
|
//
|
|
// We use the principal of aDocument to avoid having to QI |this| an extra
|
|
// time. It should always be the same as the principal of this node.
|
|
#ifdef DEBUG
|
|
nsIContent* thisContent = AsContent();
|
|
MOZ_ASSERT(thisContent &&
|
|
thisContent->NodePrincipal() == aDocument->NodePrincipal(),
|
|
"Principal mismatch?");
|
|
#endif
|
|
|
|
// Are we blocked?
|
|
int16_t cpDecision = nsIContentPolicy::REJECT_REQUEST;
|
|
nsContentPolicyType policyType = PolicyTypeForLoad(aImageLoadType);
|
|
|
|
nsContentUtils::CanLoadImage(aNewURI,
|
|
static_cast<nsIImageLoadingContent*>(this),
|
|
aDocument,
|
|
aDocument->NodePrincipal(),
|
|
&cpDecision,
|
|
policyType);
|
|
if (!NS_CP_ACCEPTED(cpDecision)) {
|
|
FireEvent(NS_LITERAL_STRING("error"));
|
|
SetBlockedRequest(aNewURI, cpDecision);
|
|
return NS_OK;
|
|
}
|
|
|
|
nsLoadFlags loadFlags = aLoadFlags;
|
|
int32_t corsmode = GetCORSMode();
|
|
if (corsmode == CORS_ANONYMOUS) {
|
|
loadFlags |= imgILoader::LOAD_CORS_ANONYMOUS;
|
|
} else if (corsmode == CORS_USE_CREDENTIALS) {
|
|
loadFlags |= imgILoader::LOAD_CORS_USE_CREDENTIALS;
|
|
}
|
|
|
|
// get document wide referrer policy
|
|
// if referrer attributes are enabled in preferences, load img referrer attribute
|
|
// if the image does not provide a referrer attribute, ignore this
|
|
net::ReferrerPolicy referrerPolicy = aDocument->GetReferrerPolicy();
|
|
net::ReferrerPolicy imgReferrerPolicy = GetImageReferrerPolicy();
|
|
if (imgReferrerPolicy != net::RP_Unset) {
|
|
referrerPolicy = imgReferrerPolicy;
|
|
}
|
|
|
|
// Not blocked. Do the load.
|
|
RefPtr<imgRequestProxy>& req = PrepareNextRequest(aImageLoadType);
|
|
nsIContent* content = AsContent();
|
|
nsresult rv = nsContentUtils::LoadImage(aNewURI, aDocument,
|
|
aDocument->NodePrincipal(),
|
|
aDocument->GetDocumentURI(),
|
|
referrerPolicy,
|
|
this, loadFlags,
|
|
content->LocalName(),
|
|
getter_AddRefs(req),
|
|
policyType);
|
|
|
|
// Tell the document to forget about the image preload, if any, for
|
|
// this URI, now that we might have another imgRequestProxy for it.
|
|
// That way if we get canceled later the image load won't continue.
|
|
aDocument->ForgetImagePreload(aNewURI);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
TrackImage(req);
|
|
ResetAnimationIfNeeded();
|
|
|
|
// Handle cases when we just ended up with a pending request but it's
|
|
// already done. In that situation we have to synchronously switch that
|
|
// request to being the current request, because websites depend on that
|
|
// behavior.
|
|
if (req == mPendingRequest) {
|
|
uint32_t pendingLoadStatus;
|
|
rv = req->GetImageStatus(&pendingLoadStatus);
|
|
if (NS_SUCCEEDED(rv) &&
|
|
(pendingLoadStatus & imgIRequest::STATUS_LOAD_COMPLETE)) {
|
|
MakePendingRequestCurrent();
|
|
MOZ_ASSERT(mCurrentRequest,
|
|
"How could we not have a current request here?");
|
|
|
|
nsImageFrame *f = do_QueryFrame(GetOurPrimaryFrame());
|
|
if (f) {
|
|
f->NotifyNewCurrentRequest(mCurrentRequest, NS_OK);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
MOZ_ASSERT(!req, "Shouldn't have non-null request here");
|
|
// If we don't have a current URI, we might as well store this URI so people
|
|
// know what we tried (and failed) to load.
|
|
if (!mCurrentRequest)
|
|
mCurrentURI = aNewURI;
|
|
FireEvent(NS_LITERAL_STRING("error"));
|
|
return NS_OK;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult
|
|
nsImageLoadingContent::ForceImageState(bool aForce,
|
|
EventStates::InternalType aState)
|
|
{
|
|
mIsImageStateForced = aForce;
|
|
mForcedImageState = EventStates(aState);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::GetNaturalWidth(uint32_t* aNaturalWidth)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aNaturalWidth);
|
|
|
|
nsCOMPtr<imgIContainer> image;
|
|
if (mCurrentRequest) {
|
|
mCurrentRequest->GetImage(getter_AddRefs(image));
|
|
}
|
|
|
|
int32_t width;
|
|
if (image && NS_SUCCEEDED(image->GetWidth(&width))) {
|
|
*aNaturalWidth = width;
|
|
} else {
|
|
*aNaturalWidth = 0;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsImageLoadingContent::GetNaturalHeight(uint32_t* aNaturalHeight)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aNaturalHeight);
|
|
|
|
nsCOMPtr<imgIContainer> image;
|
|
if (mCurrentRequest) {
|
|
mCurrentRequest->GetImage(getter_AddRefs(image));
|
|
}
|
|
|
|
int32_t height;
|
|
if (image && NS_SUCCEEDED(image->GetHeight(&height))) {
|
|
*aNaturalHeight = height;
|
|
} else {
|
|
*aNaturalHeight = 0;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
EventStates
|
|
nsImageLoadingContent::ImageState() const
|
|
{
|
|
if (mIsImageStateForced) {
|
|
return mForcedImageState;
|
|
}
|
|
|
|
EventStates states;
|
|
|
|
if (mBroken) {
|
|
states |= NS_EVENT_STATE_BROKEN;
|
|
}
|
|
if (mUserDisabled) {
|
|
states |= NS_EVENT_STATE_USERDISABLED;
|
|
}
|
|
if (mSuppressed) {
|
|
states |= NS_EVENT_STATE_SUPPRESSED;
|
|
}
|
|
if (mLoading) {
|
|
states |= NS_EVENT_STATE_LOADING;
|
|
}
|
|
|
|
return states;
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::UpdateImageState(bool aNotify)
|
|
{
|
|
if (mStateChangerDepth > 0) {
|
|
// Ignore this call; we'll update our state when the outermost state changer
|
|
// is destroyed. Need this to work around the fact that some ImageLib
|
|
// stuff is actually sync and hence we can get OnStopDecode called while
|
|
// we're still under LoadImage, and OnStopDecode doesn't know anything about
|
|
// aNotify.
|
|
// XXX - This machinery should be removed after bug 521604.
|
|
return;
|
|
}
|
|
|
|
nsIContent* thisContent = AsContent();
|
|
|
|
mLoading = mBroken = mUserDisabled = mSuppressed = false;
|
|
|
|
// If we were blocked by server-based content policy, we claim to be
|
|
// suppressed. If we were blocked by type-based content policy, we claim to
|
|
// be user-disabled. Otherwise, claim to be broken.
|
|
if (mImageBlockingStatus == nsIContentPolicy::REJECT_SERVER) {
|
|
mSuppressed = true;
|
|
} else if (mImageBlockingStatus == nsIContentPolicy::REJECT_TYPE) {
|
|
mUserDisabled = true;
|
|
} else if (!mCurrentRequest) {
|
|
// No current request means error, since we weren't disabled or suppressed
|
|
mBroken = true;
|
|
} else {
|
|
uint32_t currentLoadStatus;
|
|
nsresult rv = mCurrentRequest->GetImageStatus(¤tLoadStatus);
|
|
if (NS_FAILED(rv) || (currentLoadStatus & imgIRequest::STATUS_ERROR)) {
|
|
mBroken = true;
|
|
} else if (!(currentLoadStatus & imgIRequest::STATUS_SIZE_AVAILABLE)) {
|
|
mLoading = true;
|
|
}
|
|
}
|
|
|
|
NS_ASSERTION(thisContent->IsElement(), "Not an element?");
|
|
thisContent->AsElement()->UpdateState(aNotify);
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::CancelImageRequests(bool aNotify)
|
|
{
|
|
AutoStateChanger changer(this, aNotify);
|
|
ClearPendingRequest(NS_BINDING_ABORTED, ON_NONVISIBLE_REQUEST_DISCARD);
|
|
ClearCurrentRequest(NS_BINDING_ABORTED, ON_NONVISIBLE_REQUEST_DISCARD);
|
|
}
|
|
|
|
nsresult
|
|
nsImageLoadingContent::UseAsPrimaryRequest(imgRequestProxy* aRequest,
|
|
bool aNotify,
|
|
ImageLoadType aImageLoadType)
|
|
{
|
|
// Our state will change. Watch it.
|
|
AutoStateChanger changer(this, aNotify);
|
|
|
|
// Get rid if our existing images
|
|
ClearPendingRequest(NS_BINDING_ABORTED, ON_NONVISIBLE_REQUEST_DISCARD);
|
|
ClearCurrentRequest(NS_BINDING_ABORTED, ON_NONVISIBLE_REQUEST_DISCARD);
|
|
|
|
// Clone the request we were given.
|
|
RefPtr<imgRequestProxy>& req = PrepareNextRequest(aImageLoadType);
|
|
nsresult rv = aRequest->Clone(this, getter_AddRefs(req));
|
|
if (NS_SUCCEEDED(rv)) {
|
|
TrackImage(req);
|
|
} else {
|
|
MOZ_ASSERT(!req, "Shouldn't have non-null request here");
|
|
return rv;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
nsIDocument*
|
|
nsImageLoadingContent::GetOurOwnerDoc()
|
|
{
|
|
return AsContent()->OwnerDoc();
|
|
}
|
|
|
|
nsIDocument*
|
|
nsImageLoadingContent::GetOurCurrentDoc()
|
|
{
|
|
return AsContent()->GetComposedDoc();
|
|
}
|
|
|
|
nsIFrame*
|
|
nsImageLoadingContent::GetOurPrimaryFrame()
|
|
{
|
|
return AsContent()->GetPrimaryFrame();
|
|
}
|
|
|
|
nsPresContext* nsImageLoadingContent::GetFramePresContext()
|
|
{
|
|
nsIFrame* frame = GetOurPrimaryFrame();
|
|
if (!frame) {
|
|
return nullptr;
|
|
}
|
|
|
|
return frame->PresContext();
|
|
}
|
|
|
|
nsresult
|
|
nsImageLoadingContent::StringToURI(const nsAString& aSpec,
|
|
nsIDocument* aDocument,
|
|
nsIURI** aURI)
|
|
{
|
|
NS_PRECONDITION(aDocument, "Must have a document");
|
|
NS_PRECONDITION(aURI, "Null out param");
|
|
|
|
// (1) Get the base URI
|
|
nsIContent* thisContent = AsContent();
|
|
nsCOMPtr<nsIURI> baseURL = thisContent->GetBaseURI();
|
|
|
|
// (2) Get the charset
|
|
const nsAFlatCString &charset = aDocument->GetDocumentCharacterSet();
|
|
|
|
// (3) Construct the silly thing
|
|
return NS_NewURI(aURI,
|
|
aSpec,
|
|
charset.IsEmpty() ? nullptr : charset.get(),
|
|
baseURL,
|
|
nsContentUtils::GetIOService());
|
|
}
|
|
|
|
nsresult
|
|
nsImageLoadingContent::FireEvent(const nsAString& aEventType)
|
|
{
|
|
if (nsContentUtils::DocumentInactiveForImageLoads(GetOurOwnerDoc())) {
|
|
// Don't bother to fire any events, especially error events.
|
|
return NS_OK;
|
|
}
|
|
|
|
// We have to fire the event asynchronously so that we won't go into infinite
|
|
// loops in cases when onLoad handlers reset the src and the new src is in
|
|
// cache.
|
|
|
|
nsCOMPtr<nsINode> thisNode = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
RefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher =
|
|
new LoadBlockingAsyncEventDispatcher(thisNode, aEventType, false, false);
|
|
loadBlockingAsyncDispatcher->PostDOMEvent();
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
RefPtr<imgRequestProxy>&
|
|
nsImageLoadingContent::PrepareNextRequest(ImageLoadType aImageLoadType)
|
|
{
|
|
nsImageFrame* frame = do_QueryFrame(GetOurPrimaryFrame());
|
|
if (frame) {
|
|
// Detect JavaScript-based animations created by changing the |src|
|
|
// attribute on a timer.
|
|
TimeStamp now = TimeStamp::Now();
|
|
TimeDuration threshold =
|
|
TimeDuration::FromMilliseconds(
|
|
gfxPrefs::ImageInferSrcAnimationThresholdMS());
|
|
|
|
// If the length of time between request changes is less than the threshold,
|
|
// then force sync decoding to eliminate flicker from the animation.
|
|
frame->SetForceSyncDecoding(now - mMostRecentRequestChange < threshold);
|
|
|
|
mMostRecentRequestChange = now;
|
|
}
|
|
|
|
// If we don't have a usable current request, get rid of any half-baked
|
|
// request that might be sitting there and make this one current.
|
|
if (!HaveSize(mCurrentRequest))
|
|
return PrepareCurrentRequest(aImageLoadType);
|
|
|
|
// Otherwise, make it pending.
|
|
return PreparePendingRequest(aImageLoadType);
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::SetBlockedRequest(nsIURI* aURI, int16_t aContentDecision)
|
|
{
|
|
// Sanity
|
|
MOZ_ASSERT(!NS_CP_ACCEPTED(aContentDecision), "Blocked but not?");
|
|
|
|
// We do some slightly illogical stuff here to maintain consistency with
|
|
// old behavior that people probably depend on. Even in the case where the
|
|
// new image is blocked, the old one should really be canceled with the
|
|
// reason "image source changed". However, apparently there's some abuse
|
|
// over in nsImageFrame where the displaying of the "broken" icon for the
|
|
// next image depends on the cancel reason of the previous image. ugh.
|
|
ClearPendingRequest(NS_ERROR_IMAGE_BLOCKED, ON_NONVISIBLE_REQUEST_DISCARD);
|
|
|
|
// For the blocked case, we only want to cancel the existing current request
|
|
// if size is not available. bz says the web depends on this behavior.
|
|
if (!HaveSize(mCurrentRequest)) {
|
|
|
|
mImageBlockingStatus = aContentDecision;
|
|
uint32_t keepFlags = mCurrentRequestFlags & REQUEST_IS_IMAGESET;
|
|
ClearCurrentRequest(NS_ERROR_IMAGE_BLOCKED, ON_NONVISIBLE_REQUEST_DISCARD);
|
|
|
|
// We still want to remember what URI we were and if it was an imageset,
|
|
// despite not having an actual request. These are both cleared as part of
|
|
// ClearCurrentRequest() before a new request is started.
|
|
mCurrentURI = aURI;
|
|
mCurrentRequestFlags = keepFlags;
|
|
}
|
|
}
|
|
|
|
RefPtr<imgRequestProxy>&
|
|
nsImageLoadingContent::PrepareCurrentRequest(ImageLoadType aImageLoadType)
|
|
{
|
|
// Blocked images go through SetBlockedRequest, which is a separate path. For
|
|
// everything else, we're unblocked.
|
|
mImageBlockingStatus = nsIContentPolicy::ACCEPT;
|
|
|
|
// Get rid of anything that was there previously.
|
|
ClearCurrentRequest(NS_ERROR_IMAGE_SRC_CHANGED,
|
|
ON_NONVISIBLE_REQUEST_DISCARD);
|
|
|
|
if (mNewRequestsWillNeedAnimationReset) {
|
|
mCurrentRequestFlags |= REQUEST_NEEDS_ANIMATION_RESET;
|
|
}
|
|
|
|
if (aImageLoadType == eImageLoadType_Imageset) {
|
|
mCurrentRequestFlags |= REQUEST_IS_IMAGESET;
|
|
}
|
|
|
|
// Return a reference.
|
|
return mCurrentRequest;
|
|
}
|
|
|
|
RefPtr<imgRequestProxy>&
|
|
nsImageLoadingContent::PreparePendingRequest(ImageLoadType aImageLoadType)
|
|
{
|
|
// Get rid of anything that was there previously.
|
|
ClearPendingRequest(NS_ERROR_IMAGE_SRC_CHANGED,
|
|
ON_NONVISIBLE_REQUEST_DISCARD);
|
|
|
|
if (mNewRequestsWillNeedAnimationReset) {
|
|
mPendingRequestFlags |= REQUEST_NEEDS_ANIMATION_RESET;
|
|
}
|
|
|
|
if (aImageLoadType == eImageLoadType_Imageset) {
|
|
mPendingRequestFlags |= REQUEST_IS_IMAGESET;
|
|
}
|
|
|
|
// Return a reference.
|
|
return mPendingRequest;
|
|
}
|
|
|
|
namespace {
|
|
|
|
class ImageRequestAutoLock
|
|
{
|
|
public:
|
|
explicit ImageRequestAutoLock(imgIRequest* aRequest)
|
|
: mRequest(aRequest)
|
|
{
|
|
if (mRequest) {
|
|
mRequest->LockImage();
|
|
}
|
|
}
|
|
|
|
~ImageRequestAutoLock()
|
|
{
|
|
if (mRequest) {
|
|
mRequest->UnlockImage();
|
|
}
|
|
}
|
|
|
|
private:
|
|
nsCOMPtr<imgIRequest> mRequest;
|
|
};
|
|
|
|
} // namespace
|
|
|
|
void
|
|
nsImageLoadingContent::MakePendingRequestCurrent()
|
|
{
|
|
MOZ_ASSERT(mPendingRequest);
|
|
|
|
// Lock mCurrentRequest for the duration of this method. We do this because
|
|
// PrepareCurrentRequest() might unlock mCurrentRequest. If mCurrentRequest
|
|
// and mPendingRequest are both requests for the same image, unlocking
|
|
// mCurrentRequest before we lock mPendingRequest can cause the lock count
|
|
// to go to 0 and the image to be discarded!
|
|
ImageRequestAutoLock autoLock(mCurrentRequest);
|
|
|
|
ImageLoadType loadType = \
|
|
(mPendingRequestFlags & REQUEST_IS_IMAGESET) ? eImageLoadType_Imageset
|
|
: eImageLoadType_Normal;
|
|
|
|
PrepareCurrentRequest(loadType) = mPendingRequest;
|
|
mPendingRequest = nullptr;
|
|
mCurrentRequestFlags = mPendingRequestFlags;
|
|
mPendingRequestFlags = 0;
|
|
ResetAnimationIfNeeded();
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::ClearCurrentRequest(nsresult aReason,
|
|
uint32_t aNonvisibleAction)
|
|
{
|
|
if (!mCurrentRequest) {
|
|
// Even if we didn't have a current request, we might have been keeping
|
|
// a URI and flags as a placeholder for a failed load. Clear that now.
|
|
mCurrentURI = nullptr;
|
|
mCurrentRequestFlags = 0;
|
|
return;
|
|
}
|
|
MOZ_ASSERT(!mCurrentURI,
|
|
"Shouldn't have both mCurrentRequest and mCurrentURI!");
|
|
|
|
// Deregister this image from the refresh driver so it no longer receives
|
|
// notifications.
|
|
nsLayoutUtils::DeregisterImageRequest(GetFramePresContext(), mCurrentRequest,
|
|
&mCurrentRequestRegistered);
|
|
|
|
// Clean up the request.
|
|
UntrackImage(mCurrentRequest, aNonvisibleAction);
|
|
mCurrentRequest->CancelAndForgetObserver(aReason);
|
|
mCurrentRequest = nullptr;
|
|
mCurrentRequestFlags = 0;
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::ClearPendingRequest(nsresult aReason,
|
|
uint32_t aNonvisibleAction)
|
|
{
|
|
if (!mPendingRequest)
|
|
return;
|
|
|
|
// Deregister this image from the refresh driver so it no longer receives
|
|
// notifications.
|
|
nsLayoutUtils::DeregisterImageRequest(GetFramePresContext(), mPendingRequest,
|
|
&mPendingRequestRegistered);
|
|
|
|
UntrackImage(mPendingRequest, aNonvisibleAction);
|
|
mPendingRequest->CancelAndForgetObserver(aReason);
|
|
mPendingRequest = nullptr;
|
|
mPendingRequestFlags = 0;
|
|
}
|
|
|
|
bool*
|
|
nsImageLoadingContent::GetRegisteredFlagForRequest(imgIRequest* aRequest)
|
|
{
|
|
if (aRequest == mCurrentRequest) {
|
|
return &mCurrentRequestRegistered;
|
|
} else if (aRequest == mPendingRequest) {
|
|
return &mPendingRequestRegistered;
|
|
} else {
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::ResetAnimationIfNeeded()
|
|
{
|
|
if (mCurrentRequest &&
|
|
(mCurrentRequestFlags & REQUEST_NEEDS_ANIMATION_RESET)) {
|
|
nsCOMPtr<imgIContainer> container;
|
|
mCurrentRequest->GetImage(getter_AddRefs(container));
|
|
if (container)
|
|
container->ResetAnimation();
|
|
mCurrentRequestFlags &= ~REQUEST_NEEDS_ANIMATION_RESET;
|
|
}
|
|
}
|
|
|
|
bool
|
|
nsImageLoadingContent::HaveSize(imgIRequest *aImage)
|
|
{
|
|
// Handle the null case
|
|
if (!aImage)
|
|
return false;
|
|
|
|
// Query the image
|
|
uint32_t status;
|
|
nsresult rv = aImage->GetImageStatus(&status);
|
|
return (NS_SUCCEEDED(rv) && (status & imgIRequest::STATUS_SIZE_AVAILABLE));
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
nsIContent* aBindingParent,
|
|
bool aCompileEventHandlers)
|
|
{
|
|
// We may be entering the document, so if our image should be tracked,
|
|
// track it.
|
|
if (!aDocument)
|
|
return;
|
|
|
|
TrackImage(mCurrentRequest);
|
|
TrackImage(mPendingRequest);
|
|
|
|
if (mCurrentRequestFlags & REQUEST_BLOCKS_ONLOAD)
|
|
aDocument->BlockOnload();
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::UnbindFromTree(bool aDeep, bool aNullParent)
|
|
{
|
|
// We may be leaving the document, so if our image is tracked, untrack it.
|
|
nsCOMPtr<nsIDocument> doc = GetOurCurrentDoc();
|
|
if (!doc)
|
|
return;
|
|
|
|
UntrackImage(mCurrentRequest);
|
|
UntrackImage(mPendingRequest);
|
|
|
|
if (mCurrentRequestFlags & REQUEST_BLOCKS_ONLOAD)
|
|
doc->UnblockOnload(false);
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::TrackImage(imgIRequest* aImage)
|
|
{
|
|
if (!aImage)
|
|
return;
|
|
|
|
MOZ_ASSERT(aImage == mCurrentRequest || aImage == mPendingRequest,
|
|
"Why haven't we heard of this request?");
|
|
|
|
nsIDocument* doc = GetOurCurrentDoc();
|
|
if (doc && (mFrameCreateCalled || GetOurPrimaryFrame()) &&
|
|
(mVisibleCount > 0)) {
|
|
|
|
if (mVisibleCount == 1) {
|
|
// Since we're becoming visible, request a decode.
|
|
nsImageFrame* f = do_QueryFrame(GetOurPrimaryFrame());
|
|
if (f) {
|
|
f->MaybeDecodeForPredictedSize();
|
|
}
|
|
}
|
|
|
|
if (aImage == mCurrentRequest && !(mCurrentRequestFlags & REQUEST_IS_TRACKED)) {
|
|
mCurrentRequestFlags |= REQUEST_IS_TRACKED;
|
|
doc->AddImage(mCurrentRequest);
|
|
}
|
|
if (aImage == mPendingRequest && !(mPendingRequestFlags & REQUEST_IS_TRACKED)) {
|
|
mPendingRequestFlags |= REQUEST_IS_TRACKED;
|
|
doc->AddImage(mPendingRequest);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
nsImageLoadingContent::UntrackImage(imgIRequest* aImage,
|
|
uint32_t aNonvisibleAction
|
|
/* = ON_NONVISIBLE_NO_ACTION */)
|
|
{
|
|
if (!aImage)
|
|
return;
|
|
|
|
MOZ_ASSERT(aImage == mCurrentRequest || aImage == mPendingRequest,
|
|
"Why haven't we heard of this request?");
|
|
|
|
// We may not be in the document. If we outlived our document that's fine,
|
|
// because the document empties out the tracker and unlocks all locked images
|
|
// on destruction. But if we were never in the document we may need to force
|
|
// discarding the image here, since this is the only chance we have.
|
|
nsIDocument* doc = GetOurCurrentDoc();
|
|
if (aImage == mCurrentRequest) {
|
|
if (doc && (mCurrentRequestFlags & REQUEST_IS_TRACKED)) {
|
|
mCurrentRequestFlags &= ~REQUEST_IS_TRACKED;
|
|
doc->RemoveImage(mCurrentRequest,
|
|
(aNonvisibleAction == ON_NONVISIBLE_REQUEST_DISCARD)
|
|
? nsIDocument::REQUEST_DISCARD
|
|
: 0);
|
|
} else if (aNonvisibleAction == ON_NONVISIBLE_REQUEST_DISCARD) {
|
|
// If we're not in the document we may still need to be discarded.
|
|
aImage->RequestDiscard();
|
|
}
|
|
}
|
|
if (aImage == mPendingRequest) {
|
|
if (doc && (mPendingRequestFlags & REQUEST_IS_TRACKED)) {
|
|
mPendingRequestFlags &= ~REQUEST_IS_TRACKED;
|
|
doc->RemoveImage(mPendingRequest,
|
|
(aNonvisibleAction == ON_NONVISIBLE_REQUEST_DISCARD)
|
|
? nsIDocument::REQUEST_DISCARD
|
|
: 0);
|
|
} else if (aNonvisibleAction == ON_NONVISIBLE_REQUEST_DISCARD) {
|
|
// If we're not in the document we may still need to be discarded.
|
|
aImage->RequestDiscard();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void
|
|
nsImageLoadingContent::CreateStaticImageClone(nsImageLoadingContent* aDest) const
|
|
{
|
|
aDest->mCurrentRequest = nsContentUtils::GetStaticRequest(mCurrentRequest);
|
|
aDest->TrackImage(aDest->mCurrentRequest);
|
|
aDest->mForcedImageState = mForcedImageState;
|
|
aDest->mImageBlockingStatus = mImageBlockingStatus;
|
|
aDest->mLoadingEnabled = mLoadingEnabled;
|
|
aDest->mStateChangerDepth = mStateChangerDepth;
|
|
aDest->mIsImageStateForced = mIsImageStateForced;
|
|
aDest->mLoading = mLoading;
|
|
aDest->mBroken = mBroken;
|
|
aDest->mUserDisabled = mUserDisabled;
|
|
aDest->mSuppressed = mSuppressed;
|
|
}
|
|
|
|
CORSMode
|
|
nsImageLoadingContent::GetCORSMode()
|
|
{
|
|
return CORS_NONE;
|
|
}
|
|
|
|
nsImageLoadingContent::ImageObserver::ImageObserver(imgINotificationObserver* aObserver)
|
|
: mObserver(aObserver)
|
|
, mNext(nullptr)
|
|
{
|
|
MOZ_COUNT_CTOR(ImageObserver);
|
|
}
|
|
|
|
nsImageLoadingContent::ImageObserver::~ImageObserver()
|
|
{
|
|
MOZ_COUNT_DTOR(ImageObserver);
|
|
NS_CONTENT_DELETE_LIST_MEMBER(ImageObserver, this, mNext);
|
|
}
|
|
|
|
// Only HTMLInputElement.h overrides this for <img> tags
|
|
// all other subclasses use this one, i.e. ignore referrer attributes
|
|
mozilla::net::ReferrerPolicy
|
|
nsImageLoadingContent::GetImageReferrerPolicy()
|
|
{
|
|
return mozilla::net::RP_Unset;
|
|
};
|