Changeset 116446 in webkit
- Timestamp:
- May 8, 2012 12:11:14 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r116445 r116446 1 2012-05-08 Shezan Baig <shezbaig.wk@gmail.com> 2 3 offsetLeft broken within CSS3 columns 4 https://bugs.webkit.org/show_bug.cgi?id=34875 5 6 Reviewed by Julien Chaffraix. 7 8 Add test for offsetLeft and offsetTop within multi-columns. 9 10 * fast/block/positioning/offsetLeft-offsetTop-multicolumn-expected.txt: Added. 11 * fast/block/positioning/offsetLeft-offsetTop-multicolumn.html: Added. 12 1 13 2012-05-08 Christophe Dumez <christophe.dumez@intel.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r116438 r116446 1 2012-05-08 Shezan Baig <shezbaig.wk@gmail.com> 2 3 offsetLeft broken within CSS3 columns 4 https://bugs.webkit.org/show_bug.cgi?id=34875 5 6 Reviewed by Julien Chaffraix. 7 8 Reimplement offsetLeft and offsetTop in terms of a new method called 9 'offsetTopLeft'. The new method starts from a reference point (the 10 top-left coordinate of a box or inline) and adjusts this reference 11 point for columns as we traverse each parent. Note that the reference 12 point needs to be adjusted in both dimensions, even though offsetLeft 13 and offsetTop return only one of them. 14 15 A new method called 'offsetForColumns' was added to RenderObject. This 16 method is similar to adjustForColumns, except that it returns the 17 offset instead of modifying a reference. This method is necessary to 18 simplify the implementation of offsetTopLeft. 19 20 Tests: fast/block/positioning/offsetLeft-offsetTop-multicolumn-expected.txt 21 fast/block/positioning/offsetLeft-offsetTop-multicolumn.html 22 23 * rendering/RenderBox.h: 24 (RenderBox): 25 Override offsetLeft and offsetTop. 26 * rendering/RenderBox.cpp: 27 (WebCore::RenderBox::offsetLeft): 28 Implemented in terms of RenderBoxModelObject::offsetTopLeft, using 29 topLeftLocation as startPoint. 30 (WebCore::RenderBox::offsetTop): 31 Implemented in terms of RenderBoxModelObject::offsetTopLeft, using 32 topLeftLocation as startPoint. 33 * rendering/RenderBoxModelObject.cpp: 34 (WebCore::RenderBoxModelObject::offsetTopLeft): 35 New method to compute offsetLeft and offsetTop simultaneously, and 36 adjusting for columns at each parent. 37 (WebCore::RenderBoxModelObject::offsetLeft): 38 Reimplemented in terms of offsetTopLeft. 39 (WebCore::RenderBoxModelObject::offsetTop): 40 Reimplemented in terms of offsetTopLeft. 41 * rendering/RenderBoxModelObject.h: 42 (RenderBoxModelObject): 43 Declare new offsetTopLeft method. 44 * rendering/RenderInline.cpp: 45 (WebCore::RenderInline::offsetLeft): 46 Reimplemented in terms of RenderBoxModelObject::offsetTopLeft. 47 (WebCore::RenderInline::offsetTop): 48 Reimplemented in terms of RenderBoxModelObject::offsetTopLeft. 49 * rendering/RenderObject.h: 50 (RenderObject): 51 (WebCore::RenderObject::offsetForColumns): 52 New helper method to simplify implementation of offsetTopLeft. 53 1 54 2012-03-31 Robert Hogan <robert@webkit.org> 2 55 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r115981 r116446 3913 3913 } 3914 3914 3915 LayoutUnit RenderBox::offsetLeft() const 3916 { 3917 return offsetTopLeft(topLeftLocation()).x(); 3918 } 3919 3920 LayoutUnit RenderBox::offsetTop() const 3921 { 3922 return offsetTopLeft(topLeftLocation()).y(); 3923 } 3924 3915 3925 LayoutPoint RenderBox::flipForWritingModeForChild(const RenderBox* child, const LayoutPoint& point) const 3916 3926 { -
trunk/Source/WebCore/rendering/RenderBox.h
r115981 r116446 434 434 virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 435 435 436 virtual LayoutUnit offsetLeft() const OVERRIDE; 437 virtual LayoutUnit offsetTop() const OVERRIDE; 438 436 439 LayoutPoint flipForWritingModeForChild(const RenderBox* child, const LayoutPoint&) const; 437 440 LayoutUnit flipForWritingMode(LayoutUnit position) const; // The offset is in the block direction (y for horizontal writing modes, x for vertical writing modes). -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r116392 r116446 536 536 } 537 537 538 Layout Unit RenderBoxModelObject::offsetLeft() const538 LayoutPoint RenderBoxModelObject::offsetTopLeft(const LayoutPoint& startPoint) const 539 539 { 540 540 // If the element is the HTML body element or does not have an associated box 541 541 // return 0 and stop this algorithm. 542 542 if (isBody()) 543 return ZERO_LAYOUT_UNIT;543 return LayoutPoint(); 544 544 545 RenderBoxModelObject* offsetPar = offsetParent();546 LayoutUnit xPos = (isBox() ? toRenderBox(this)->left() : ZERO_LAYOUT_UNIT);545 LayoutPoint referencePoint = startPoint; 546 referencePoint.move(parent()->offsetForColumns(referencePoint)); 547 547 548 548 // If the offsetParent of the element is null, or is the HTML body element, 549 549 // return the distance between the canvas origin and the left border edge 550 550 // of the element and stop this algorithm. 551 if ( offsetPar) {552 if (offsetPar ->isBox() && !offsetPar->isBody())553 xPos -= toRenderBox(offsetPar)->borderLeft();551 if (const RenderBoxModelObject* offsetParent = this->offsetParent()) { 552 if (offsetParent->isBox() && !offsetParent->isBody()) 553 referencePoint.move(-toRenderBox(offsetParent)->borderLeft(), -toRenderBox(offsetParent)->borderTop()); 554 554 if (!isPositioned()) { 555 555 if (isRelPositioned()) 556 xPos += relativePositionOffsetX();557 RenderObject* curr = parent();558 while (curr && curr != offsetPar) {556 referencePoint.move(relativePositionOffset()); 557 const RenderObject* curr = parent(); 558 while (curr != offsetParent) { 559 559 // FIXME: What are we supposed to do inside SVG content? 560 560 if (curr->isBox() && !curr->isTableRow()) 561 xPos += toRenderBox(curr)->left(); 561 referencePoint.moveBy(toRenderBox(curr)->topLeftLocation()); 562 referencePoint.move(curr->parent()->offsetForColumns(referencePoint)); 562 563 curr = curr->parent(); 563 564 } 564 if (offsetPar->isBox() && offsetPar->isBody() && !offsetPar->isRelPositioned() && !offsetPar->isPositioned()) 565 xPos += toRenderBox(offsetPar)->left(); 566 } 567 } 568 569 return xPos; 565 if (offsetParent->isBox() && offsetParent->isBody() && !offsetParent->isRelPositioned() && !offsetParent->isPositioned()) 566 referencePoint.moveBy(toRenderBox(offsetParent)->topLeftLocation()); 567 } 568 } 569 570 return referencePoint; 571 } 572 573 LayoutUnit RenderBoxModelObject::offsetLeft() const 574 { 575 // Note that RenderInline and RenderBox override this to pass a different 576 // startPoint to offsetTopLeft. 577 return offsetTopLeft(LayoutPoint()).x(); 570 578 } 571 579 572 580 LayoutUnit RenderBoxModelObject::offsetTop() const 573 581 { 574 // If the element is the HTML body element or does not have an associated box 575 // return 0 and stop this algorithm. 576 if (isBody()) 577 return ZERO_LAYOUT_UNIT; 578 579 RenderBoxModelObject* offsetPar = offsetParent(); 580 LayoutUnit yPos = (isBox() ? toRenderBox(this)->top() : ZERO_LAYOUT_UNIT); 581 582 // If the offsetParent of the element is null, or is the HTML body element, 583 // return the distance between the canvas origin and the top border edge 584 // of the element and stop this algorithm. 585 if (offsetPar) { 586 if (offsetPar->isBox() && !offsetPar->isBody()) 587 yPos -= toRenderBox(offsetPar)->borderTop(); 588 if (!isPositioned()) { 589 if (isRelPositioned()) 590 yPos += relativePositionOffsetY(); 591 RenderObject* curr = parent(); 592 while (curr && curr != offsetPar) { 593 // FIXME: What are we supposed to do inside SVG content? 594 if (curr->isBox() && !curr->isTableRow()) 595 yPos += toRenderBox(curr)->top(); 596 curr = curr->parent(); 597 } 598 if (offsetPar->isBox() && offsetPar->isBody() && !offsetPar->isRelPositioned() && !offsetPar->isPositioned()) 599 yPos += toRenderBox(offsetPar)->top(); 600 } 601 } 602 return yPos; 582 // Note that RenderInline and RenderBox override this to pass a different 583 // startPoint to offsetTopLeft. 584 return offsetTopLeft(LayoutPoint()).y(); 603 585 } 604 586 -
trunk/Source/WebCore/rendering/RenderBoxModelObject.h
r115846 r116446 228 228 }; 229 229 230 LayoutPoint offsetTopLeft(const LayoutPoint&) const; 231 230 232 void calculateBackgroundImageGeometry(const FillLayer*, const LayoutRect& paintRect, BackgroundImageGeometry&); 231 233 void getBorderEdgeInfo(class BorderEdge[], const RenderStyle*, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const; -
trunk/Source/WebCore/rendering/RenderInline.cpp
r116174 r116446 679 679 LayoutUnit RenderInline::offsetLeft() const 680 680 { 681 Layout Unit x = RenderBoxModelObject::offsetLeft();681 LayoutPoint topLeft; 682 682 if (InlineBox* firstBox = firstLineBoxIncludingCulling()) 683 x += firstBox->x();684 return x;683 topLeft = flooredLayoutPoint(firstBox->topLeft()); 684 return offsetTopLeft(topLeft).x(); 685 685 } 686 686 687 687 LayoutUnit RenderInline::offsetTop() const 688 688 { 689 Layout Unit y = RenderBoxModelObject::offsetTop();689 LayoutPoint topLeft; 690 690 if (InlineBox* firstBox = firstLineBoxIncludingCulling()) 691 y += firstBox->y();692 return y;691 topLeft = flooredLayoutPoint(firstBox->topLeft()); 692 return offsetTopLeft(topLeft).y(); 693 693 } 694 694 -
trunk/Source/WebCore/rendering/RenderObject.h
r116373 r116446 766 766 // offset to the given size. 767 767 virtual void adjustForColumns(LayoutSize&, const LayoutPoint&) const { } 768 LayoutSize offsetForColumns(const LayoutPoint& point) const 769 { 770 LayoutSize offset; 771 adjustForColumns(offset, point); 772 return offset; 773 } 768 774 769 775 virtual unsigned int length() const { return 1; }
Note: See TracChangeset
for help on using the changeset viewer.