package com.vaadin.client.ui;
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.SimplePanel;
import com.vaadin.client.ApplicationConnection;
+import com.vaadin.client.BrowserInfo;
import com.vaadin.client.Focusable;
import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler;
touchScrollHandler = TouchScrollDelegate.enableTouchScrolling(this);
}
touchScrollHandler.addElement(contentNode);
+
+ /*
+ * Shake up the DOM a bit to make the window shed unnecessary scroll
+ * bars and resize correctly afterwards. This resulting code took over a
+ * week to summon forth, and involved some pretty hairy black magic.
+ * Don't touch it unless you know what you're doing! Fixes ticket
+ * #12727.
+ *
+ * This solution comes from ticket #11994: Windows get unnecessary
+ * scroll bars in WebKit when content is 100% wide.
+ */
+ if (BrowserInfo.get().isWebkit()) {
+ Scheduler.get().scheduleFinally(new ScheduledCommand() {
+ @Override
+ public void execute() {
+ final com.google.gwt.dom.client.Element scrollable = contentNode
+ .getFirstChildElement();
+ final String oldWidth = scrollable.getStyle().getWidth();
+ final String oldHeight = scrollable.getStyle().getHeight();
+
+ scrollable.getStyle().setWidth(110, Unit.PCT);
+ scrollable.getOffsetWidth();
+ scrollable.getStyle().setProperty("width", oldWidth);
+
+ scrollable.getStyle().setHeight(110, Unit.PCT);
+ scrollable.getOffsetHeight();
+ scrollable.getStyle().setProperty("height", oldHeight);
+ }
+ });
+ }
+
}
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.panel.WebkitScrollbarTest?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>panelShouldNotHaveScrollbars</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
--- /dev/null
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.tests.components.panel;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+
+@SuppressWarnings("serial")
+public class WebkitScrollbarTest extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Panel panel = new Panel();
+
+ VerticalLayout content = new VerticalLayout();
+ panel.setContent(content);
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.setHeight(null);
+ gridLayout.setWidth(100, Unit.PERCENTAGE);
+ content.addComponent(gridLayout);
+
+ ListSelect listSelect = new ListSelect();
+
+ listSelect.setWidth(100, Unit.PERCENTAGE);
+ listSelect.setHeight(300, Unit.PIXELS);
+
+ gridLayout.addComponent(listSelect);
+
+ gridLayout.setMargin(true);
+
+ setContent(panel);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "When opening the window, it should NOT contain a horizontal";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12727;
+ }
+
+}
--- /dev/null
+package com.vaadin.tests.tickets;
+
+import java.util.ArrayList;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ * Test for #12727: Panels get unnecessary scroll bars in WebKit when content is
+ * 100% wide.
+ */
+@SuppressWarnings("serial")
+public class Ticket12727 extends UI {
+
+ @Override
+ protected void init(VaadinRequest request) {
+ Panel panel = new Panel();
+
+ VerticalLayout content = new VerticalLayout();
+ panel.setContent(content);
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.setHeight(null);
+ gridLayout.setWidth(100, Unit.PERCENTAGE);
+ content.addComponent(gridLayout);
+
+ ListSelect listSelect = new ListSelect();
+
+ listSelect.setWidth(100, Unit.PERCENTAGE);
+ listSelect.setHeight(500, Unit.PIXELS);
+
+ gridLayout.addComponent(listSelect);
+
+ ArrayList<String> values = new ArrayList<String>();
+ values.add("Value 1");
+ values.add("Value 2");
+ values.add("Value 3");
+
+ ComboBox comboBox = new ComboBox(null, values);
+ gridLayout.addComponent(comboBox);
+
+ gridLayout.setMargin(true);
+
+ setContent(panel);
+ }
+}