Changeset 64610 in webkit


Ignore:
Timestamp:
Aug 3, 2010 6:19:14 PM (14 years ago)
Author:
rniwa@webkit.org
Message:

2010-08-03 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Eric Seidel.

extractAndNegateTextDecorationStyle and maxRangeOffset in ApplyStyleCommand.cpp should be deleted
https://bugs.webkit.org/show_bug.cgi?id=43437

Removed extractAndNegateTextDecorationStyle because we never push down text decorations added by CSS rules
as discussed on the bug 27809. Also removed pushDownTextDecorationStyleAtBoundaries because it only existed
to encapsulate the complexity of calling pushDownTextDecorationStyleAroundNode first with forceNegate = false
(calling pushDownTextDecorationStyleAroundNode) and again with forceNegate = true (calling extractAndNegateTextDecorationStyle)
after updating layout but neither the layout update nor the second call to pushDownTextDecorationStyleAroundNode
is needed after the removal of extractAndNegateTextDecorationStyle.

Also replaced maxRangeOffset by lastOffsetForEditing as FIXME (added by r48235) indicated.

No new tests added since this is a clean up.

  • editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::pushDownTextDecorationStyleAroundNode): No longer takes forceNegate as an argument. (WebCore::ApplyStyleCommand::removeInlineStyle): Calls pushDownTextDecorationStyleAroundNode directly.
  • editing/ApplyStyleCommand.h:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64609 r64610  
     12010-08-03  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        extractAndNegateTextDecorationStyle and maxRangeOffset in ApplyStyleCommand.cpp should be deleted
     6        https://bugs.webkit.org/show_bug.cgi?id=43437
     7
     8        Removed extractAndNegateTextDecorationStyle because we never push down text decorations added by CSS rules
     9        as discussed on the bug 27809. Also removed pushDownTextDecorationStyleAtBoundaries because it only existed
     10        to encapsulate the complexity of calling pushDownTextDecorationStyleAroundNode first with forceNegate = false
     11        (calling pushDownTextDecorationStyleAroundNode) and again with forceNegate = true (calling extractAndNegateTextDecorationStyle)
     12        after updating layout but neither the layout update nor the second call to pushDownTextDecorationStyleAroundNode
     13        is needed after the removal of extractAndNegateTextDecorationStyle.
     14
     15        Also replaced maxRangeOffset by lastOffsetForEditing as FIXME (added by r48235) indicated.
     16
     17        No new tests added since this is a clean up.
     18
     19        * editing/ApplyStyleCommand.cpp:
     20        (WebCore::ApplyStyleCommand::pushDownTextDecorationStyleAroundNode): No longer takes forceNegate as an argument.
     21        (WebCore::ApplyStyleCommand::removeInlineStyle): Calls pushDownTextDecorationStyleAroundNode directly.
     22        * editing/ApplyStyleCommand.h:
     23
    1242010-08-03  Ryosuke Niwa  <rniwa@webkit.org>
    225
  • trunk/WebCore/editing/ApplyStyleCommand.cpp

    r64432 r64610  
    13861386}
    13871387
    1388 PassRefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::extractAndNegateTextDecorationStyle(Node* node)
    1389 {
    1390     ASSERT(node);
    1391     ASSERT(node->isElementNode());
    1392    
    1393     // non-html elements not handled yet
    1394     if (!node->isHTMLElement())
    1395         return 0;
    1396 
    1397     RefPtr<CSSComputedStyleDeclaration> nodeStyle = computedStyle(node);
    1398     ASSERT(nodeStyle);
    1399 
    1400     int properties[1] = { CSSPropertyTextDecoration };
    1401     RefPtr<CSSMutableStyleDeclaration> textDecorationStyle = nodeStyle->copyPropertiesInSet(properties, 1);
    1402 
    1403     RefPtr<CSSValue> property = nodeStyle->getPropertyCSSValue(CSSPropertyTextDecoration);
    1404     if (property && !equalIgnoringCase(property->cssText(), "none")) {
    1405         RefPtr<CSSMutableStyleDeclaration> newStyle = textDecorationStyle->copy();
    1406         newStyle->setProperty(CSSPropertyTextDecoration, "none");
    1407         applyTextDecorationStyle(node, newStyle.get());
    1408     }
    1409 
    1410     return textDecorationStyle.release();
    1411 }
    1412 
    14131388void ApplyStyleCommand::applyTextDecorationStyle(Node *node, CSSMutableStyleDeclaration *style)
    14141389{
     
    14441419}
    14451420
    1446 void ApplyStyleCommand::pushDownTextDecorationStyleAroundNode(Node* targetNode, bool forceNegate)
     1421void ApplyStyleCommand::pushDownTextDecorationStyleAroundNode(Node* targetNode)
    14471422{
    14481423    ASSERT(targetNode);
     
    14561431        ASSERT(current);
    14571432        ASSERT(current->contains(targetNode));
    1458         RefPtr<CSSMutableStyleDeclaration> decoration = forceNegate ? extractAndNegateTextDecorationStyle(current) : extractTextDecorationStyle(current);
     1433        RefPtr<CSSMutableStyleDeclaration> decoration = extractTextDecorationStyle(current);
    14591434
    14601435        // The inner loop will go through children on each level
     
    14771452}
    14781453
    1479 void ApplyStyleCommand::pushDownTextDecorationStyleAtBoundaries(const Position &start, const Position &end)
    1480 {
    1481     // We need to work in two passes. First we push down any inline
    1482     // styles that set text decoration. Then we look for any remaining
    1483     // styles (caused by stylesheets) and explicitly negate text
    1484     // decoration while pushing down.
    1485 
    1486     pushDownTextDecorationStyleAroundNode(start.node(), false);
    1487     updateLayout();
    1488     pushDownTextDecorationStyleAroundNode(start.node(), true);
    1489 
    1490     pushDownTextDecorationStyleAroundNode(end.node(), false);
    1491     updateLayout();
    1492     pushDownTextDecorationStyleAroundNode(end.node(), true);
    1493 }
    1494 
    1495 // FIXME: Why does this exist?  Callers should either use lastOffsetForEditing or lastOffsetInNode
    1496 static int maxRangeOffset(Node *n)
    1497 {
    1498     if (n->offsetInCharacters())
    1499         return n->maxCharacterOffset();
    1500 
    1501     if (n->isElementNode())
    1502         return n->childNodeCount();
    1503 
    1504     return 1;
    1505 }
    1506 
    15071454void ApplyStyleCommand::removeInlineStyle(PassRefPtr<CSSMutableStyleDeclaration> style, const Position &start, const Position &end)
    15081455{
     
    15161463
    15171464    if (textDecorationSpecialProperty) {
    1518         pushDownTextDecorationStyleAtBoundaries(start.downstream(), end.upstream());
     1465        pushDownTextDecorationStyleAroundNode(start.downstream().node());
     1466        pushDownTextDecorationStyleAroundNode(end.upstream().node());
    15191467        style = style->copy();
    15201468        style->setProperty(CSSPropertyTextDecoration, textDecorationSpecialProperty->cssText(), style->getPropertyPriority(CSSPropertyWebkitTextDecorationsInEffect));
     
    15461494                    // of the selection, it is clear we can set the new e offset to
    15471495                    // the max range offset of prev.
    1548                     ASSERT(e.deprecatedEditingOffset() >= maxRangeOffset(e.node()));
    1549                     e = Position(prev, maxRangeOffset(prev));
     1496                    ASSERT(e.deprecatedEditingOffset() >= lastOffsetForEditing(e.node()));
     1497                    e = Position(prev, lastOffsetForEditing(prev));
    15501498                }
    15511499            }
  • trunk/WebCore/editing/ApplyStyleCommand.h

    r64432 r64610  
    8383    bool nodeFullyUnselected(Node*, const Position& start, const Position& end) const;
    8484    PassRefPtr<CSSMutableStyleDeclaration> extractTextDecorationStyle(Node*);
    85     PassRefPtr<CSSMutableStyleDeclaration> extractAndNegateTextDecorationStyle(Node*);
    8685    void applyTextDecorationStyle(Node*, CSSMutableStyleDeclaration *style);
    87     void pushDownTextDecorationStyleAroundNode(Node*, bool forceNegate);
    88     void pushDownTextDecorationStyleAtBoundaries(const Position& start, const Position& end);
    89    
     86    void pushDownTextDecorationStyleAroundNode(Node*);
     87
    9088    // style-application helpers
    9189    void applyBlockStyle(CSSMutableStyleDeclaration*);
Note: See TracChangeset for help on using the changeset viewer.