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

Side by Side Diff: Source/core/rendering/RenderBoxModelObject.cpp

Issue 267063007: Fix overconstrained behaviour for position: sticky. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated by review comments. Created 6 years, 7 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/css/sticky/sticky-vertically-overconstrained-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 if (containingBlock->hasOverflowClip()) { 313 if (containingBlock->hasOverflowClip()) {
314 IntSize scrollOffset = containingBlock->layer()->scrollableArea()->adjus tedScrollOffset(); 314 IntSize scrollOffset = containingBlock->layer()->scrollableArea()->adjus tedScrollOffset();
315 stickyLocation -= scrollOffset; 315 stickyLocation -= scrollOffset;
316 } 316 }
317 317
318 // We can't call localToAbsolute on |this| because that will recur. FIXME: F or now, assume that |this| is not transformed. 318 // We can't call localToAbsolute on |this| because that will recur. FIXME: F or now, assume that |this| is not transformed.
319 FloatRect absoluteStickyBoxRect(absContainerFrame.location() + stickyLocatio n, flippedStickyBoxRect.size()); 319 FloatRect absoluteStickyBoxRect(absContainerFrame.location() + stickyLocatio n, flippedStickyBoxRect.size());
320 constraints.setAbsoluteStickyBoxRect(absoluteStickyBoxRect); 320 constraints.setAbsoluteStickyBoxRect(absoluteStickyBoxRect);
321 321
322 if (!style()->left().isAuto()) { 322 float horizontalOffsets = constraints.rightOffset() + constraints.leftOffset ();
323 bool skipRight = false;
324 bool skipLeft = false;
325 if (!style()->left().isAuto() && !style()->right().isAuto()) {
326 if (horizontalOffsets > containerContentRect.width().toFloat()
327 || horizontalOffsets + containerContentRect.width().toFloat() > cons trainingRect.width()) {
328 skipRight = style()->isLeftToRightDirection();
329 skipLeft = !skipRight;
330 }
331 }
332
333 if (!style()->left().isAuto() && !skipLeft) {
323 constraints.setLeftOffset(floatValueForLength(style()->left(), constrain ingRect.width())); 334 constraints.setLeftOffset(floatValueForLength(style()->left(), constrain ingRect.width()));
324 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft); 335 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft);
325 } 336 }
326 337
327 if (!style()->right().isAuto()) { 338 if (!style()->right().isAuto() && !skipRight) {
328 constraints.setRightOffset(floatValueForLength(style()->right(), constra iningRect.width())); 339 constraints.setRightOffset(floatValueForLength(style()->right(), constra iningRect.width()));
329 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeRight); 340 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeRight);
330 } 341 }
331 342
343 bool skipBottom = false;
344 // FIXME(ostap): Exclude top or bottom edge offset depending on the writing mode when related
345 // sections are fixed in spec: http://lists.w3.org/Archives/Public/www-style /2014May/0286.html
346 float verticalOffsets = constraints.topOffset() + constraints.bottomOffset() ;
347 if (!style()->top().isAuto() && !style()->bottom().isAuto()) {
348 if (verticalOffsets > containerContentRect.height().toFloat()
349 || verticalOffsets + containerContentRect.height().toFloat() > const rainingRect.height()) {
350 skipBottom = true;
351 }
352 }
353
332 if (!style()->top().isAuto()) { 354 if (!style()->top().isAuto()) {
333 constraints.setTopOffset(floatValueForLength(style()->top(), constrainin gRect.height())); 355 constraints.setTopOffset(floatValueForLength(style()->top(), constrainin gRect.height()));
334 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop); 356 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop);
335 } 357 }
336 358
337 if (!style()->bottom().isAuto()) { 359 if (!style()->bottom().isAuto() && !skipBottom) {
338 constraints.setBottomOffset(floatValueForLength(style()->bottom(), const rainingRect.height() )); 360 constraints.setBottomOffset(floatValueForLength(style()->bottom(), const rainingRect.height()));
339 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeBottom); 361 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeBottom);
340 } 362 }
341 } 363 }
342 364
343 LayoutSize RenderBoxModelObject::stickyPositionOffset() const 365 LayoutSize RenderBoxModelObject::stickyPositionOffset() const
344 { 366 {
345 FloatRect constrainingRect; 367 FloatRect constrainingRect;
346 368
347 ASSERT(hasLayer()); 369 ASSERT(hasLayer());
348 RenderLayer* enclosingClippingLayer = layer()->enclosingOverflowClipLayer(Ex cludeSelf); 370 RenderLayer* enclosingClippingLayer = layer()->enclosingOverflowClipLayer(Ex cludeSelf);
(...skipping 2475 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2846 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2825 for (RenderObject* child = startChild; child && child != endChild; ) { 2847 for (RenderObject* child = startChild; child && child != endChild; ) {
2826 // Save our next sibling as moveChildTo will clear it. 2848 // Save our next sibling as moveChildTo will clear it.
2827 RenderObject* nextSibling = child->nextSibling(); 2849 RenderObject* nextSibling = child->nextSibling();
2828 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2850 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2829 child = nextSibling; 2851 child = nextSibling;
2830 } 2852 }
2831 } 2853 }
2832 2854
2833 } // namespace WebCore 2855 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/sticky/sticky-vertically-overconstrained-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698