List of usage examples for com.google.gwt.dom.client Style getOverflow
public String getOverflow()
From source file:com.vaadin.client.LayoutManager.java
License:Apache License
private int measureConnectors(LayoutDependencyTree layoutDependencyTree, boolean measureAll) { Profiler.enter("Layout overflow fix handling"); JsArrayString pendingOverflowConnectorsIds = pendingOverflowFixes.dump(); int pendingOverflowCount = pendingOverflowConnectorsIds.length(); ConnectorMap connectorMap = ConnectorMap.get(connection); if (pendingOverflowCount > 0) { HashMap<Element, String> originalOverflows = new HashMap<Element, String>(); FastStringSet delayedOverflowFixes = FastStringSet.create(); // First set overflow to hidden (and save previous value so it can // be restored later) for (int i = 0; i < pendingOverflowCount; i++) { String connectorId = pendingOverflowConnectorsIds.get(i); ComponentConnector componentConnector = (ComponentConnector) connectorMap.getConnector(connectorId); if (delayOverflowFix(componentConnector)) { delayedOverflowFixes.add(connectorId); continue; }/*w w w.j a va 2 s.c om*/ if (debugLogging) { getLogger().info("Doing overflow fix for " + Util.getConnectorString(componentConnector) + " in " + Util.getConnectorString(componentConnector.getParent())); } Profiler.enter("Overflow fix apply"); Element parentElement = componentConnector.getWidget().getElement().getParentElement(); Style style = parentElement.getStyle(); String originalOverflow = style.getOverflow(); if (originalOverflow != null && !originalOverflows.containsKey(parentElement)) { // Store original value for restore, but only the first time // the value is changed originalOverflows.put(parentElement, originalOverflow); } style.setOverflow(Overflow.HIDDEN); Profiler.leave("Overflow fix apply"); } pendingOverflowFixes.removeAll(delayedOverflowFixes); JsArrayString remainingOverflowFixIds = pendingOverflowFixes.dump(); int remainingCount = remainingOverflowFixIds.length(); Profiler.enter("Overflow fix reflow"); // Then ensure all scrolling elements are reflowed by measuring for (int i = 0; i < remainingCount; i++) { ComponentConnector componentConnector = (ComponentConnector) connectorMap .getConnector(remainingOverflowFixIds.get(i)); componentConnector.getWidget().getElement().getParentElement().getOffsetHeight(); } Profiler.leave("Overflow fix reflow"); Profiler.enter("Overflow fix restore"); // Finally restore old overflow value and update bookkeeping for (int i = 0; i < remainingCount; i++) { String connectorId = remainingOverflowFixIds.get(i); ComponentConnector componentConnector = (ComponentConnector) connectorMap.getConnector(connectorId); Element parentElement = componentConnector.getWidget().getElement().getParentElement(); parentElement.getStyle().setProperty("overflow", originalOverflows.get(parentElement)); layoutDependencyTree.setNeedsMeasure(componentConnector, true); } Profiler.leave("Overflow fix restore"); if (!pendingOverflowFixes.isEmpty()) { getLogger().info("Did overflow fix for " + remainingCount + " elements"); } pendingOverflowFixes = delayedOverflowFixes; } Profiler.leave("Layout overflow fix handling"); int measureCount = 0; if (measureAll) { Profiler.enter("Layout measureAll"); JsArrayObject<ComponentConnector> allConnectors = connectorMap.getComponentConnectorsAsJsArray(); int size = allConnectors.size(); // Find connectors that should actually be measured JsArrayObject<ComponentConnector> connectors = JsArrayObject.createArray().cast(); for (int i = 0; i < size; i++) { ComponentConnector candidate = allConnectors.get(i); if (!Util.shouldSkipMeasurementOfConnector(candidate) && needsMeasure(candidate.getWidget().getElement())) { connectors.add(candidate); } } int connectorCount = connectors.size(); for (int i = 0; i < connectorCount; i++) { measureConnector(connectors.get(i)); } for (int i = 0; i < connectorCount; i++) { layoutDependencyTree.setNeedsMeasure(connectors.get(i), false); } measureCount += connectorCount; Profiler.leave("Layout measureAll"); } Profiler.enter("Layout measure from tree"); while (layoutDependencyTree.hasConnectorsToMeasure()) { JsArrayString measureTargets = layoutDependencyTree.getMeasureTargetsJsArray(); int length = measureTargets.length(); for (int i = 0; i < length; i++) { ComponentConnector connector = (ComponentConnector) connectorMap .getConnector(measureTargets.get(i)); measureConnector(connector); measureCount++; } for (int i = 0; i < length; i++) { ComponentConnector connector = (ComponentConnector) connectorMap .getConnector(measureTargets.get(i)); layoutDependencyTree.setNeedsMeasure(connector, false); } } Profiler.leave("Layout measure from tree"); return measureCount; }
From source file:gwt.material.design.addins.client.cutout.MaterialCutOut.java
License:Apache License
/** * Opens the dialog cut out taking all the screen. The target element should * be set before calling this method.//from ww w . ja va 2 s. c om * * @throws IllegalStateException if the target element is <code>null</code> * @see #setTarget(Widget) */ public void open() { setCutOutStyle(); if (targetElement == null) { throw new IllegalStateException("The target element should be set before calling open()."); } targetElement.scrollIntoView(); if (computedBackgroundColor == null) { setupComputedBackgroundColor(); } //temporarily disables scrolling by setting the overflow of the page to hidden Style docStyle = Document.get().getDocumentElement().getStyle(); viewportOverflow = docStyle.getOverflow(); docStyle.setProperty("overflow", "hidden"); if (backgroundSize == null) { backgroundSize = body().width() + 300 + "px"; } setupTransition(); if (animated) { focusElement.getStyle().setProperty("boxShadow", "0px 0px 0px 0rem " + computedBackgroundColor); //the animation will take place after the boxshadow is set by the deferred command Scheduler.get().scheduleDeferred(() -> { focusElement.getStyle().setProperty("boxShadow", "0px 0px 0px " + backgroundSize + " " + computedBackgroundColor); }); } else { focusElement.getStyle().setProperty("boxShadow", "0px 0px 0px " + backgroundSize + " " + computedBackgroundColor); } if (circle) { focusElement.getStyle().setProperty("WebkitBorderRadius", "50%"); focusElement.getStyle().setProperty("borderRadius", "50%"); // Temporary fixed for the IOS Issue on recalculation of the border radius focusElement.getStyle().setProperty("webkitBorderTopLeftRadius", "49.9%"); focusElement.getStyle().setProperty("borderTopLeftRadius", "49.9%"); } else { focusElement.getStyle().clearProperty("WebkitBorderRadius"); focusElement.getStyle().clearProperty("borderRadius"); focusElement.getStyle().clearProperty("webkitBorderTopLeftRadius"); focusElement.getStyle().clearProperty("borderTopLeftRadius"); } setupCutOutPosition(focusElement, targetElement, cutOutPadding, circle); setupWindowHandlers(); getElement().getStyle().clearDisplay(); // verify if the component is added to the document (via UiBinder for // instance) if (getParent() == null) { autoAddedToDocument = true; RootPanel.get().add(this); } OpenEvent.fire(this, this); }
From source file:gwt.material.design.addins.client.ui.MaterialCutOut.java
License:Apache License
/** * Opens the modal cut out taking all the screen. The target element should * be set before calling this method.//from www . ja va 2 s.co m * * @throws IllegalStateException * if the target element is <code>null</code> * @see #setTargetElement(Element) */ public void openCutOut() { if (targetElement == null) { throw new IllegalStateException("The target element should be set before calling openCutOut()."); } targetElement.scrollIntoView(); if (computedBackgroundColor == null) { setupComputedBackgroundColor(); } //temporarily disables scrolling by setting the overflow of the page to hidden Style docStyle = Document.get().getDocumentElement().getStyle(); viewportOverflow = docStyle.getOverflow(); docStyle.setProperty("overflow", "hidden"); setupTransition(); if (animated) { focus.getStyle().setProperty("boxShadow", "0px 0px 0px 0rem " + computedBackgroundColor); //the animation will take place after the boxshadow is set by the deferred command Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { focus.getStyle().setProperty("boxShadow", "0px 0px 0px " + backgroundSize + " " + computedBackgroundColor); } }); } else { focus.getStyle().setProperty("boxShadow", "0px 0px 0px " + backgroundSize + " " + computedBackgroundColor); } if (circle) { focus.getStyle().setProperty("WebkitBorderRadius", "50%"); focus.getStyle().setProperty("borderRadius", "50%"); } else { focus.getStyle().clearProperty("WebkitBorderRadius"); focus.getStyle().clearProperty("borderRadius"); } setupCutOutPosition(focus, targetElement, cutOutPadding, circle); setupWindowHandlers(); getElement().getStyle().clearDisplay(); // verify if the component is added to the document (via UiBinder for // instance) if (getParent() == null) { autoAddedToDocument = true; RootPanel.get().add(this); } }
From source file:org.cruxframework.crux.core.client.utils.DOMUtils.java
License:Apache License
public static boolean isOverflowEnabled(Element e) { Style style = e.getStyle(); String overflow = style.getOverflow() + style.getOverflowX() + style.getOverflowY(); return overflow.contains("auto") || overflow.contains("scroll"); }
From source file:org.rstudio.core.client.widget.RStudioDataGrid.java
License:Open Source License
@Override public void onAttach() { super.onAttach(); // None of the below is necessary unless on MacOS since that's the only // platform that uses overlay scrollbars. if (!BrowseCap.isMacintosh()) return;/*from w ww .j ava2 s.c om*/ // GWT's DataGrid implementation adds a handful of nodes with aggressive // inline styles in the header and footer of the grid. They're designed to // help with scrolling, but in newer versions of Chromium, they cause // horizontal overlay scrollbars to appear when the grid is created and // whenever it's resized. The below tweaks these elements so that they // don't have a scrollbar. // // Typically we'd use CSS here but these elements are buried, have no // assigned class, and have all their style attributes applied inline, so // instead we scan the attached DOM subtree and change the inline styles. Element parent = getElement().getParentElement().getParentElement(); List<Node> matches = DomUtils.findNodes(parent, 10, // Max results 3, // Recurse depth false, // Check siblings node -> { // Ignore text nodes, etc. if (node.getNodeType() != Node.ELEMENT_NODE) return false; com.google.gwt.dom.client.Style style = Element.as(node).getStyle(); // The scroll helpers are hidden, and set to appear behind the grid. return style.getZIndex() == "-1" && style.getOverflow() == "scroll" && style.getVisibility() == "hidden"; }); for (Node match : matches) { // Don't show scrollbars on these elements Element.as(match).getStyle().setOverflow(Overflow.HIDDEN); } }