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

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: 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 | « Source/core/page/scrolling/ScrollingConstraints.h ('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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 if (!style()->left().isAuto()) { 322 if (!style()->left().isAuto()) {
323 constraints.setLeftOffset(floatValueForLength(style()->left(), constrain ingRect.width())); 323 constraints.setLeftOffset(floatValueForLength(style()->left(), constrain ingRect.width()));
324 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft); 324 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft);
325 } 325 }
326 326
327 if (!style()->right().isAuto()) { 327 if (!style()->right().isAuto()) {
328 constraints.setRightOffset(floatValueForLength(style()->right(), constra iningRect.width())); 328 constraints.setRightOffset(floatValueForLength(style()->right(), constra iningRect.width()));
329 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeRight); 329 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeRight);
330 } 330 }
331 331
332 float offsetsSum = constraints.rightOffset() + constraints.leftOffset();
Julien - ping for review 2014/05/16 13:17:49 We should rename this to a better name: verticalOf
ostap 2014/05/22 04:33:19 Done.
333 if (offsetsSum > containerContentRect.width().toFloat()
334 || offsetsSum + containerContentRect.width().toFloat() > constrainingRec t.width()) {
335 if (style()->isLeftToRightDirection()) {
336 constraints.setRightOffset(0);
337 constraints.removeAnchorEdge(ViewportConstraints::AnchorEdgeRight);
338 } else {
339 constraints.setLeftOffset(0);
340 constraints.removeAnchorEdge(ViewportConstraints::AnchorEdgeLeft);
Julien - ping for review 2014/05/16 13:17:49 It would be cleaner if we didn't set the anchor ed
ostap 2014/05/22 04:33:19 Done
341 }
342 }
343
332 if (!style()->top().isAuto()) { 344 if (!style()->top().isAuto()) {
333 constraints.setTopOffset(floatValueForLength(style()->top(), constrainin gRect.height())); 345 constraints.setTopOffset(floatValueForLength(style()->top(), constrainin gRect.height()));
334 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop); 346 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop);
335 } 347 }
336 348
337 if (!style()->bottom().isAuto()) { 349 if (!style()->bottom().isAuto()) {
338 constraints.setBottomOffset(floatValueForLength(style()->bottom(), const rainingRect.height() )); 350 constraints.setBottomOffset(floatValueForLength(style()->bottom(), const rainingRect.height()));
339 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeBottom); 351 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeBottom);
340 } 352 }
353
354 offsetsSum = constraints.topOffset() + constraints.bottomOffset();
355 if (offsetsSum > containerContentRect.height().toFloat()
356 || offsetsSum + containerContentRect.height().toFloat() > constrainingRe ct.height()) {
357 constraints.setBottomOffset(0);
358 constraints.removeAnchorEdge(ViewportConstraints::AnchorEdgeBottom);
359 }
Julien - ping for review 2014/05/16 13:17:49 Shouldn't you check if our writing mode is not bot
ostap 2014/05/22 04:33:19 The over-constrained behavior is done similar to p
341 } 360 }
342 361
343 LayoutSize RenderBoxModelObject::stickyPositionOffset() const 362 LayoutSize RenderBoxModelObject::stickyPositionOffset() const
344 { 363 {
345 FloatRect constrainingRect; 364 FloatRect constrainingRect;
346 365
347 ASSERT(hasLayer()); 366 ASSERT(hasLayer());
348 RenderLayer* enclosingClippingLayer = layer()->enclosingOverflowClipLayer(Ex cludeSelf); 367 RenderLayer* enclosingClippingLayer = layer()->enclosingOverflowClipLayer(Ex cludeSelf);
349 if (enclosingClippingLayer) { 368 if (enclosingClippingLayer) {
350 RenderBox* enclosingClippingBox = toRenderBox(enclosingClippingLayer->re nderer()); 369 RenderBox* enclosingClippingBox = toRenderBox(enclosingClippingLayer->re nderer());
(...skipping 2473 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2843 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2825 for (RenderObject* child = startChild; child && child != endChild; ) { 2844 for (RenderObject* child = startChild; child && child != endChild; ) {
2826 // Save our next sibling as moveChildTo will clear it. 2845 // Save our next sibling as moveChildTo will clear it.
2827 RenderObject* nextSibling = child->nextSibling(); 2846 RenderObject* nextSibling = child->nextSibling();
2828 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2847 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2829 child = nextSibling; 2848 child = nextSibling;
2830 } 2849 }
2831 } 2850 }
2832 2851
2833 } // namespace WebCore 2852 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/scrolling/ScrollingConstraints.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698