Changeset 111229 in webkit


Ignore:
Timestamp:
Mar 19, 2012 1:24:14 PM (12 years ago)
Author:
mihnea@adobe.com
Message:

[CSSRegions]Implement NamedFlow::contentNodes attribute
https://bugs.webkit.org/show_bug.cgi?id=80134

Reviewed by David Hyatt.

The named flow content nodes collection contains those nodes with webkitFlowInto property set to 'flow'.
In the list, the nodes are placed in document order. Nodes with display:none are also part of the list.
The list of nodes is returned as a static node list.

Source/WebCore:

Test: fast/regions/webkit-named-flow-content-nodes.html

  • dom/Document.cpp:

(WebCore::Document::webkitGetFlowByName):

  • dom/Document.h:
  • dom/Element.cpp:

(WebCore::Element::detach):

  • dom/NodeRenderingContext.cpp:

(WebCore::NodeRenderingContext::moveToFlowThreadIfNeeded):

  • dom/WebKitNamedFlow.cpp:

(WebCore::WebKitNamedFlow::contentNodes):
(WebCore):
(WebCore::WebKitNamedFlow::registerContentNode):

  • dom/WebKitNamedFlow.h:

(WebCore):
(WebKitNamedFlow):
(WebCore::WebKitNamedFlow::unregisterContentNode):

  • dom/WebKitNamedFlow.idl:

LayoutTests:

  • fast/regions/webkit-named-flow-content-nodes-expected.txt: Added.
  • fast/regions/webkit-named-flow-content-nodes.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r111227 r111229  
     12012-03-19  Mihnea Ovidenie  <mihnea@adobe.com>
     2
     3        [CSSRegions]Implement NamedFlow::contentNodes attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=80134
     5
     6        Reviewed by David Hyatt.
     7
     8        The named flow content nodes collection contains those nodes with webkitFlowInto property set to 'flow'.
     9        In the list, the nodes are placed in document order. Nodes with display:none are also part of the list.
     10        The list of nodes is returned as a static node list.
     11
     12        * fast/regions/webkit-named-flow-content-nodes-expected.txt: Added.
     13        * fast/regions/webkit-named-flow-content-nodes.html: Added.
     14
    1152012-03-19  Xingnan Wang  <xingnan.wang@intel.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r111227 r111229  
     12012-03-19  Mihnea Ovidenie  <mihnea@adobe.com>
     2
     3        [CSSRegions]Implement NamedFlow::contentNodes attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=80134
     5
     6        Reviewed by David Hyatt.
     7
     8        The named flow content nodes collection contains those nodes with webkitFlowInto property set to 'flow'.
     9        In the list, the nodes are placed in document order. Nodes with display:none are also part of the list.
     10        The list of nodes is returned as a static node list.
     11
     12        Test: fast/regions/webkit-named-flow-content-nodes.html
     13
     14        * dom/Document.cpp:
     15        (WebCore::Document::webkitGetFlowByName):
     16        * dom/Document.h:
     17        * dom/Element.cpp:
     18        (WebCore::Element::detach):
     19        * dom/NodeRenderingContext.cpp:
     20        (WebCore::NodeRenderingContext::moveToFlowThreadIfNeeded):
     21        * dom/WebKitNamedFlow.cpp:
     22        (WebCore::WebKitNamedFlow::contentNodes):
     23        (WebCore):
     24        (WebCore::WebKitNamedFlow::registerContentNode):
     25        * dom/WebKitNamedFlow.h:
     26        (WebCore):
     27        (WebKitNamedFlow):
     28        (WebCore::WebKitNamedFlow::unregisterContentNode):
     29        * dom/WebKitNamedFlow.idl:
     30
    1312012-03-19  Xingnan Wang  <xingnan.wang@intel.com>
    232
  • trunk/Source/WebCore/dom/Document.cpp

    r111126 r111229  
    10401040PassRefPtr<WebKitNamedFlow> Document::webkitGetFlowByName(const String& flowName)
    10411041{
    1042     if (!cssRegionsEnabled() || flowName.isEmpty() || !validFlowName(flowName) || !renderer())
     1042    return webkitGetFlowByName(flowName, CheckFlowNameForInvalidValues);
     1043}
     1044
     1045PassRefPtr<WebKitNamedFlow> Document::webkitGetFlowByName(const String& flowName, FlowNameCheck flowNameCheck)
     1046{
     1047    if (!cssRegionsEnabled() || !renderer())
    10431048        return 0;
    10441049
    1045     // Make a slower check for invalid flow name
    1046     CSSParser p(true);
    1047     if (!p.parseFlowThread(flowName, this))
    1048         return 0;
     1050    if (flowNameCheck == CheckFlowNameForInvalidValues) {
     1051        if (flowName.isEmpty() || !validFlowName(flowName))
     1052            return 0;
     1053
     1054        // Make a slower check for invalid flow name
     1055        CSSParser parser(true);
     1056        if (!parser.parseFlowThread(flowName, this))
     1057            return 0;
     1058    }
    10491059
    10501060    if (RenderView* view = renderer()->view())
  • trunk/Source/WebCore/dom/Document.h

    r111048 r111229  
    353353
    354354    bool cssRegionsEnabled() const;
     355    enum FlowNameCheck {
     356        CheckFlowNameForInvalidValues,
     357        DoNotCheckFlowNameForInvalidValues
     358    };
    355359    PassRefPtr<WebKitNamedFlow> webkitGetFlowByName(const String&);
     360    PassRefPtr<WebKitNamedFlow> webkitGetFlowByName(const String&, FlowNameCheck);
    356361
    357362    bool regionBasedColumnsEnabled() const;
  • trunk/Source/WebCore/dom/Element.cpp

    r111176 r111229  
    6767#include "Text.h"
    6868#include "TextIterator.h"
     69#include "WebKitAnimationList.h"
    6970#include "WebKitMutationObserver.h"
    70 #include "WebKitAnimationList.h"
     71#include "WebKitNamedFlow.h"
    7172#include "XMLNSNames.h"
    7273#include "XMLNames.h"
     
    980981    RenderWidget::suspendWidgetHierarchyUpdates();
    981982
     983    if (document()->cssRegionsEnabled()) {
     984        RenderStyle* style = renderer() ? renderer()->style() : computedStyle();
     985        if (style && !style->flowThread().isEmpty()) {
     986            RefPtr<WebKitNamedFlow> namedFlow = document()->webkitGetFlowByName(style->flowThread(), Document::DoNotCheckFlowNameForInvalidValues);
     987            if (namedFlow)
     988                namedFlow->unregisterContentNode(this);
     989        }
     990    }
     991
    982992    cancelFocusAppearanceUpdate();
    983993    if (hasRareData())
  • trunk/Source/WebCore/dom/NodeRenderingContext.cpp

    r110161 r111229  
    3939#include "ShadowRoot.h"
    4040#include "ShadowTree.h"
     41#include "WebKitNamedFlow.h"
    4142
    4243#if ENABLE(SVG)
     
    328329    ASSERT(m_node->document()->renderView());
    329330    m_parentFlowRenderer = m_node->document()->renderView()->ensureRenderFlowThreadWithName(m_flowThread);
     331    m_parentFlowRenderer->ensureNamedFlow()->registerContentNode(m_node);
    330332}
    331333
  • trunk/Source/WebCore/dom/WebKitNamedFlow.cpp

    r110639 r111229  
    3131#include "WebKitNamedFlow.h"
    3232
     33#include "Node.h"
     34#include "NodeList.h"
    3335#include "RenderFlowThread.h"
     36#include "StaticNodeList.h"
    3437
    3538namespace WebCore {
     
    5053}
    5154
     55PassRefPtr<NodeList> WebKitNamedFlow::contentNodes() const
     56{
     57    m_parentFlowThread->document()->updateLayoutIgnorePendingStylesheets();
     58
     59    Vector<RefPtr<Node> > contentNodes;
     60    for (NamedFlowContentNodes::const_iterator it = m_contentNodes.begin(); it != m_contentNodes.end(); ++it) {
     61        Node* node = const_cast<Node*>(*it);
     62        ASSERT(node->computedStyle()->flowThread() == m_parentFlowThread->flowThread());
     63        contentNodes.append(node);
     64    }
     65
     66    return StaticNodeList::adopt(contentNodes);
     67}
     68
     69// The content nodes list contains those nodes with -webkit-flow-into: flow.
     70// An element with display:none should also be listed among those nodes.
     71// The list of nodes is orderer.
     72void WebKitNamedFlow::registerContentNode(Node* contentNode)
     73{
     74    ASSERT(contentNode && contentNode->isElementNode());
     75
     76    // Find the first content node following the new content node.
     77    for (NamedFlowContentNodes::iterator it = m_contentNodes.begin(); it != m_contentNodes.end(); ++it) {
     78        Node* node = *it;
     79        unsigned short position = contentNode->compareDocumentPosition(node);
     80        if (position & Node::DOCUMENT_POSITION_FOLLOWING) {
     81            m_contentNodes.insertBefore(node, contentNode);
     82            return;
     83        }
     84    }
     85    m_contentNodes.add(contentNode);
     86}
     87
    5288} // namespace WebCore
    5389
  • trunk/Source/WebCore/dom/WebKitNamedFlow.h

    r110639 r111229  
    3131#define WebKitNamedFlow_h
    3232
     33#include <Node.h>
     34#include <wtf/ListHashSet.h>
    3335#include <wtf/RefCounted.h>
    3436#include <wtf/RefPtr.h>
     
    3638namespace WebCore {
    3739
     40class NodeList;
    3841class RenderFlowThread;
    3942
     
    4851
    4952    bool overflow() const;
     53    PassRefPtr<NodeList> contentNodes() const;
     54
     55    void registerContentNode(Node* contentNode);
     56    void unregisterContentNode(Node* contentNode) { m_contentNodes.remove(contentNode); }
    5057
    5158private:
     
    5360
    5461    RenderFlowThread* m_parentFlowThread;
     62
     63    typedef ListHashSet<Node*> NamedFlowContentNodes;
     64    NamedFlowContentNodes m_contentNodes;
    5565};
    5666
  • trunk/Source/WebCore/dom/WebKitNamedFlow.idl

    r110639 r111229  
    3333    ] WebKitNamedFlow {
    3434        readonly attribute boolean overflow;
     35        readonly attribute NodeList contentNodes;
    3536    };
    3637}
Note: See TracChangeset for help on using the changeset viewer.