PageRenderTime 56ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/mozilla/mozilla/dist/include/layout/nsIPresShell.h

http://kmbrasil.codeplex.com
C++ Header | 787 lines | 263 code | 111 blank | 413 comment | 0 complexity | 0a83644e16a119fc6eb27d732e0c3eda MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, GPL-2.0
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. * ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. * Steve Clark <buster@netscape.com>
  24. * Dan Rosen <dr@netscape.com>
  25. *
  26. * Alternatively, the contents of this file may be used under the terms of
  27. * either of the GNU General Public License Version 2 or later (the "GPL"),
  28. * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29. * in which case the provisions of the GPL or the LGPL are applicable instead
  30. * of those above. If you wish to allow use of your version of this file only
  31. * under the terms of either the GPL or the LGPL, and not to allow others to
  32. * use your version of this file under the terms of the MPL, indicate your
  33. * decision by deleting the provisions above and replace them with the notice
  34. * and other provisions required by the GPL or the LGPL. If you do not delete
  35. * the provisions above, a recipient may use your version of this file under
  36. * the terms of any one of the MPL, the GPL or the LGPL.
  37. *
  38. * ***** END LICENSE BLOCK *****
  39. *
  40. * This Original Code has been modified by IBM Corporation.
  41. * Modifications made by IBM described herein are
  42. * Copyright (c) International Business Machines
  43. * Corporation, 2000
  44. *
  45. * Modifications to Mozilla code or documentation
  46. * identified per MPL Section 3.3
  47. *
  48. * Date Modified by Description of modification
  49. * 05/03/2000 IBM Corp. Observer related defines for reflow
  50. */
  51. #ifndef nsIPresShell_h___
  52. #define nsIPresShell_h___
  53. #include "nsISupports.h"
  54. #include "nsCoord.h"
  55. #include "nsEvent.h"
  56. #include "nsReflowType.h"
  57. #include "nsCompatibility.h"
  58. #include "nsCOMArray.h"
  59. #include "nsFrameManagerBase.h"
  60. #include "mozFlushType.h"
  61. #include "nsWeakReference.h"
  62. #include <stdio.h> // for FILE definition
  63. class nsIAtom;
  64. class nsIContent;
  65. class nsIContentIterator;
  66. class nsIDocument;
  67. class nsIDocumentObserver;
  68. class nsIFrame;
  69. class nsPresContext;
  70. class nsStyleSet;
  71. class nsIViewManager;
  72. class nsIDeviceContext;
  73. class nsIRenderingContext;
  74. class nsIPageSequenceFrame;
  75. class nsString;
  76. class nsAString;
  77. class nsStringArray;
  78. class nsICaret;
  79. class nsStyleContext;
  80. class nsIFrameSelection;
  81. class nsFrameManager;
  82. class nsILayoutHistoryState;
  83. class nsIReflowCallback;
  84. class nsISupportsArray;
  85. class nsIDOMNode;
  86. class nsIStyleFrameConstruction;
  87. class nsIStyleSheet;
  88. class nsCSSFrameConstructor;
  89. class nsISelection;
  90. class nsWeakFrame;
  91. #define NS_IPRESSHELL_IID \
  92. { 0x0672be76, 0x1047, 0x4905, \
  93. {0xad, 0xd1, 0xc5, 0xc6, 0x90, 0xe8, 0x70, 0x3a} }
  94. // Constants uses for ScrollFrameIntoView() function
  95. #define NS_PRESSHELL_SCROLL_TOP 0
  96. #define NS_PRESSHELL_SCROLL_BOTTOM 100
  97. #define NS_PRESSHELL_SCROLL_LEFT 0
  98. #define NS_PRESSHELL_SCROLL_RIGHT 100
  99. #define NS_PRESSHELL_SCROLL_CENTER 50
  100. #define NS_PRESSHELL_SCROLL_ANYWHERE -1
  101. #define NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE -2
  102. // debug VerifyReflow flags
  103. #define VERIFY_REFLOW_ON 0x01
  104. #define VERIFY_REFLOW_NOISY 0x02
  105. #define VERIFY_REFLOW_ALL 0x04
  106. #define VERIFY_REFLOW_DUMP_COMMANDS 0x08
  107. #define VERIFY_REFLOW_NOISY_RC 0x10
  108. #define VERIFY_REFLOW_REALLY_NOISY_RC 0x20
  109. #define VERIFY_REFLOW_INCLUDE_SPACE_MANAGER 0x40
  110. #define VERIFY_REFLOW_DURING_RESIZE_REFLOW 0x80
  111. #ifdef IBMBIDI // Constant for Set/Get CaretBidiLevel
  112. #define BIDI_LEVEL_UNDEFINED 0x80
  113. #endif
  114. // for PostAttributeChanged
  115. enum nsAttributeChangeType {
  116. eChangeType_Set = 0, // Set attribute
  117. eChangeType_Remove = 1 // Remove attribute
  118. };
  119. /**
  120. * Presentation shell interface. Presentation shells are the
  121. * controlling point for managing the presentation of a document. The
  122. * presentation shell holds a live reference to the document, the
  123. * presentation context, the style manager, the style set and the root
  124. * frame. <p>
  125. *
  126. * When this object is Release'd, it will release the document, the
  127. * presentation context, the style manager, the style set and the root
  128. * frame.
  129. */
  130. // hack to make egcs / gcc 2.95.2 happy
  131. class nsIPresShell_base : public nsISupports
  132. {
  133. public:
  134. NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_IID)
  135. };
  136. class nsIPresShell : public nsIPresShell_base
  137. {
  138. public:
  139. NS_IMETHOD Init(nsIDocument* aDocument,
  140. nsPresContext* aPresContext,
  141. nsIViewManager* aViewManager,
  142. nsStyleSet* aStyleSet,
  143. nsCompatibility aCompatMode) = 0;
  144. /**
  145. * All callers are responsible for calling |Destroy| after calling
  146. * |EndObservingDocument|. It needs to be separate only because form
  147. * controls incorrectly store their data in the frames rather than the
  148. * content model and printing calls |EndObservingDocument| multiple
  149. * times to make form controls behave nicely when printed.
  150. */
  151. NS_IMETHOD Destroy() = 0;
  152. // All frames owned by the shell are allocated from an arena. They are also recycled
  153. // using free lists (separate free lists being maintained for each size_t).
  154. // Methods for recycling frames.
  155. virtual void* AllocateFrame(size_t aSize) = 0;
  156. virtual void FreeFrame(size_t aSize, void* aFreeChunk) = 0;
  157. // Dynamic stack memory allocation
  158. NS_IMETHOD PushStackMemory() = 0;
  159. NS_IMETHOD PopStackMemory() = 0;
  160. NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult) = 0;
  161. nsIDocument* GetDocument() { return mDocument; }
  162. nsPresContext* GetPresContext() { return mPresContext; }
  163. nsIViewManager* GetViewManager() { return mViewManager; }
  164. #ifdef _IMPL_NS_LAYOUT
  165. nsStyleSet* StyleSet() { return mStyleSet; }
  166. nsCSSFrameConstructor* FrameConstructor()
  167. {
  168. return mFrameConstructor;
  169. }
  170. nsFrameManager* FrameManager() const {
  171. return NS_REINTERPRET_CAST(nsFrameManager*,
  172. &NS_CONST_CAST(nsIPresShell*, this)->mFrameManager);
  173. }
  174. #endif
  175. // These two methods are used only by viewer
  176. NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle) = 0;
  177. NS_IMETHOD SelectAlternateStyleSheet(const nsString& aSheetTitle) = 0;
  178. /* Enable/disable author style level. Disabling author style disables the entire
  179. * author level of the cascade, including the HTML preshint level.
  180. */
  181. // XXX these could easily be inlined, but there is a circular #include
  182. // problem with nsStyleSet.
  183. NS_HIDDEN_(void) SetAuthorStyleDisabled(PRBool aDisabled);
  184. NS_HIDDEN_(PRBool) GetAuthorStyleDisabled();
  185. /*
  186. * Called when stylesheets are added/removed/enabled/disabled to rebuild
  187. * all style data for a given pres shell without necessarily reconstructing
  188. * all of the frames.
  189. */
  190. virtual NS_HIDDEN_(void) ReconstructStyleDataExternal();
  191. NS_HIDDEN_(void) ReconstructStyleDataInternal();
  192. #ifdef _IMPL_NS_LAYOUT
  193. void ReconstructStyleData() { ReconstructStyleDataInternal(); }
  194. #else
  195. void ReconstructStyleData() { ReconstructStyleDataExternal(); }
  196. #endif
  197. /** Setup all style rules required to implement preferences
  198. * - used for background/text/link colors and link underlining
  199. * may be extended for any prefs that are implemented via style rules
  200. * - aForceReflow argument is used to force a full reframe to make the rules show
  201. * (only used when the current page needs to reflect changed pref rules)
  202. *
  203. * - initially created for bugs 31816, 20760, 22963
  204. */
  205. NS_IMETHOD SetPreferenceStyleRules(PRBool aForceReflow) = 0;
  206. /**
  207. * Gather titles of all selectable (alternate and preferred) style sheets
  208. * fills void array with nsString* caller must free strings
  209. */
  210. NS_IMETHOD ListAlternateStyleSheets(nsStringArray& aTitleList) = 0;
  211. /**
  212. * FrameSelection will return the Frame based selection API.
  213. * You cannot go back and forth anymore with QI between nsIDOM sel and
  214. * nsIFrame sel.
  215. */
  216. nsIFrameSelection* FrameSelection() { return mSelection; }
  217. // Make shell be a document observer
  218. NS_IMETHOD BeginObservingDocument() = 0;
  219. // Make shell stop being a document observer
  220. NS_IMETHOD EndObservingDocument() = 0;
  221. /**
  222. * Determine if InitialReflow() was previously called.
  223. * @param aDidInitialReflow PR_TRUE if InitalReflow() was previously called,
  224. * PR_FALSE otherwise.
  225. */
  226. NS_IMETHOD GetDidInitialReflow(PRBool *aDidInitialReflow) = 0;
  227. /**
  228. * Perform the initial reflow. Constructs the frame for the root content
  229. * object and then reflows the frame model into the specified width and
  230. * height.
  231. *
  232. * The coordinates for aWidth and aHeight must be in standard nscoord's.
  233. */
  234. NS_IMETHOD InitialReflow(nscoord aWidth, nscoord aHeight) = 0;
  235. /**
  236. * Reflow the frame model into a new width and height. The
  237. * coordinates for aWidth and aHeight must be in standard nscoord's.
  238. */
  239. NS_IMETHOD ResizeReflow(nscoord aWidth, nscoord aHeight) = 0;
  240. /**
  241. * Reflow the frame model with a reflow reason of eReflowReason_StyleChange
  242. */
  243. NS_IMETHOD StyleChangeReflow() = 0;
  244. /**
  245. * This calls through to the frame manager to get the root frame.
  246. * Callers inside of gklayout should use FrameManager()->GetRootFrame()
  247. * instead, as it's more efficient.
  248. */
  249. virtual NS_HIDDEN_(nsIFrame*) GetRootFrame() const;
  250. /**
  251. * Returns the page sequence frame associated with the frame hierarchy.
  252. * Returns NULL if not a paginated view.
  253. */
  254. NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const = 0;
  255. /**
  256. * Gets the primary frame associated with the content object. This is a
  257. * helper function that just forwards the request to the frame manager.
  258. *
  259. * The primary frame is the frame that is most closely associated with the
  260. * content. A frame is more closely associated with the content that another
  261. * frame if the one frame contains directly or indirectly the other frame (e.g.,
  262. * when a frame is scrolled there is a scroll frame that contains the frame
  263. * being scrolled). The primary frame is always the first-in-flow.
  264. *
  265. * In the case of absolutely positioned elements and floated elements,
  266. * the primary frame is the frame that is out of the flow and not the
  267. * placeholder frame.
  268. */
  269. NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent,
  270. nsIFrame** aPrimaryFrame) const = 0;
  271. /**
  272. * Returns a layout object associated with the primary frame for the content object.
  273. *
  274. * @param aContent the content object for which we seek a layout object
  275. * @param aResult the resulting layout object as an nsISupports, if found. Refcounted.
  276. */
  277. NS_IMETHOD GetLayoutObjectFor(nsIContent* aContent,
  278. nsISupports** aResult) const = 0;
  279. /**
  280. * Gets the placeholder frame associated with the specified frame. This is
  281. * a helper frame that forwards the request to the frame manager.
  282. */
  283. NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame,
  284. nsIFrame** aPlaceholderFrame) const = 0;
  285. /**
  286. * Reflow commands
  287. */
  288. NS_IMETHOD AppendReflowCommand(nsIFrame* aTargetFrame,
  289. nsReflowType aReflowType,
  290. nsIAtom* aChildListName) = 0;
  291. // XXXbz don't we need a child list name on this too?
  292. NS_IMETHOD CancelReflowCommand(nsIFrame* aTargetFrame, nsReflowType* aCmdType) = 0;
  293. NS_IMETHOD CancelAllReflowCommands() = 0;
  294. /**
  295. * Recreates the frames for a node
  296. */
  297. NS_IMETHOD RecreateFramesFor(nsIContent* aContent) = 0;
  298. /**
  299. * Determine if it is safe to flush all pending notifications
  300. * @param aIsSafeToFlush PR_TRUE if it is safe, PR_FALSE otherwise.
  301. *
  302. */
  303. NS_IMETHOD IsSafeToFlush(PRBool& aIsSafeToFlush) = 0;
  304. /**
  305. * Flush pending notifications of the type specified. This method
  306. * will not affect the content model; it'll just affect style and
  307. * frames. Callers that actually want up-to-date presentation (other
  308. * than the document itself) should probably be calling
  309. * nsIDocument::FlushPendingNotifications.
  310. *
  311. * @param aType the type of notifications to flush
  312. */
  313. NS_IMETHOD FlushPendingNotifications(mozFlushType aType) = 0;
  314. /**
  315. * Post a request to handle a DOM event after Reflow has finished.
  316. */
  317. NS_IMETHOD PostDOMEvent(nsIContent* aContent, nsEvent* aEvent)=0;
  318. /**
  319. * Post a request to set and attribute after reflow has finished.
  320. */
  321. NS_IMETHOD PostAttributeChange(nsIContent* aContent,
  322. PRInt32 aNameSpaceID,
  323. nsIAtom* aName,
  324. const nsString& aValue,
  325. PRBool aNotify,
  326. nsAttributeChangeType aType) = 0;
  327. NS_IMETHOD PostReflowCallback(nsIReflowCallback* aCallback) = 0;
  328. NS_IMETHOD CancelReflowCallback(nsIReflowCallback* aCallback) = 0;
  329. /**
  330. * Reflow batching
  331. */
  332. NS_IMETHOD BeginReflowBatching() = 0;
  333. NS_IMETHOD EndReflowBatching(PRBool aFlushPendingReflows) = 0;
  334. NS_IMETHOD GetReflowBatchingStatus(PRBool* aIsBatching) = 0;
  335. NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame) = 0;
  336. /**
  337. * Given a frame, create a rendering context suitable for use with
  338. * the frame.
  339. */
  340. NS_IMETHOD CreateRenderingContext(nsIFrame *aFrame,
  341. nsIRenderingContext** aContext) = 0;
  342. /**
  343. * Notification that we were unable to render a replaced element.
  344. * Called when the replaced element can not be rendered, and we should
  345. * instead render the element's contents.
  346. * The content object associated with aFrame should either be a IMG
  347. * element, an OBJECT element, or an APPLET element
  348. */
  349. NS_IMETHOD CantRenderReplacedElement(nsIFrame* aFrame) = 0;
  350. /**
  351. * Informs the pres shell that the document is now at the anchor with
  352. * the given name. If |aScroll| is true, scrolls the view of the
  353. * document so that the anchor with the specified name is displayed at
  354. * the top of the window. If |aAnchorName| is empty, then this informs
  355. * the pres shell that there is no current target, and |aScroll| must
  356. * be false.
  357. */
  358. NS_IMETHOD GoToAnchor(const nsAString& aAnchorName, PRBool aScroll) = 0;
  359. /**
  360. * Scrolls the view of the document so that the frame is displayed at the
  361. * top of the window.
  362. *
  363. * @param aFrame The frame to scroll into view
  364. * @param aVPercent How to align the frame vertically. A value of 0
  365. * (NS_PRESSHELL_SCROLL_TOP) means the frame's upper edge is
  366. * aligned with the top edge of the visible area. A value of
  367. * 100 (NS_PRESSHELL_SCROLL_BOTTOM) means the frame's bottom
  368. * edge is aligned with the bottom edge of the visible area.
  369. * For values in between, the point "aVPercent" down the frame
  370. * is placed at the point "aVPercent" down the visible area. A
  371. * value of 50 (NS_PRESSHELL_SCROLL_CENTER) centers the frame
  372. * vertically. A value of NS_PRESSHELL_SCROLL_ANYWHERE means move
  373. * the frame the minimum amount necessary in order for the entire
  374. * frame to be visible vertically (if possible)
  375. * @param aHPercent How to align the frame horizontally. A value of 0
  376. * (NS_PRESSHELL_SCROLL_LEFT) means the frame's left edge is
  377. * aligned with the left edge of the visible area. A value of
  378. * 100 (NS_PRESSHELL_SCROLL_RIGHT) means the frame's right
  379. * edge is aligned with the right edge of the visible area.
  380. * For values in between, the point "aVPercent" across the frame
  381. * is placed at the point "aVPercent" across the visible area.
  382. * A value of 50 (NS_PRESSHELL_SCROLL_CENTER) centers the frame
  383. * horizontally . A value of NS_PRESSHELL_SCROLL_ANYWHERE means move
  384. * the frame the minimum amount necessary in order for the entire
  385. * frame to be visible horizontally (if possible)
  386. */
  387. NS_IMETHOD ScrollFrameIntoView(nsIFrame *aFrame,
  388. PRIntn aVPercent,
  389. PRIntn aHPercent) const = 0;
  390. /**
  391. * Suppress notification of the frame manager that frames are
  392. * being destroyed.
  393. */
  394. NS_IMETHOD SetIgnoreFrameDestruction(PRBool aIgnore) = 0;
  395. /**
  396. * Notification sent by a frame informing the pres shell that it is about to
  397. * be destroyed.
  398. * This allows any outstanding references to the frame to be cleaned up
  399. */
  400. NS_IMETHOD NotifyDestroyingFrame(nsIFrame* aFrame) = 0;
  401. /**
  402. * Notify the Clipboard that we have something to copy.
  403. */
  404. NS_IMETHOD DoCopy() = 0;
  405. /**
  406. * Get the selection of the focussed element (either the page selection,
  407. * or the selection for a text field).
  408. */
  409. NS_IMETHOD GetSelectionForCopy(nsISelection** outSelection) = 0;
  410. /**
  411. * Get link location.
  412. */
  413. NS_IMETHOD GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocation) = 0;
  414. /**
  415. * Get the doc or the selection as text or html.
  416. */
  417. NS_IMETHOD DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aSelectionOnly, nsAString& outValue) = 0;
  418. /**
  419. * Get the caret, if it exists. AddRefs it.
  420. */
  421. NS_IMETHOD GetCaret(nsICaret **aOutCaret) = 0;
  422. /**
  423. * Should the images have borders etc. Actual visual effects are determined
  424. * by the frames. Visual effects may not effect layout, only display.
  425. * Takes effect on next repaint, does not force a repaint itself.
  426. *
  427. * @param aEnabled if PR_TRUE, visual selection effects are enabled
  428. * if PR_FALSE visual selection effects are disabled
  429. * @return always NS_OK
  430. */
  431. NS_IMETHOD SetSelectionFlags(PRInt16 aInEnable) = 0;
  432. /**
  433. * Gets the current state of non text selection effects
  434. * @param aEnabled [OUT] set to the current state of non text selection,
  435. * as set by SetDisplayNonTextSelection
  436. * @return if aOutEnabled==null, returns NS_ERROR_INVALID_ARG
  437. * else NS_OK
  438. */
  439. NS_IMETHOD GetSelectionFlags(PRInt16 *aOutEnabled) = 0;
  440. /**
  441. * Interface to dispatch events via the presshell
  442. * @note The caller must have a strong reference to the PresShell.
  443. */
  444. NS_IMETHOD HandleEventWithTarget(nsEvent* aEvent,
  445. nsIFrame* aFrame,
  446. nsIContent* aContent,
  447. PRUint32 aFlags,
  448. nsEventStatus* aStatus) = 0;
  449. /**
  450. * Dispatch event to content only (NOT full processing)
  451. * @note The caller must have a strong reference to the PresShell.
  452. */
  453. NS_IMETHOD HandleDOMEventWithTarget(nsIContent* aTargetContent,
  454. nsEvent* aEvent,
  455. nsEventStatus* aStatus) = 0;
  456. /**
  457. * Gets the current target event frame from the PresShell
  458. */
  459. NS_IMETHOD GetEventTargetFrame(nsIFrame** aFrame) = 0;
  460. /**
  461. * Gets the current target event frame from the PresShell
  462. */
  463. NS_IMETHOD GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent) = 0;
  464. /**
  465. * Get and set the history state for the current document
  466. */
  467. NS_IMETHOD CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, PRBool aLeavingPage = PR_FALSE) = 0;
  468. /**
  469. * Determine if reflow is currently locked
  470. * @param aIsReflowLocked returns PR_TRUE if reflow is locked, PR_FALSE otherwise
  471. */
  472. NS_IMETHOD IsReflowLocked(PRBool* aIsLocked) = 0;
  473. /**
  474. * Returns a content iterator to iterate the generated content nodes.
  475. * You must specify whether you want to iterate the "before" generated
  476. * content or the "after" generated content. If there is no generated
  477. * content of the specified type for the promary frame associated with
  478. * with the content object then NULL is returned
  479. */
  480. enum GeneratedContentType {Before, After};
  481. NS_IMETHOD GetGeneratedContentIterator(nsIContent* aContent,
  482. GeneratedContentType aType,
  483. nsIContentIterator** aIterator) const = 0;
  484. /**
  485. * Store the nsIAnonymousContentCreator-generated anonymous
  486. * content that's associated with an element. The new anonymous content
  487. * is added to whatever anonymous content might already be associated with
  488. * the element.
  489. * @param aContent the element with which the anonymous
  490. * content is to be associated with
  491. * @param aAnonymousElements an array of nsIContent
  492. * objects, or null to indicate that any anonymous
  493. * content should be dissociated from the aContent
  494. */
  495. NS_IMETHOD SetAnonymousContentFor(nsIContent* aContent, nsISupportsArray* aAnonymousElements) = 0;
  496. /**
  497. * Retrieve the nsIAnonymousContentCreator-generated anonymous
  498. * content that's associated with an element.
  499. * @param aContent the element for which to retrieve the
  500. * associated anonymous content
  501. * @param aAnonymousElements an array of nsIContent objects,
  502. * or null to indicate that there are no anonymous elements
  503. * associated with aContent
  504. */
  505. NS_IMETHOD GetAnonymousContentFor(nsIContent* aContent, nsISupportsArray** aAnonymousElements) = 0;
  506. /**
  507. * Release all nsIAnonymousContentCreator-generated
  508. * anonymous content associated with the shell.
  509. */
  510. NS_IMETHOD ReleaseAnonymousContent() = 0;
  511. /**
  512. * Called to find out if painting is suppressed for this presshell. If it is suppressd,
  513. * we don't allow the painting of any layer but the background, and we don't
  514. * recur into our children.
  515. */
  516. NS_IMETHOD IsPaintingSuppressed(PRBool* aResult)=0;
  517. /**
  518. * Unsuppress painting.
  519. */
  520. NS_IMETHOD UnsuppressPainting() = 0;
  521. /**
  522. * Called to disable nsITheme support in a specific presshell.
  523. */
  524. NS_IMETHOD DisableThemeSupport() = 0;
  525. /**
  526. * Indicates whether theme support is enabled.
  527. */
  528. virtual PRBool IsThemeSupportEnabled() = 0;
  529. /**
  530. * Get the set of agent style sheets for this presentation
  531. */
  532. virtual nsresult GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets) = 0;
  533. /**
  534. * Replace the set of agent style sheets
  535. */
  536. virtual nsresult SetAgentStyleSheets(const nsCOMArray<nsIStyleSheet>& aSheets) = 0;
  537. /**
  538. * Add an override style sheet for this presentation
  539. */
  540. virtual nsresult AddOverrideStyleSheet(nsIStyleSheet *aSheet) = 0;
  541. /**
  542. * Remove an override style sheet
  543. */
  544. virtual nsresult RemoveOverrideStyleSheet(nsIStyleSheet *aSheet) = 0;
  545. /**
  546. * Reconstruct frames for all elements in the document
  547. */
  548. virtual nsresult ReconstructFrames() = 0;
  549. /**
  550. * See if reflow verification is enabled. To enable reflow verification add
  551. * "verifyreflow:1" to your NSPR_LOG_MODULES environment variable
  552. * (any non-zero debug level will work). Or, call SetVerifyReflowEnable
  553. * with PR_TRUE.
  554. */
  555. static PRBool GetVerifyReflowEnable();
  556. /**
  557. * Set the verify-reflow enable flag.
  558. */
  559. static void SetVerifyReflowEnable(PRBool aEnabled);
  560. /**
  561. * Get the flags associated with the VerifyReflow debug tool
  562. */
  563. static PRInt32 GetVerifyReflowFlags();
  564. #ifdef MOZ_REFLOW_PERF
  565. NS_IMETHOD DumpReflows() = 0;
  566. NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
  567. NS_IMETHOD PaintCount(const char * aName,
  568. nsIRenderingContext* aRenderingContext,
  569. nsPresContext * aPresContext,
  570. nsIFrame * aFrame,
  571. PRUint32 aColor) = 0;
  572. NS_IMETHOD SetPaintFrameCount(PRBool aOn) = 0;
  573. #endif
  574. #ifdef IBMBIDI
  575. /**
  576. * SetCaretBidiLevel will set the Bidi embedding level for the cursor. 0-63
  577. */
  578. NS_IMETHOD SetCaretBidiLevel(PRUint8 aLevel) = 0;
  579. /**
  580. * GetCaretBidiLevel will get the Bidi embedding level for the cursor. 0-63
  581. */
  582. NS_IMETHOD GetCaretBidiLevel(PRUint8 *aOutLevel) = 0;
  583. /**
  584. * UndefineCaretBidiLevel will set the Bidi embedding level for the cursor to an out-of-range value
  585. */
  586. NS_IMETHOD UndefineCaretBidiLevel(void) = 0;
  587. /**
  588. * Reconstruct and reflow frame model
  589. */
  590. NS_IMETHOD BidiStyleChangeReflow(void) = 0;
  591. #endif
  592. #ifdef DEBUG
  593. // Debugging hooks
  594. virtual void ListStyleContexts(nsIFrame *aRootFrame, FILE *out,
  595. PRInt32 aIndent = 0) = 0;
  596. virtual void ListStyleSheets(FILE *out, PRInt32 aIndent = 0) = 0;
  597. #endif
  598. PRBool IsAccessibilityActive() { return mIsAccessibilityActive; }
  599. /**
  600. * Stop all active elements (plugins and the caret) in this presentation and
  601. * in the presentations of subdocuments. Resets painting to a suppressed state.
  602. * XXX this should include image animations
  603. */
  604. virtual void Freeze() = 0;
  605. /**
  606. * Restarts active elements (plugins) in this presentation and in the
  607. * presentations of subdocuments, then do a full invalidate of the content area.
  608. */
  609. virtual void Thaw() = 0;
  610. /**
  611. * When this shell is disconnected from its containing docshell, we
  612. * lose our container pointer. However, we'd still like to be able to target
  613. * user events at the docshell's parent. This pointer allows us to do that.
  614. * It should not be used for any other purpose.
  615. */
  616. void SetForwardingContainer(nsWeakPtr aContainer)
  617. {
  618. mForwardingContainer = aContainer;
  619. }
  620. protected:
  621. // IMPORTANT: The ownership implicit in the following member variables
  622. // has been explicitly checked. If you add any members to this class,
  623. // please make the ownership explicit (pinkerton, scc).
  624. // these are the same Document and PresContext owned by the DocViewer.
  625. // we must share ownership.
  626. nsIDocument* mDocument; // [STRONG]
  627. nsPresContext* mPresContext; // [STRONG]
  628. nsStyleSet* mStyleSet; // [OWNS]
  629. nsCSSFrameConstructor* mFrameConstructor; // [OWNS]
  630. nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
  631. nsIFrameSelection* mSelection;
  632. nsFrameManagerBase mFrameManager; // [OWNS]
  633. nsWeakPtr mForwardingContainer;
  634. PRPackedBool mStylesHaveChanged;
  635. #ifdef ACCESSIBILITY
  636. /**
  637. * Call this when there have been significant changes in the rendering for
  638. * a content subtree, so the matching accessibility subtree can be invalidated
  639. */
  640. void InvalidateAccessibleSubtree(nsIContent *aContent);
  641. #endif
  642. // Set to true when the accessibility service is being used to mirror
  643. // the dom/layout trees
  644. PRPackedBool mIsAccessibilityActive;
  645. };
  646. #define NS_IPRESSHELL_MOZILLA_1_8_BRANCH_IID \
  647. { 0x365C83FB, 0x7D4C, 0x4B53, \
  648. { 0x84, 0xde, 0xa5, 0xcc, 0x9a, 0x05, 0x9a, 0x26 } }
  649. class nsIPresShell_MOZILLA_1_8_BRANCH : public nsIPresShell
  650. {
  651. public:
  652. NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_MOZILLA_1_8_BRANCH_IID)
  653. void AddWeakFrame(nsWeakFrame* aWeakFrame);
  654. void RemoveWeakFrame(nsWeakFrame* aWeakFrame);
  655. virtual void HidePopups() = 0;
  656. protected:
  657. // A list of weak frames. This is a pointer to the last item in the list.
  658. nsWeakFrame* mWeakFrames;
  659. };
  660. #define NS_IPRESSHELL_MOZILLA_1_8_BRANCH2_IID \
  661. { 0x5187f765, 0x895b, 0x4566, \
  662. { 0x99, 0x7d, 0xd8, 0xd8, 0xbf, 0xa4, 0x74, 0x21 } }
  663. class nsIPresShell_MOZILLA_1_8_BRANCH2 : public nsIPresShell_MOZILLA_1_8_BRANCH
  664. {
  665. public:
  666. NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_MOZILLA_1_8_BRANCH2_IID)
  667. virtual void BlockFlushing() = 0;
  668. virtual void UnblockFlushing() = 0;
  669. };
  670. /**
  671. * Create a new empty presentation shell. Upon success, call Init
  672. * before attempting to use the shell.
  673. */
  674. nsresult
  675. NS_NewPresShell(nsIPresShell** aInstancePtrResult);
  676. #endif /* nsIPresShell_h___ */