123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- /*
- * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
- */
- #include "config.h"
- #include "WebKitThreadViewportAccessor.h"
- #include "WebPage_p.h"
- #include <BlackBerryPlatformMessageClient.h>
- #include <BlackBerryPlatformPrimitives.h>
- using BlackBerry::Platform::IntPoint;
- using BlackBerry::Platform::IntSize;
- using BlackBerry::Platform::ViewportAccessor;
- namespace BlackBerry {
- namespace WebKit {
- WebKitThreadViewportAccessor::WebKitThreadViewportAccessor(WebPagePrivate* webPagePrivate)
- : m_webPagePrivate(webPagePrivate)
- {
- }
- IntSize WebKitThreadViewportAccessor::pixelContentsSize() const
- {
- ASSERT(Platform::webKitThreadMessageClient()->isCurrentThread());
- double scaleFactor = scale();
- if (scaleFactor != 1.0) {
- // Round down to avoid showing partially rendered pixels.
- IntSize size = documentContentsSize();
- return IntSize(
- floorf(size.width() * scaleFactor),
- floorf(size.height() * scaleFactor));
- }
- return documentContentsSize();
- }
- IntSize WebKitThreadViewportAccessor::documentContentsSize() const
- {
- ASSERT(Platform::webKitThreadMessageClient()->isCurrentThread());
- return m_webPagePrivate->contentsSize();
- }
- IntPoint WebKitThreadViewportAccessor::pixelScrollPosition() const
- {
- ASSERT(Platform::webKitThreadMessageClient()->isCurrentThread());
- return roundToPixelFromDocumentContents(documentScrollPosition());
- }
- IntPoint WebKitThreadViewportAccessor::documentScrollPosition() const
- {
- ASSERT(Platform::webKitThreadMessageClient()->isCurrentThread());
- return m_webPagePrivate->scrollPosition();
- }
- IntSize WebKitThreadViewportAccessor::pixelViewportSize() const
- {
- ASSERT(Platform::webKitThreadMessageClient()->isCurrentThread());
- return m_webPagePrivate->transformedActualVisibleSize();
- }
- IntSize WebKitThreadViewportAccessor::documentViewportSize() const
- {
- ASSERT(Platform::webKitThreadMessageClient()->isCurrentThread());
- return roundToDocumentFromPixelContents(pixelViewportRect()).size();
- }
- IntPoint WebKitThreadViewportAccessor::destinationSurfaceOffset() const
- {
- // FIXME: This should somehow get its offset from a reliable source.
- return IntPoint(0, 0);
- }
- double WebKitThreadViewportAccessor::scale() const
- {
- ASSERT(Platform::webKitThreadMessageClient()->isCurrentThread());
- return m_webPagePrivate->currentScale();
- }
- } // namespace WebKit
- } // namespace BlackBerry
|