Changeset 164837 in webkit


Ignore:
Timestamp:
Feb 27, 2014 3:52:23 PM (10 years ago)
Author:
stavila@adobe.com
Message:

[CSS Regions] Move named-flow specific method decorationsClipRectForBoxInRegion to RenderNamedFlowThread
https://bugs.webkit.org/show_bug.cgi?id=129428

Reviewed by Andreas Kling.

Since the decorationsClipRectForBoxInRegion method is a named flow specific method, it makes
sense to be in the named flow specific class, RenderNamedFlowThread, instead of the more
generic RenderFlowThread.

No new tests required. No new functionality.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::paintObject):

  • rendering/RenderFlowThread.cpp:
  • rendering/RenderFlowThread.h:
  • rendering/RenderNamedFlowThread.cpp:

(WebCore::RenderNamedFlowThread::decorationsClipRectForBoxInNamedFlowFragment):

  • rendering/RenderNamedFlowThread.h:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r164834 r164837  
     12014-02-27  Radu Stavila  <stavila@adobe.com>
     2
     3        [CSS Regions] Move named-flow specific method decorationsClipRectForBoxInRegion to RenderNamedFlowThread
     4        https://bugs.webkit.org/show_bug.cgi?id=129428
     5
     6        Reviewed by Andreas Kling.
     7
     8        Since the decorationsClipRectForBoxInRegion method is a named flow specific method, it makes
     9        sense to be in the named flow specific class, RenderNamedFlowThread, instead of the more
     10        generic RenderFlowThread.
     11
     12        No new tests required. No new functionality.
     13
     14        * rendering/RenderBlock.cpp:
     15        (WebCore::RenderBlock::paintObject):
     16        * rendering/RenderFlowThread.cpp:
     17        * rendering/RenderFlowThread.h:
     18        * rendering/RenderNamedFlowThread.cpp:
     19        (WebCore::RenderNamedFlowThread::decorationsClipRectForBoxInNamedFlowFragment):
     20        * rendering/RenderNamedFlowThread.h:
     21
    1222014-02-27  Zoltan Horvath  <zoltan@webkit.org>
    223
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r164805 r164837  
    23022302            bool didClipToRegion = false;
    23032303           
    2304             if (paintInfo.paintContainer && paintInfo.renderNamedFlowFragment && paintInfo.paintContainer->isRenderFlowThread()) {
     2304            if (paintInfo.paintContainer && paintInfo.renderNamedFlowFragment && paintInfo.paintContainer->isRenderNamedFlowThread()) {
    23052305                // If this box goes beyond the current region, then make sure not to overflow the region.
    23062306                // This (overflowing region X altough also fragmented to region X+1) could happen when one of this box's children
     
    23112311                didClipToRegion = true;
    23122312
    2313                 paintInfo.context->clip(toRenderFlowThread(paintInfo.paintContainer)->decorationsClipRectForBoxInRegion(*this, *paintInfo.renderNamedFlowFragment));
     2313                paintInfo.context->clip(toRenderNamedFlowThread(paintInfo.paintContainer)->decorationsClipRectForBoxInNamedFlowFragment(*this, *paintInfo.renderNamedFlowFragment));
    23142314            }
    23152315
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r164594 r164837  
    12631263}
    12641264
    1265 LayoutRect RenderFlowThread::decorationsClipRectForBoxInRegion(const RenderBox& box, RenderRegion& region) const
    1266 {
    1267     LayoutRect visualOverflowRect = region.visualOverflowRectForBox(&box);
    1268     LayoutUnit initialLogicalX = style().isHorizontalWritingMode() ? visualOverflowRect.x() : visualOverflowRect.y();
    1269 
    1270     // The visual overflow rect returned by visualOverflowRectForBox is already flipped but the
    1271     // RenderRegion::rectFlowPortionForBox method expects it unflipped.
    1272     flipForWritingModeLocalCoordinates(visualOverflowRect);
    1273     visualOverflowRect = region.rectFlowPortionForBox(&box, visualOverflowRect);
    1274    
    1275     // Now flip it again.
    1276     flipForWritingModeLocalCoordinates(visualOverflowRect);
    1277    
    1278     // Layers are in physical coordinates so the origin must be moved to the physical top-left of the flowthread.
    1279     if (style().isFlippedBlocksWritingMode()) {
    1280         if (style().isHorizontalWritingMode())
    1281             visualOverflowRect.moveBy(LayoutPoint(0, height()));
    1282         else
    1283             visualOverflowRect.moveBy(LayoutPoint(width(), 0));
    1284     }
    1285 
    1286     const RenderBox* iterBox = &box;
    1287     while (iterBox && iterBox != this) {
    1288         RenderBlock* containerBlock = iterBox->containingBlock();
    1289 
    1290         // FIXME: This doesn't work properly with flipped writing modes.
    1291         // https://bugs.webkit.org/show_bug.cgi?id=125149
    1292         if (iterBox->isPositioned()) {
    1293             // For positioned elements, just use the layer's absolute bounding box.
    1294             visualOverflowRect.moveBy(iterBox->layer()->absoluteBoundingBox().location());
    1295             break;
    1296         }
    1297 
    1298         LayoutRect currentBoxRect = iterBox->frameRect();
    1299         if (iterBox->style().isFlippedBlocksWritingMode()) {
    1300             if (iterBox->style().isHorizontalWritingMode())
    1301                 currentBoxRect.setY(currentBoxRect.height() - currentBoxRect.maxY());
    1302             else
    1303                 currentBoxRect.setX(currentBoxRect.width() - currentBoxRect.maxX());
    1304         }
    1305 
    1306         if (containerBlock->style().writingMode() != iterBox->style().writingMode())
    1307             iterBox->flipForWritingMode(currentBoxRect);
    1308 
    1309         visualOverflowRect.moveBy(currentBoxRect.location());
    1310         iterBox = containerBlock;
    1311     }
    1312 
    1313     // Since the purpose of this method is to make sure the borders of a fragmented
    1314     // element don't overflow the region in the fragmentation direction, there's no
    1315     // point in restricting the clipping rect on the logical X axis.
    1316     // This also saves us the trouble of handling percent-based widths and margins
    1317     // since the absolute bounding box of a positioned element would not contain
    1318     // the correct coordinates relative to the region we're interested in, but rather
    1319     // relative to the actual flow thread.
    1320     if (style().isHorizontalWritingMode()) {
    1321         if (initialLogicalX < visualOverflowRect.x())
    1322             visualOverflowRect.shiftXEdgeTo(initialLogicalX);
    1323         if (visualOverflowRect.width() < frameRect().width())
    1324             visualOverflowRect.setWidth(frameRect().width());
    1325     } else {
    1326         if (initialLogicalX < visualOverflowRect.y())
    1327             visualOverflowRect.shiftYEdgeTo(initialLogicalX);
    1328         if (visualOverflowRect.height() < frameRect().height())
    1329             visualOverflowRect.setHeight(frameRect().height());
    1330     }
    1331 
    1332     return visualOverflowRect;
    1333 }
    1334 
    13351265void RenderFlowThread::flipForWritingModeLocalCoordinates(LayoutRect& rect) const
    13361266{
  • trunk/Source/WebCore/rendering/RenderFlowThread.h

    r164716 r164837  
    200200    LayoutRect mapFromFlowThreadToLocal(const RenderBox*, const LayoutRect&) const;
    201201    LayoutRect mapFromLocalToFlowThread(const RenderBox*, const LayoutRect&) const;
    202    
    203     LayoutRect decorationsClipRectForBoxInRegion(const RenderBox&, RenderRegion&) const;
    204    
     202
    205203    void flipForWritingModeLocalCoordinates(LayoutRect&) const;
    206204
  • trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp

    r164482 r164837  
    3636#include "Range.h"
    3737#include "RenderInline.h"
     38#include "RenderLayer.h"
    3839#include "RenderNamedFlowFragment.h"
    3940#include "RenderText.h"
     
    282283    if (m_regionList.first() == region)
    283284        updateWritingMode();
     285}
     286
     287LayoutRect RenderNamedFlowThread::decorationsClipRectForBoxInNamedFlowFragment(const RenderBox& box, RenderNamedFlowFragment& fragment) const
     288{
     289    LayoutRect visualOverflowRect = fragment.visualOverflowRectForBox(&box);
     290    LayoutUnit initialLogicalX = style().isHorizontalWritingMode() ? visualOverflowRect.x() : visualOverflowRect.y();
     291
     292    // The visual overflow rect returned by visualOverflowRectForBox is already flipped but the
     293    // RenderRegion::rectFlowPortionForBox method expects it unflipped.
     294    flipForWritingModeLocalCoordinates(visualOverflowRect);
     295    visualOverflowRect = fragment.rectFlowPortionForBox(&box, visualOverflowRect);
     296   
     297    // Now flip it again.
     298    flipForWritingModeLocalCoordinates(visualOverflowRect);
     299   
     300    // Layers are in physical coordinates so the origin must be moved to the physical top-left of the flowthread.
     301    if (style().isFlippedBlocksWritingMode()) {
     302        if (style().isHorizontalWritingMode())
     303            visualOverflowRect.moveBy(LayoutPoint(0, height()));
     304        else
     305            visualOverflowRect.moveBy(LayoutPoint(width(), 0));
     306    }
     307
     308    const RenderBox* iterBox = &box;
     309    while (iterBox && iterBox != this) {
     310        RenderBlock* containerBlock = iterBox->containingBlock();
     311
     312        // FIXME: This doesn't work properly with flipped writing modes.
     313        // https://bugs.webkit.org/show_bug.cgi?id=125149
     314        if (iterBox->isPositioned()) {
     315            // For positioned elements, just use the layer's absolute bounding box.
     316            visualOverflowRect.moveBy(iterBox->layer()->absoluteBoundingBox().location());
     317            break;
     318        }
     319
     320        LayoutRect currentBoxRect = iterBox->frameRect();
     321        if (iterBox->style().isFlippedBlocksWritingMode()) {
     322            if (iterBox->style().isHorizontalWritingMode())
     323                currentBoxRect.setY(currentBoxRect.height() - currentBoxRect.maxY());
     324            else
     325                currentBoxRect.setX(currentBoxRect.width() - currentBoxRect.maxX());
     326        }
     327
     328        if (containerBlock->style().writingMode() != iterBox->style().writingMode())
     329            iterBox->flipForWritingMode(currentBoxRect);
     330
     331        visualOverflowRect.moveBy(currentBoxRect.location());
     332        iterBox = containerBlock;
     333    }
     334
     335    // Since the purpose of this method is to make sure the borders of a fragmented
     336    // element don't overflow the region in the fragmentation direction, there's no
     337    // point in restricting the clipping rect on the logical X axis.
     338    // This also saves us the trouble of handling percent-based widths and margins
     339    // since the absolute bounding box of a positioned element would not contain
     340    // the correct coordinates relative to the region we're interested in, but rather
     341    // relative to the actual flow thread.
     342    if (style().isHorizontalWritingMode()) {
     343        if (initialLogicalX < visualOverflowRect.x())
     344            visualOverflowRect.shiftXEdgeTo(initialLogicalX);
     345        if (visualOverflowRect.width() < frameRect().width())
     346            visualOverflowRect.setWidth(frameRect().width());
     347    } else {
     348        if (initialLogicalX < visualOverflowRect.y())
     349            visualOverflowRect.shiftYEdgeTo(initialLogicalX);
     350        if (visualOverflowRect.height() < frameRect().height())
     351            visualOverflowRect.setHeight(frameRect().height());
     352    }
     353
     354    return visualOverflowRect;
    284355}
    285356
  • trunk/Source/WebCore/rendering/RenderNamedFlowThread.h

    r164482 r164837  
    6868
    6969    virtual void regionChangedWritingMode(RenderRegion*) override;
     70
     71    LayoutRect decorationsClipRectForBoxInNamedFlowFragment(const RenderBox&, RenderNamedFlowFragment&) const;
    7072
    7173    bool overset() const { return m_overset; }
Note: See TracChangeset for help on using the changeset viewer.