Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3897)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/overlays/strip/StripStacker.java

Issue 1836453003: Use a scrollable tab strip on tablets at small widths (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tiny bit of clean up Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/overlays/strip/StripStacker.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/overlays/strip/StripStacker.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/overlays/strip/StripStacker.java
index 02e24cbeaf6ef130f96aa61597d8b9aff10c68bf..41968dde3f6b7fad82a7bbed27405266add60b46 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/overlays/strip/StripStacker.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/overlays/strip/StripStacker.java
@@ -5,43 +5,88 @@
package org.chromium.chrome.browser.compositor.overlays.strip;
import org.chromium.chrome.browser.compositor.layouts.Layout;
+import org.chromium.chrome.browser.util.MathUtils;
/**
* An interface that defines how to stack tabs and how they should look visually. This lets
* certain components customize how the {@link StripLayoutHelper} functions and how other
* {@link Layout}s visually order tabs.
*/
-public interface StripStacker {
+public abstract class StripStacker {
/**
* @return Whether or not the close button can be shown. Note that even if it can be shown,
* it might not be due to how much of the tab is actually visible to preserve proper hit
* target sizes.
*/
- public boolean canShowCloseButton();
-
- /**
- * @return Whether or not the title text can slide to the right to stay visible.
- */
- public boolean canSlideTitleText();
+ public boolean canShowCloseButton() {
+ return true;
+ }
/**
* This gives the implementing class a chance to determine how the tabs should be ordered
- * visually. The positioning logic is the same regardless, this just has to do with visual
+ * visually. The positioning logic is the same regardless, this just has to do with visual
* stacking.
*
* @param selectedIndex The selected index of the tabs.
* @param indexOrderedTabs A list of tabs ordered by index.
- * @param outVisualOrderedTabs The new list of tabs, ordered from back to front visually.
+ * @param outVisualOrderedTabs The new list of tabs, ordered from back (low z-index) to front
+ * (high z-index) visually.
*/
public void createVisualOrdering(int selectedIndex, StripLayoutTab[] indexOrderedTabs,
- StripLayoutTab[] outVisualOrderedTabs);
+ StripLayoutTab[] outVisualOrderedTabs) {
+ assert indexOrderedTabs.length == outVisualOrderedTabs.length;
+
+ selectedIndex = MathUtils.clamp(selectedIndex, 0, indexOrderedTabs.length);
+
+ int outIndex = 0;
+ for (int i = 0; i < selectedIndex; i++) {
+ outVisualOrderedTabs[outIndex++] = indexOrderedTabs[i];
+ }
+
+ for (int i = indexOrderedTabs.length - 1; i >= selectedIndex; --i) {
+ outVisualOrderedTabs[outIndex++] = indexOrderedTabs[i];
+ }
+ }
+
+ /**
+ * Computes and sets the draw X, draw Y, visibility and content offset for each tab.
+ *
+ * @param selectedIndex The selected index of the tabs.
+ * @param indexOrderedTabs A list of tabs ordered by index.
+ * @param tabStackWidth The width of a tab when it's stacked behind another tab.
+ * @param maxTabsToStack The maximum number of tabs to stack.
+ * @param tabOverlapWidth The amount tabs overlap.
+ * @param stripLeftMargin The left margin of the tab strip.
+ * @param stripRightMargin The right margin of the tab strip.
+ * @param stripWidth The width of the tab strip.
+ * @param inReorderMode Whether the strip is in reorder mode.
+ */
+ public abstract void setTabOffsets(int selectedIndex, StripLayoutTab[] indexOrderedTabs,
+ float tabStackWidth, int maxTabsToStack, float tabOverlapWidth, float stripLeftMargin,
+ float stripRightMargin, float stripWidth, boolean inReorderMode);
+
+ /**
+ * Computes the X offset for the new tab button.
+ *
+ * @param indexOrderedTabs A list of tabs ordered by index.
+ * @param tabOverlapWidth The amount tabs overlap.
+ * @param stripLeftMargin The left margin of the tab strip.
+ * @param stripRightMargin The right margin of the tab strip.
+ * @param stripWidth The width of the tab strip.
+ * @param mNewTabButtonWidth The width of the new tab button.
+ * @return The x offset for the new tab button.
+ */
+ public abstract float computeNewTabButtonOffset(StripLayoutTab[] indexOrderedTabs,
+ float tabOverlapWidth, float stripLeftMargin, float stripRightMargin, float stripWidth,
+ float mNewTabButtonWidth);
/**
- * Performs an occlusion pass, setting the visibility on tabs depending on whether or not they
- * overlap each other perfectly. This is relegated to this interface because the implementing
- * class knows the proper visual order to optimize this pass.
+ * Performs an occlusion pass, setting the visibility on tabs. This is relegated to this
+ * interface because the implementing class knows the proper visual order to optimize this pass.
* @param selectedIndex The selected index of the tabs.
* @param indexOrderedTabs A list of tabs ordered by index.
+ * @param stripWidth The width of the tab strip.
*/
- public void performOcclusionPass(int selectedIndex, StripLayoutTab[] indexOrderedTabs);
+ public abstract void performOcclusionPass(int selectedIndex, StripLayoutTab[] indexOrderedTabs,
+ float stripWidth);
}

Powered by Google App Engine
This is Rietveld 408576698