Opera 12.15 Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

viewportcontroller.h 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
  2. *
  3. * Copyright (C) 2008-2009 Opera Software AS. All rights reserved.
  4. *
  5. * This file is part of the Opera web browser.
  6. * It may not be distributed under any circumstances.
  7. */
  8. #ifndef VIEWPORTCONTROLLER_H
  9. #define VIEWPORTCONTROLLER_H
  10. #include "modules/windowcommander/OpViewportController.h"
  11. #include "modules/windowcommander/src/WindowCommander.h"
  12. #include "modules/dochand/viewportlisteners.h"
  13. #include "modules/dochand/win.h"
  14. class FramesDocument;
  15. class ViewportController : public OpViewportController
  16. {
  17. public:
  18. ViewportController(Window* window) :
  19. window(window),
  20. default_viewport_request_listener(window->GetWindowCommander()),
  21. viewport_request_listener(&default_viewport_request_listener),
  22. viewport_info_listener(&null_viewport_info_listener),
  23. desktop_layout_width(0),
  24. desktop_layout_height(0),
  25. visual_viewport_size_locked(TRUE),
  26. buffered_mode(FALSE),
  27. max_paragraph_width(-1),
  28. visual_viewport_width(0),
  29. visual_viewport_height(0),
  30. buffered_rendering_view_x(INT_MIN),
  31. buffered_rendering_view_y(INT_MIN),
  32. buffered_layout_view_x(INT_MIN),
  33. buffered_layout_view_y(INT_MIN)
  34. #ifdef PAGED_MEDIA_SUPPORT
  35. , current_page_number(-1)
  36. , total_page_count(-1)
  37. #endif // PAGED_MEDIA_SUPPORT
  38. { }
  39. OpViewportRequestListener* GetViewportRequestListener() const { return viewport_request_listener; }
  40. OpViewportInfoListener* GetViewportInfoListener() const { return viewport_info_listener; }
  41. OpRect ConvertToToplevelRect(FramesDocument* frm_doc, const OpRect& local_rect);
  42. OpRect ConvertToLocalRect(FramesDocument* frm_doc, const OpRect& toplevel_rect);
  43. unsigned int GetDesktopLayoutViewportWidth() const { return desktop_layout_width; }
  44. unsigned int GetDesktopLayoutViewportHeight() const { return desktop_layout_height; }
  45. /* @return max paragraph width in document coordinates. */
  46. int GetMaxParagraphWidth() { return max_paragraph_width; }
  47. /*
  48. * Find the innermost document that this point points to (may be an iframe or frame document)
  49. *
  50. * @param p[in/out] point in document coordinates. returns the point in document
  51. * coordinates relative to the innermost found framesdocument
  52. * @param allow_svg If TRUE the resulting document may contain only SVG markup.
  53. * If FALSE the resulting document must not only contain SVG markup.
  54. *
  55. * @return the innermost FramesDocument that the given position points at.
  56. */
  57. FramesDocument* FindDocumentAtPosAndTranslate(OpPoint& p, BOOL allow_svg = TRUE);
  58. // Implementing OpViewportController:
  59. virtual void SetViewportRequestListener(OpViewportRequestListener* listener);
  60. virtual void SetViewportInfoListener(OpViewportInfoListener* listener);
  61. virtual void LockVisualViewportSize(BOOL lock);
  62. virtual void SetBufferedMode(BOOL buffered_mode);
  63. virtual void FlushBuffer();
  64. virtual void SetDesktopLayoutViewportSize(unsigned int width, unsigned int height);
  65. virtual OpRect GetVisualViewport();
  66. virtual void SetVisualViewport(const OpRect& viewport);
  67. virtual void SetVisualViewportPos(const OpPoint& pos);
  68. #ifdef PAGED_MEDIA_SUPPORT
  69. virtual void SetCurrentPageNumber(int page_number);
  70. virtual int GetCurrentPageNumber();
  71. virtual int GetTotalPageCount();
  72. #endif // PAGED_MEDIA_SUPPORT
  73. virtual void SetTextParagraphWidthLimit(unsigned int max_paragraph_width, const OpPoint* pos = NULL);
  74. virtual void DisableTextParagraphWidthLimit(const OpPoint* pos = NULL);
  75. virtual OpRect GetRenderingViewport();
  76. virtual void SetRenderingViewportPos(const OpPoint& pos);
  77. virtual void SetRenderingScale(unsigned int scale_percentage);
  78. virtual void SetTrueZoomBaseScale(unsigned int scale_percentage);
  79. virtual OpRect GetLayoutViewport();
  80. virtual void GetDocumentSize(unsigned int* width, unsigned int* height);
  81. virtual void GetParagraphRects(const OpRect& rect, Head* paragraph_rects);
  82. virtual BOOL IsVisualViewportSizeLocked() const { return visual_viewport_size_locked; }
  83. #ifdef RESERVED_REGIONS
  84. virtual OP_STATUS GetReservedRegion(const OpRect& rect, OpRegion& reserved_region);
  85. #endif // RESERVED_REGIONS
  86. /** Finds the innermost HTML_Element at a screen position.
  87. *
  88. * @param screen_pos[in] The screen position
  89. * @param target_doc[out] The FramesDocument at the given screen position (NULL if no document)
  90. * @param document_pos[out] The document position relative target_doc (undefined if no document);
  91. *
  92. * @return The HTML_Element at the given screen position, or NULL if no HTML_Element found.
  93. */
  94. HTML_Element* FindElementAtScreenPosAndTranslate(const OpPoint& screen_pos, FramesDocument* &target_doc, OpPoint &document_pos);
  95. #ifdef PAGED_MEDIA_SUPPORT
  96. void SignalPageChange(int current, int total);
  97. #endif // PAGED_MEDIA_SUPPORT
  98. #ifdef SELFTEST
  99. BOOL HasDefaultViewportRequestListener() const {return viewport_request_listener == &default_viewport_request_listener;}
  100. #endif // SELFTEST
  101. private:
  102. Window* window;
  103. DefaultViewportRequestListener default_viewport_request_listener;
  104. NullViewportInfoListener null_viewport_info_listener;
  105. OpViewportRequestListener* viewport_request_listener;
  106. OpViewportInfoListener* viewport_info_listener;
  107. unsigned int desktop_layout_width;
  108. unsigned int desktop_layout_height;
  109. BOOL visual_viewport_size_locked;
  110. BOOL buffered_mode;
  111. int max_paragraph_width;
  112. OpPoint visual_viewport_pos;
  113. unsigned int visual_viewport_width;
  114. unsigned int visual_viewport_height;
  115. int buffered_rendering_view_x;
  116. int buffered_rendering_view_y;
  117. int buffered_layout_view_x;
  118. int buffered_layout_view_y;
  119. #ifdef PAGED_MEDIA_SUPPORT
  120. int current_page_number;
  121. int total_page_count;
  122. #endif // PAGED_MEDIA_SUPPORT
  123. void HandleVisualViewportChange(const OpRect& viewport);
  124. void GetVisualViewportSizeFromWindow(unsigned int& width, unsigned int& height);
  125. };
  126. #endif // VIEWPORTCONTROLLER_H