Bug 945277 - Align sub-frame display ports to tile boundaries. r=botond
authorChris Lord <chrislord.net@gmail.com>
Thu, 05 Dec 2013 13:12:12 +0000
changeset 158874 0ae343996d36c19a159c9713332a2fc1058b9723
parent 158873 4a61d432db433c9ccc98333b8ec22f6a72be00aa
child 158875 954f30096cbee300dc8a30b2cc743dd364e74f0c
push id37122
push userchrislord.net@gmail.com
push dateThu, 05 Dec 2013 13:12:47 +0000
treeherdermozilla-inbound@954f30096cbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs945277, 907743
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 945277 - Align sub-frame display ports to tile boundaries. r=botond Bug 907743 only addressed the root frame, this patch updates APZCCallbackHelper to make the same alterations on sub-frame metrics.
dom/ipc/TabChild.cpp
widget/gonk/ParentProcessController.cpp
widget/xpwidgets/APZCCallbackHelper.cpp
widget/xpwidgets/APZCCallbackHelper.h
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1525,17 +1525,18 @@ TabChild::RecvUpdateFrame(const FrameMet
       return ProcessUpdateFrame(aFrameMetrics);
     }
   } else {
     // aFrameMetrics.mIsRoot is false, so we are trying to update a subframe.
     // This requires special handling.
     nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(
                                       aFrameMetrics.mScrollId);
     if (content) {
-      APZCCallbackHelper::UpdateSubFrame(content, aFrameMetrics);
+      FrameMetrics newSubFrameMetrics(aFrameMetrics);
+      APZCCallbackHelper::UpdateSubFrame(content, newSubFrameMetrics);
       return true;
     }
   }
 
   // We've recieved a message that is out of date and we want to ignore.
   // However we can't reply without painting so we reply by painting the
   // exact same thing as we did before.
   return ProcessUpdateFrame(mLastMetrics);
--- a/widget/gonk/ParentProcessController.cpp
+++ b/widget/gonk/ParentProcessController.cpp
@@ -27,17 +27,17 @@ public:
         nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(mFrameMetrics.mScrollId);
         if (content) {
             APZCCallbackHelper::UpdateSubFrame(content, mFrameMetrics);
         }
         return NS_OK;
     }
 
 protected:
-    const FrameMetrics mFrameMetrics;
+    FrameMetrics mFrameMetrics;
 };
 
 void
 ParentProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
 {
     if (aFrameMetrics.mScrollId == FrameMetrics::NULL_SCROLL_ID) {
         return;
     }
--- a/widget/xpwidgets/APZCCallbackHelper.cpp
+++ b/widget/xpwidgets/APZCCallbackHelper.cpp
@@ -67,27 +67,25 @@ MaybeAlignAndClampDisplayPort(mozilla::l
   // Correct the display-port by the difference between the requested scroll
   // offset and the resulting scroll offset after setting the requested value.
   CSSRect& displayPort = aFrameMetrics.mDisplayPort;
   displayPort += aActualScrollOffset - aFrameMetrics.mScrollOffset;
 
   // Expand the display port to the next tile boundaries, if tiled thebes layers
   // are enabled.
   if (Preferences::GetBool("layers.force-tiles")) {
-    // aFrameMetrics.mZoom is the zoom amount reported by the APZC,
-    // scale by ScreenToLayerScale to get the gecko zoom amount
     displayPort =
       ExpandDisplayPortToTileBoundaries(displayPort + aActualScrollOffset,
-                                        aFrameMetrics.mZoom * ScreenToLayerScale(1))
+                                        aFrameMetrics.LayersPixelsPerCSSPixel())
       - aActualScrollOffset;
   }
 
   // Finally, clamp the display port to the scrollable rect.
   CSSRect scrollableRect = aFrameMetrics.mScrollableRect;
-  displayPort = scrollableRect.ClampRect(displayPort + aActualScrollOffset)
+  displayPort = scrollableRect.Intersect(displayPort + aActualScrollOffset)
     - aActualScrollOffset;
 }
 
 void
 APZCCallbackHelper::UpdateRootFrame(nsIDOMWindowUtils* aUtils,
                                     FrameMetrics& aMetrics)
 {
     // Precondition checks
@@ -148,45 +146,50 @@ APZCCallbackHelper::UpdateRootFrame(nsID
                                      aMetrics.mDisplayPort.y,
                                      aMetrics.mDisplayPort.width,
                                      aMetrics.mDisplayPort.height,
                                      element);
 }
 
 void
 APZCCallbackHelper::UpdateSubFrame(nsIContent* aContent,
-                                   const FrameMetrics& aMetrics)
+                                   FrameMetrics& aMetrics)
 {
     // Precondition checks
     MOZ_ASSERT(aContent);
     if (aMetrics.mScrollId == FrameMetrics::NULL_SCROLL_ID) {
         return;
     }
 
     nsCOMPtr<nsIDOMWindowUtils> utils = GetDOMWindowUtils(aContent);
     if (!utils) {
         return;
     }
 
     // We currently do not support zooming arbitrary subframes. They can only
     // be scrolled, so here we only have to set the scroll position and displayport.
 
+    CSSPoint actualScrollOffset;
     nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aMetrics.mScrollId);
     if (sf) {
         sf->ScrollToCSSPixelsApproximate(aMetrics.mScrollOffset);
+        actualScrollOffset = CSSPoint::FromAppUnits(sf->GetScrollPosition());
     }
 
     nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aContent);
     if (element) {
+        MaybeAlignAndClampDisplayPort(aMetrics, actualScrollOffset);
         utils->SetDisplayPortForElement(aMetrics.mDisplayPort.x,
                                         aMetrics.mDisplayPort.y,
                                         aMetrics.mDisplayPort.width,
                                         aMetrics.mDisplayPort.height,
                                         element);
     }
+
+    aMetrics.mScrollOffset = actualScrollOffset;
 }
 
 already_AddRefed<nsIDOMWindowUtils>
 APZCCallbackHelper::GetDOMWindowUtils(const nsIDocument* aDoc)
 {
     nsCOMPtr<nsIDOMWindowUtils> utils;
     nsCOMPtr<nsIDOMWindow> window = aDoc->GetDefaultView();
     if (window) {
--- a/widget/xpwidgets/APZCCallbackHelper.h
+++ b/widget/xpwidgets/APZCCallbackHelper.h
@@ -37,19 +37,23 @@ public:
        layers are enabled, this will align the displayport to tile boundaries.
        Setting the scroll position can cause some small adjustments to be made
        to the actual scroll position. aMetrics' display port and scroll position
        will be updated with any modifications made. */
     static void UpdateRootFrame(nsIDOMWindowUtils* aUtils,
                                 FrameMetrics& aMetrics);
 
     /* Applies the scroll parameters from the given FrameMetrics object to the subframe
-       corresponding to the given content object. */
+       corresponding to the given content object. If tiled thebes
+       layers are enabled, this will align the displayport to tile boundaries.
+       Setting the scroll position can cause some small adjustments to be made
+       to the actual scroll position. aMetrics' display port and scroll position
+       will be updated with any modifications made. */
     static void UpdateSubFrame(nsIContent* aContent,
-                               const FrameMetrics& aMetrics);
+                               FrameMetrics& aMetrics);
 
     /* Get the DOMWindowUtils for the window corresponding to the given document. */
     static already_AddRefed<nsIDOMWindowUtils> GetDOMWindowUtils(const nsIDocument* aDoc);
 
     /* Get the DOMWindowUtils for the window corresponding to the givent content
        element. This might be an iframe inside the tab, for instance. */
     static already_AddRefed<nsIDOMWindowUtils> GetDOMWindowUtils(const nsIContent* aContent);