Source/WebCore/ChangeLog

 12012-06-19 Andrei Bucur <abucur@adobe.com>
 2
 3 [CSS Regions] Fix the lifecycle for the flow objects and their renderers
 4 https://bugs.webkit.org/show_bug.cgi?id=89000
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This patch adds the concept of a NamedFlowCollection, owned by the document, that keeps track of
 9 all the named flows that exist in the Document. This collection contains a ListHashSet of weak references to
 10 all the existing NamedFlows in the document. This is not a managed set because the CREATED flows are referenced from the renderer and
 11 the NULL flows are only cached, they should be destructible.
 12 Two named flows are considered to be equal if they have the same name.
 13 The class will be used to implement the interface NamedFlowCollection from the Regions spec; this is the reason for the length() and item(index) methods.
 14 I've changed the NamedFlow state to depend on the existence of its renderer. A flow thread that has a renderer will also have a NamedFlow object.
 15 A flow thread without a renderer can have a NamedFlow object, but only in the NULL state. It's possible for a NamedFlow object to jump from the
 16 NULL state to the CREATED state if it was not destroyed (e.g. it was referenced from JS). Keeping track of the NULL state flows that have listeners will be important
 17 so when they go back to the CREATED state, the listeners would still be there.
 18
 19 Link to spec: http://www.w3.org/TR/2012/WD-css3-regions-20120503/
 20
 21 Tests: The old tests have been modified to take into account the new behavior
 22
 23 * CMakeLists.txt:
 24 * GNUmakefile.list.am:
 25 * Target.pri:
 26 * WebCore.gypi:
 27 * WebCore.vcproj/WebCore.vcproj:
 28 * WebCore.xcodeproj/project.pbxproj:
 29 * dom/DOMAllInOne.cpp:
 30 * dom/Document.cpp:
 31 (WebCore::Document::Document):
 32 (WebCore::Document::~Document):
 33 (WebCore):
 34 (WebCore::Document::webkitGetFlowByName):
 35 (WebCore::Document::namedFlows):
 36 * dom/Document.h:
 37 (WebCore):
 38 (Document):
 39 * dom/WebKitNamedFlow.cpp:
 40 (WebCore::WebKitNamedFlow::WebKitNamedFlow):
 41 (WebCore::WebKitNamedFlow::~WebKitNamedFlow):
 42 (WebCore::WebKitNamedFlow::name):
 43 (WebCore::WebKitNamedFlow::overset):
 44 (WebCore::WebKitNamedFlow::getRegionsByContentNode):
 45 (WebCore::WebKitNamedFlow::contentNodes):
 46 (WebCore):
 47 (WebCore::WebKitNamedFlow::setRenderer):
 48 * dom/WebKitNamedFlow.h:
 49 (WebCore):
 50 (WebCore::WebKitNamedFlow::create):
 51 (WebKitNamedFlow):
 52 (WebCore::WebKitNamedFlow::getFlowState):
 53 (WebCore::WebKitNamedFlow::switchFlowState):
 54 * dom/WebKitNamedFlowCollection.cpp: Added.
 55 (WebCore):
 56 (WebCore::WebKitNamedFlowCollection::WebKitNamedFlowCollection):
 57 (WebCore::WebKitNamedFlowCollection::~WebKitNamedFlowCollection):
 58 (WebCore::WebKitNamedFlowCollection::length): An O(1) operation
 59 (WebCore::WebKitNamedFlowCollection::item): An O(number of CREATED flows) operation
 60 (WebCore::WebKitNamedFlowCollection::getFlowByName): An O(1) operation
 61 (WebCore::WebKitNamedFlowCollection::ensureNamedFlowInCreatedState): An O(1) operation
 62 (WebCore::WebKitNamedFlowCollection::moveNamedFlowToNullState): An O(1) operation
 63 (WebCore::WebKitNamedFlowCollection::discardNamedFlow): An O(1) operation
 64 (WebCore::WebKitNamedFlowCollection::documentDestroyed):
 65 (WebCore::WebKitNamedFlowCollection::NamedFlowHashFunctions::hash):
 66 (WebCore::WebKitNamedFlowCollection::NamedFlowHashFunctions::equal):
 67 (WebKitNamedFlowCollection::NamedFlowHashFunctions):
 68 (WebCore::WebKitNamedFlowCollection::NamedFlowHashTranslator::hash):
 69 (WebCore::WebKitNamedFlowCollection::NamedFlowHashTranslator::equal):
 70 * dom/WebKitNamedFlowCollection.h: Copied from Source/WebCore/dom/WebKitNamedFlow.h.
 71 (WebCore):
 72 (WebKitNamedFlowCollection):
 73 (WebCore::WebKitNamedFlowCollection::create):
 74 * rendering/FlowThreadController.cpp:
 75 (WebCore::FlowThreadController::ensureRenderFlowThreadWithName):
 76 (WebCore::FlowThreadController::removeFlowThread):
 77 (WebCore):
 78 * rendering/FlowThreadController.h:
 79 (FlowThreadController):
 80 * rendering/RenderNamedFlowThread.cpp:
 81 (WebCore::RenderNamedFlowThread::RenderNamedFlowThread):
 82 (WebCore):
 83 (WebCore::RenderNamedFlowThread::~RenderNamedFlowThread):
 84 (WebCore::RenderNamedFlowThread::removeRegionFromThread):
 85 (WebCore::RenderNamedFlowThread::unregisterNamedFlowContentNode):
 86 (WebCore::RenderNamedFlowThread::flowThreadName):
 87 (WebCore::RenderNamedFlowThread::willBeDestroyed):
 88 * rendering/RenderNamedFlowThread.h:
 89 (RenderNamedFlowThread):
 90 (WebCore::RenderNamedFlowThread::canBeDestroyed):
 91
1922012-06-19 Dominik Röttsches <dominik.rottsches@intel.com>
293
394 [GTK] Assert failure in svg/batik/text/textDecoration.svg,textEffect3.svg for 64bit Debug bot

Source/WebCore/CMakeLists.txt

@@SET(WebCore_SOURCES
664664 dom/WebKitAnimationEvent.cpp
665665 dom/WebKitMutationObserver.cpp
666666 dom/WebKitNamedFlow.cpp
 667 dom/WebKitNamedFlowCollection.cpp
667668 dom/WebKitTransitionEvent.cpp
668669 dom/WheelEvent.cpp
669670 dom/WindowEventContext.cpp

Source/WebCore/GNUmakefile.list.am

@@webcore_sources += \
20372037 Source/WebCore/dom/WebKitMutationObserver.h \
20382038 Source/WebCore/dom/WebKitNamedFlow.cpp \
20392039 Source/WebCore/dom/WebKitNamedFlow.h \
 2040 Source/WebCore/dom/WebKitNamedFlowCollection.cpp \
 2041 Source/WebCore/dom/WebKitNamedFlowCollection.h \
20402042 Source/WebCore/dom/WebKitTransitionEvent.cpp \
20412043 Source/WebCore/dom/WebKitTransitionEvent.h \
20422044 Source/WebCore/dom/WheelEvent.cpp \

Source/WebCore/Target.pri

@@SOURCES += \
632632 dom/WebKitAnimationEvent.cpp \
633633 dom/WebKitMutationObserver.cpp \
634634 dom/WebKitNamedFlow.cpp \
 635 dom/WebKitNamedFlowCollection.cpp \
635636 dom/WebKitTransitionEvent.cpp \
636637 dom/WheelEvent.cpp \
637638 dom/WindowEventContext.cpp \

@@HEADERS += \
18001801 dom/WebKitAnimationEvent.h \
18011802 dom/WebKitMutationObserver.h \
18021803 dom/WebKitNamedFlow.h \
 1804 dom/WebKitNamedFlowCollection.h \
18031805 dom/WebKitTransitionEvent.h \
18041806 dom/WheelEvent.h \
18051807 editing/AlternativeTextController.h \

Source/WebCore/WebCore.gypi

54445444 'dom/WebKitMutationObserver.h',
54455445 'dom/WebKitNamedFlow.cpp',
54465446 'dom/WebKitNamedFlow.h',
 5447 'dom/WebKitNamedFlowCollection.cpp',
 5448 'dom/WebKitNamedFlowCollection.h',
54475449 'dom/WebKitTransitionEvent.cpp',
54485450 'dom/WebKitTransitionEvent.h',
54495451 'dom/WheelEvent.cpp',

Source/WebCore/WebCore.vcproj/WebCore.vcproj

5441454414 RelativePath="..\dom\WebKitNamedFlow.h"
5441554415 >
5441654416 </File>
 54417 <File
 54418 RelativePath="..\dom\WebKitNamedFlowCollection.cpp"
 54419 >
 54420 <FileConfiguration
 54421 Name="Debug|Win32"
 54422 ExcludedFromBuild="true"
 54423 >
 54424 <Tool
 54425 Name="VCCLCompilerTool"
 54426 />
 54427 </FileConfiguration>
 54428 <FileConfiguration
 54429 Name="Release|Win32"
 54430 ExcludedFromBuild="true"
 54431 >
 54432 <Tool
 54433 Name="VCCLCompilerTool"
 54434 />
 54435 </FileConfiguration>
 54436 <FileConfiguration
 54437 Name="Debug_Cairo_CFLite|Win32"
 54438 ExcludedFromBuild="true"
 54439 >
 54440 <Tool
 54441 Name="VCCLCompilerTool"
 54442 />
 54443 </FileConfiguration>
 54444 <FileConfiguration
 54445 Name="Release_Cairo_CFLite|Win32"
 54446 ExcludedFromBuild="true"
 54447 >
 54448 <Tool
 54449 Name="VCCLCompilerTool"
 54450 />
 54451 </FileConfiguration>
 54452 <FileConfiguration
 54453 Name="Debug_All|Win32"
 54454 ExcludedFromBuild="true"
 54455 >
 54456 <Tool
 54457 Name="VCCLCompilerTool"
 54458 />
 54459 </FileConfiguration>
 54460 <FileConfiguration
 54461 Name="Production|Win32"
 54462 ExcludedFromBuild="true"
 54463 >
 54464 <Tool
 54465 Name="VCCLCompilerTool"
 54466 />
 54467 </FileConfiguration>
 54468 </File>
 54469 <File
 54470 RelativePath="..\dom\WebKitNamedFlowCollection.h"
 54471 >
 54472 </File>
5441754473 <File
5441854474 RelativePath="..\dom\WebKitTransitionEvent.cpp"
5441954475 >

Source/WebCore/WebCore.xcodeproj/project.pbxproj

278278 0FF50271102BA96A0066F39A /* StyleMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FF5026E102BA9660066F39A /* StyleMedia.cpp */; };
279279 0FF50272102BA96A0066F39A /* StyleMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF5026F102BA96A0066F39A /* StyleMedia.h */; };
280280 10FB084B14E15C7E00A3DB98 /* PublicURLManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */; };
 281 12F35EB6158745A40035CB63 /* WebKitNamedFlowCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 12F35EB4158745A40035CB63 /* WebKitNamedFlowCollection.h */; };
 282 12F35EB7158745A40035CB63 /* WebKitNamedFlowCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12F35EB5158745A40035CB63 /* WebKitNamedFlowCollection.cpp */; };
281283 1402645E0AFDC19B005919E2 /* LoggingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1402645D0AFDC19B005919E2 /* LoggingMac.mm */; };
282284 1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1403B99509EB13AF00797C7F /* DOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
283285 1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1403B99609EB13AF00797C7F /* DOMWindow.cpp */; };

72057207 0FF5026F102BA96A0066F39A /* StyleMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleMedia.h; sourceTree = "<group>"; };
72067208 0FF50270102BA96A0066F39A /* StyleMedia.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = StyleMedia.idl; sourceTree = "<group>"; };
72077209 10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PublicURLManager.h; sourceTree = "<group>"; };
 7210 12F35EB4158745A40035CB63 /* WebKitNamedFlowCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitNamedFlowCollection.h; sourceTree = "<group>"; };
 7211 12F35EB5158745A40035CB63 /* WebKitNamedFlowCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitNamedFlowCollection.cpp; sourceTree = "<group>"; };
72087212 1402645D0AFDC19B005919E2 /* LoggingMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggingMac.mm; sourceTree = "<group>"; };
72097213 1403B90C09EB124500797C7F /* DOMWindow.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMWindow.idl; sourceTree = "<group>"; };
72107214 1403B99509EB13AF00797C7F /* DOMWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWindow.h; sourceTree = "<group>"; };

2155121555 93EEC1F709C2877700C515D1 /* WheelEvent.idl */,
2155221556 4123E568127B3041000FEEA7 /* WindowEventContext.cpp */,
2155321557 4123E567127B3041000FEEA7 /* WindowEventContext.h */,
 21558 12F35EB4158745A40035CB63 /* WebKitNamedFlowCollection.h */,
 21559 12F35EB5158745A40035CB63 /* WebKitNamedFlowCollection.cpp */,
2155421560 );
2155521561 path = dom;
2155621562 sourceTree = "<group>";

2509825104 FD537353137B651800008DCE /* ZeroPole.h in Headers */,
2509925105 CE7B2DB31586ABAD0098B3FA /* AlternativeTextUIController.h in Headers */,
2510025106 CE7B2DB51586ABAD0098B3FA /* TextAlternativeWithRange.h in Headers */,
 25107 12F35EB6158745A40035CB63 /* WebKitNamedFlowCollection.h in Headers */,
2510125108 );
2510225109 runOnlyForDeploymentPostprocessing = 0;
2510325110 };

2814428151 9A1B6F97158869C80011A8C4 /* JSDOMStringListCustom.cpp in Sources */,
2814528152 CE7B2DB41586ABAD0098B3FA /* AlternativeTextUIController.mm in Sources */,
2814628153 CE7B2DB61586ABAD0098B3FA /* TextAlternativeWithRange.mm in Sources */,
 28154 12F35EB7158745A40035CB63 /* WebKitNamedFlowCollection.cpp in Sources */,
2814728155 );
2814828156 runOnlyForDeploymentPostprocessing = 0;
2814928157 };

Source/WebCore/dom/DOMAllInOne.cpp

144144#include "WebKitAnimationEvent.cpp"
145145#include "WebKitMutationObserver.cpp"
146146#include "WebKitNamedFlow.cpp"
 147#include "WebKitNamedFlowCollection.cpp"
147148#include "WebKitTransitionEvent.cpp"
148149#include "WheelEvent.cpp"
149150#include "WindowEventContext.cpp"

Source/WebCore/dom/Document.cpp

156156#include "UndoManager.h"
157157#include "UserContentURLPattern.h"
158158#include "WebKitNamedFlow.h"
 159#include "WebKitNamedFlowCollection.h"
159160#include "XMLDocumentParser.h"
160161#include "XMLHttpRequest.h"
161162#include "XMLNSNames.h"

@@Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
495496 , m_scheduledTasksAreSuspended(false)
496497 , m_visualUpdatesAllowed(true)
497498 , m_visualUpdatesSuppressionTimer(this, &Document::visualUpdatesSuppressionTimerFired)
 499 , m_namedFlows(0)
498500#ifndef NDEBUG
499501 , m_didDispatchViewportPropertiesChanged(false)
500502#endif

@@Document::~Document()
617619 if (m_styleSheets)
618620 m_styleSheets->documentDestroyed();
619621
 622 if (m_namedFlows)
 623 m_namedFlows->documentDestroyed();
 624
620625 if (m_elemSheet)
621626 m_elemSheet->clearOwnerNode();
622627 if (m_pageUserSheet)

@@bool Document::cssGridLayoutEnabled() const
11161121
11171122#if ENABLE(CSS_REGIONS)
11181123
1119 static bool validFlowName(const String& flowName)
1120 {
1121  if (equalIgnoringCase(flowName, "auto")
1122  || equalIgnoringCase(flowName, "default")
1123  || equalIgnoringCase(flowName, "inherit")
1124  || equalIgnoringCase(flowName, "initial")
1125  || equalIgnoringCase(flowName, "none"))
1126  return false;
1127  return true;
1128 }
1129 
11301124PassRefPtr<WebKitNamedFlow> Document::webkitGetFlowByName(const String& flowName)
11311125{
1132  return webkitGetFlowByName(flowName, CheckFlowNameForInvalidValues);
1133 }
1134 
1135 PassRefPtr<WebKitNamedFlow> Document::webkitGetFlowByName(const String& flowName, FlowNameCheck flowNameCheck)
1136 {
11371126 if (!cssRegionsEnabled() || !renderer())
11381127 return 0;
1139 
1140  if (flowNameCheck == CheckFlowNameForInvalidValues) {
1141  if (flowName.isEmpty() || !validFlowName(flowName))
1142  return 0;
1143 
1144  // Make a slower check for invalid flow name.
1145  CSSParser parser(document());
1146  if (!parser.parseFlowThread(flowName))
1147  return 0;
1148  }
1149 
1150  if (RenderView* view = renderer()->view())
1151  return view->flowThreadController()->ensureRenderFlowThreadWithName(flowName)->ensureNamedFlow();
1152  return 0;
 1128
 1129 // It's possible to have pendiding styles not applied that affect the existing flows.
 1130 updateStyleIfNeeded();
 1131
 1132 return namedFlows()->getFlowByName(flowName);
11531133}
1154 
11551134#endif
11561135
 1136WebKitNamedFlowCollection* Document::namedFlows()
 1137{
 1138 if (!m_namedFlows)
 1139 m_namedFlows = WebKitNamedFlowCollection::create(this);
 1140
 1141 return m_namedFlows.get();
 1142}
 1143
11571144PassRefPtr<Element> Document::createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode& ec)
11581145{
11591146 String prefix, localName;

Source/WebCore/dom/Document.h

@@class TextResourceDecoder;
136136class TreeWalker;
137137class UndoManager;
138138class WebKitNamedFlow;
 139class WebKitNamedFlowCollection;
139140class XMLHttpRequest;
140141class XPathEvaluator;
141142class XPathExpression;

@@public:
327328
328329 bool cssRegionsEnabled() const;
329330#if ENABLE(CSS_REGIONS)
330  enum FlowNameCheck {
331  CheckFlowNameForInvalidValues,
332  DoNotCheckFlowNameForInvalidValues
333  };
334331 PassRefPtr<WebKitNamedFlow> webkitGetFlowByName(const String&);
335  PassRefPtr<WebKitNamedFlow> webkitGetFlowByName(const String&, FlowNameCheck);
336332#endif
337333
 334 WebKitNamedFlowCollection* namedFlows();
 335
338336 bool regionBasedColumnsEnabled() const;
339337
340338 bool cssGridLayoutEnabled() const;

@@private:
14931491 bool m_visualUpdatesAllowed;
14941492 Timer<Document> m_visualUpdatesSuppressionTimer;
14951493
 1494 RefPtr<WebKitNamedFlowCollection> m_namedFlows;
 1495
14961496#ifndef NDEBUG
14971497 bool m_didDispatchViewportPropertiesChanged;
14981498#endif

Source/WebCore/dom/WebKitNamedFlow.cpp

3333#include "RenderNamedFlowThread.h"
3434#include "RenderRegion.h"
3535#include "StaticNodeList.h"
 36#include "WebKitNamedFlowCollection.h"
3637
3738namespace WebCore {
3839
39 WebKitNamedFlow::WebKitNamedFlow(RenderNamedFlowThread* parentFlowThread)
40 : m_parentFlowThread(parentFlowThread)
 40WebKitNamedFlow::WebKitNamedFlow(WebKitNamedFlowCollection* manager, const AtomicString& flowThreadName)
 41 : m_flowThreadName(flowThreadName)
 42 , m_flowManager(manager)
 43 , m_parentFlowThread(0)
 44 , m_state(STATE_CREATED)
4145{
4246}
4347
4448WebKitNamedFlow::~WebKitNamedFlow()
4549{
 50 // The named flow is not "strong" referenced from anywhere at this time so it shouldn't be reused if the named flow is recreated.
 51 m_flowManager->discardNamedFlow(this);
4652}
4753
4854String WebKitNamedFlow::name() const
4955{
50  return m_parentFlowThread->flowThreadName();
 56 return m_flowThreadName;
5157}
5258
5359bool WebKitNamedFlow::overset() const
5460{
55  m_parentFlowThread->document()->updateLayoutIgnorePendingStylesheets();
56  return m_parentFlowThread->overset();
 61 if (m_parentFlowThread)
 62 m_parentFlowThread->document()->updateLayoutIgnorePendingStylesheets();
 63
 64 // The renderer may be destroyed here after a style update.
 65 return m_parentFlowThread ? m_parentFlowThread->overset() : true;
5766}
5867
5968PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContentNode(Node* contentNode)

@@PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContentNode(Node* contentNode)
6170 if (!contentNode)
6271 return 0;
6372
64  m_parentFlowThread->document()->updateLayoutIgnorePendingStylesheets();
65 
6673 Vector<RefPtr<Node> > regionNodes;
67  if (contentNode->renderer()
68  && contentNode->renderer()->inRenderFlowThread()
69  && m_parentFlowThread == contentNode->renderer()->enclosingRenderFlowThread()) {
70  const RenderRegionList& regionList = m_parentFlowThread->renderRegionList();
71  for (RenderRegionList::const_iterator iter = regionList.begin(); iter != regionList.end(); ++iter) {
72  const RenderRegion* renderRegion = *iter;
73  if (!renderRegion->isValid())
74  continue;
75  if (m_parentFlowThread->objectInFlowRegion(contentNode->renderer(), renderRegion))
76  regionNodes.append(renderRegion->node());
 74
 75 if (m_parentFlowThread)
 76 m_parentFlowThread->document()->updateLayoutIgnorePendingStylesheets();
 77
 78 // The renderer may be destroyed here after a style update.
 79 if (m_parentFlowThread) {
 80 if (contentNode->renderer()
 81 && contentNode->renderer()->inRenderFlowThread()
 82 && m_parentFlowThread == contentNode->renderer()->enclosingRenderFlowThread()) {
 83 const RenderRegionList& regionList = m_parentFlowThread->renderRegionList();
 84 for (RenderRegionList::const_iterator iter = regionList.begin(); iter != regionList.end(); ++iter) {
 85 const RenderRegion* renderRegion = *iter;
 86 if (!renderRegion->isValid())
 87 continue;
 88 if (m_parentFlowThread->objectInFlowRegion(contentNode->renderer(), renderRegion))
 89 regionNodes.append(renderRegion->node());
 90 }
7791 }
7892 }
 93
7994 return StaticNodeList::adopt(regionNodes);
8095}
8196
8297PassRefPtr<NodeList> WebKitNamedFlow::contentNodes() const
8398{
84  m_parentFlowThread->document()->updateLayoutIgnorePendingStylesheets();
85 
8699 Vector<RefPtr<Node> > contentNodes;
87  for (NamedFlowContentNodes::const_iterator it = m_parentFlowThread->contentNodes().begin(); it != m_parentFlowThread->contentNodes().end(); ++it) {
88  Node* node = const_cast<Node*>(*it);
89  ASSERT(node->computedStyle()->flowThread() == m_parentFlowThread->flowThreadName());
90  contentNodes.append(node);
 100
 101 if (m_parentFlowThread)
 102 m_parentFlowThread->document()->updateLayoutIgnorePendingStylesheets();
 103
 104 // The renderer may be destroyed here after a style update.
 105 if (m_parentFlowThread) {
 106 for (NamedFlowContentNodes::const_iterator it = m_parentFlowThread->contentNodes().begin(); it != m_parentFlowThread->contentNodes().end(); ++it) {
 107 Node* node = const_cast<Node*>(*it);
 108 ASSERT(node->computedStyle()->flowThread() == m_parentFlowThread->flowThreadName());
 109 contentNodes.append(node);
 110 }
91111 }
92112
93113 return StaticNodeList::adopt(contentNodes);
94114}
 115
 116void WebKitNamedFlow::setRenderer(RenderNamedFlowThread* parentFlowThread)
 117{
 118 // The named flow can either go from a no_renderer->renderer or renderer->no_renderer state; anything else could indicate a bug.
 119 ASSERT((!m_parentFlowThread && parentFlowThread) || (m_parentFlowThread && !parentFlowThread));
 120
 121 m_parentFlowThread = parentFlowThread;
 122
 123 // A named flow that loses the renderer is in the "NULL" state.
 124 if (!m_parentFlowThread)
 125 m_flowManager->moveNamedFlowToNullState(this);
 126}
95127
96128} // namespace WebCore
97129

Source/WebCore/dom/WebKitNamedFlow.h

@@namespace WebCore {
3939
4040class NodeList;
4141class RenderNamedFlowThread;
 42class WebKitNamedFlowCollection;
4243
4344class WebKitNamedFlow : public RefCounted<WebKitNamedFlow> {
4445public:
45  static PassRefPtr<WebKitNamedFlow> create(RenderNamedFlowThread* parentFlowThread)
 46 static PassRefPtr<WebKitNamedFlow> create(WebKitNamedFlowCollection* manager, const AtomicString& flowThreadName)
4647 {
47  return adoptRef(new WebKitNamedFlow(parentFlowThread));
 48 return adoptRef(new WebKitNamedFlow(manager, flowThreadName));
4849 }
4950
5051 ~WebKitNamedFlow();

@@public:
5455 PassRefPtr<NodeList> getRegionsByContentNode(Node*);
5556 PassRefPtr<NodeList> contentNodes() const;
5657
 58 void setRenderer(RenderNamedFlowThread* parentFlowThread);
 59
 60 enum FlowState {
 61 STATE_CREATED,
 62 STATE_NULL
 63 };
 64
 65 FlowState getFlowState() const { return m_state; }
 66 void switchFlowState() { m_state = m_state == STATE_NULL ? STATE_CREATED : STATE_NULL; }
 67
5768private:
58  WebKitNamedFlow(RenderNamedFlowThread*);
 69 WebKitNamedFlow(WebKitNamedFlowCollection*, const AtomicString&);
5970
 71 // The name of the flow thread as specified in CSS.
 72 AtomicString m_flowThreadName;
 73
 74 WebKitNamedFlowCollection* m_flowManager;
6075 RenderNamedFlowThread* m_parentFlowThread;
 76
 77 FlowState m_state;
6178};
6279
6380}

Source/WebCore/dom/WebKitNamedFlowCollection.cpp

 1/*
 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above
 9 * copyright notice, this list of conditions and the following
 10 * disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above
 12 * copyright notice, this list of conditions and the following
 13 * disclaimer in the documentation and/or other materials
 14 * provided with the distribution.
 15 *
 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 27 * SUCH DAMAGE.
 28 */
 29
 30#include "config.h"
 31#include "WebKitNamedFlowCollection.h"
 32
 33#include "Document.h"
 34#include "WebKitNamedFlow.h"
 35
 36#include <wtf/text/StringHash.h>
 37#include <wtf/text/WTFString.h>
 38
 39namespace WebCore {
 40
 41WebKitNamedFlowCollection::WebKitNamedFlowCollection(Document* doc)
 42 : m_document(doc)
 43 , m_createdFlowsCount(0)
 44{
 45}
 46
 47WebKitNamedFlowCollection::~WebKitNamedFlowCollection()
 48{
 49}
 50
 51unsigned WebKitNamedFlowCollection::length() const
 52{
 53 return m_createdFlowsCount;
 54}
 55
 56WebKitNamedFlow* WebKitNamedFlowCollection::item(unsigned index) const
 57{
 58 ASSERT(m_createdFlowsCount >= 0);
 59
 60 if (index >= m_createdFlowsCount)
 61 return 0;
 62
 63 NamedFlowSet::const_iterator it = m_namedFlows.begin();
 64 NamedFlowSet::const_iterator end = m_namedFlows.end();
 65
 66 while (it != end) {
 67 WebKitNamedFlow* namedFlow = *it;
 68 if (namedFlow->getFlowState() == WebKitNamedFlow::STATE_CREATED) {
 69 if (!index)
 70 return namedFlow;
 71 --index;
 72 }
 73
 74 ++it;
 75 }
 76
 77 return 0;
 78}
 79
 80WebKitNamedFlow* WebKitNamedFlowCollection::getFlowByName(const String& flowName)
 81{
 82 ASSERT(m_createdFlowsCount >= 0);
 83
 84 NamedFlowSet::iterator it = m_namedFlows.find<String, NamedFlowHashTranslator>(flowName);
 85 if (it == m_namedFlows.end() || (*it)->getFlowState() == WebKitNamedFlow::STATE_NULL)
 86 return 0;
 87
 88 return *it;
 89}
 90
 91PassRefPtr<WebKitNamedFlow> WebKitNamedFlowCollection::ensureNamedFlowInCreatedState(const String& flowName)
 92{
 93 ++m_createdFlowsCount;
 94
 95 NamedFlowSet::iterator it = m_namedFlows.find<String, NamedFlowHashTranslator>(flowName);
 96 if (it != m_namedFlows.end()) {
 97 WebKitNamedFlow* namedFlow = *it;
 98 ASSERT(namedFlow->getFlowState() == WebKitNamedFlow::STATE_NULL);
 99 namedFlow->switchFlowState();
 100
 101 return namedFlow;
 102 }
 103
 104 RefPtr<WebKitNamedFlow> newFlow = WebKitNamedFlow::create(this, flowName);
 105 m_namedFlows.add(newFlow.get());
 106
 107 return newFlow.release();
 108}
 109
 110void WebKitNamedFlowCollection::moveNamedFlowToNullState(WebKitNamedFlow* namedFlow)
 111{
 112 ASSERT(namedFlow->getFlowState() == WebKitNamedFlow::STATE_CREATED);
 113 ASSERT(m_createdFlowsCount > 0);
 114
 115 namedFlow->switchFlowState();
 116 --m_createdFlowsCount;
 117}
 118
 119void WebKitNamedFlowCollection::discardNamedFlow(WebKitNamedFlow* namedFlow)
 120{
 121 // The document is not valid anymore so the collection will be destroyed anyway.
 122 if (!m_document)
 123 return;
 124
 125 ASSERT(namedFlow->getFlowState() == WebKitNamedFlow::STATE_NULL);
 126 ASSERT(m_namedFlows.contains(namedFlow));
 127
 128 m_namedFlows.remove(namedFlow);
 129}
 130
 131void WebKitNamedFlowCollection::documentDestroyed()
 132{
 133 m_document = 0;
 134}
 135
 136struct WebKitNamedFlowCollection::NamedFlowHashFunctions {
 137 static unsigned hash(WebKitNamedFlow* key) { return DefaultHash<String>::Hash::hash(key->name()); }
 138 static bool equal(WebKitNamedFlow* a, WebKitNamedFlow* b) { return a->name() == b->name(); }
 139 static const bool safeToCompareToEmptyOrDeleted = true;
 140};
 141
 142struct WebKitNamedFlowCollection::NamedFlowHashTranslator {
 143 static unsigned hash(const String& key) { return DefaultHash<String>::Hash::hash(key); }
 144 static bool equal(WebKitNamedFlow* a, const String& b) { return a->name() == b; }
 145};
 146
 147} // namespace WebCore

Source/WebCore/dom/WebKitNamedFlowCollection.h

 1/*
 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above
 9 * copyright notice, this list of conditions and the following
 10 * disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above
 12 * copyright notice, this list of conditions and the following
 13 * disclaimer in the documentation and/or other materials
 14 * provided with the distribution.
 15 *
 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 27 * SUCH DAMAGE.
 28 */
 29
 30#ifndef WebKitNamedFlowCollection_h
 31#define WebKitNamedFlowCollection_h
 32
 33#include <wtf/Forward.h>
 34#include <wtf/ListHashSet.h>
 35#include <wtf/PassRefPtr.h>
 36#include <wtf/RefCounted.h>
 37
 38namespace WebCore {
 39
 40class Document;
 41class WebKitNamedFlow;
 42
 43class WebKitNamedFlowCollection : public RefCounted<WebKitNamedFlowCollection> {
 44public:
 45 static PassRefPtr<WebKitNamedFlowCollection> create(Document* doc) { return adoptRef(new WebKitNamedFlowCollection(doc)); }
 46 ~WebKitNamedFlowCollection();
 47
 48 unsigned length() const;
 49 WebKitNamedFlow* item(unsigned index) const;
 50
 51 WebKitNamedFlow* getFlowByName(const String&);
 52 PassRefPtr<WebKitNamedFlow> ensureNamedFlowInCreatedState(const String&);
 53
 54 void moveNamedFlowToNullState(WebKitNamedFlow*);
 55 void discardNamedFlow(WebKitNamedFlow*);
 56
 57 void documentDestroyed();
 58
 59private:
 60 WebKitNamedFlowCollection(Document*);
 61
 62 Document* m_document;
 63
 64 struct NamedFlowHashFunctions;
 65 struct NamedFlowHashTranslator;
 66
 67 typedef ListHashSet<WebKitNamedFlow*, 1, NamedFlowHashFunctions> NamedFlowSet;
 68
 69 unsigned m_createdFlowsCount;
 70 NamedFlowSet m_namedFlows;
 71};
 72
 73} // namespace WebCore
 74
 75#endif // WebKitNamedFlowCollection_h

Source/WebCore/rendering/FlowThreadController.cpp

3333
3434#include "RenderFlowThread.h"
3535#include "RenderNamedFlowThread.h"
 36#include "WebKitNamedFlow.h"
 37#include "WebKitNamedFlowCollection.h"
3638#include <wtf/text/AtomicString.h>
3739
3840namespace WebCore {

@@RenderNamedFlowThread* FlowThreadController::ensureRenderFlowThreadWithName(cons
6567 }
6668 }
6769
68  RenderNamedFlowThread* flowRenderer = new (m_view->renderArena()) RenderNamedFlowThread(m_view->document(), name);
 70 WebKitNamedFlowCollection* namedFlows = m_view->document()->namedFlows();
 71
 72 // Sanity check for the inexistence of a named flow in the "CREATED" state with the same name.
 73 ASSERT(!namedFlows->getFlowByName(name));
 74
 75 RenderNamedFlowThread* flowRenderer = new (m_view->renderArena()) RenderNamedFlowThread(m_view->document(), namedFlows->ensureNamedFlowInCreatedState(name));
6976 flowRenderer->setStyle(RenderFlowThread::createFlowThreadStyle(m_view->style()));
7077 m_renderNamedFlowThreadList->add(flowRenderer);
7178

@@void FlowThreadController::unregisterNamedFlowContentNode(Node* contentNode)
122129 m_mapNamedFlowContentNodes.remove(contentNode);
123130}
124131
 132void FlowThreadController::removeFlowThread(RenderNamedFlowThread* flowThread)
 133{
 134 m_renderNamedFlowThreadList->remove(flowThread);
 135 setIsRenderNamedFlowThreadOrderDirty(true);
 136}
 137
125138} // namespace WebCore

Source/WebCore/rendering/FlowThreadController.h

@@public:
6464
6565 void registerNamedFlowContentNode(Node*, RenderNamedFlowThread*);
6666 void unregisterNamedFlowContentNode(Node*);
 67
 68 void removeFlowThread(RenderNamedFlowThread*);
6769
6870protected:
6971 FlowThreadController(RenderView*);

Source/WebCore/rendering/RenderNamedFlowThread.cpp

3333
3434namespace WebCore {
3535
36 RenderNamedFlowThread::RenderNamedFlowThread(Node* node, const AtomicString& name)
 36RenderNamedFlowThread::RenderNamedFlowThread(Node* node, PassRefPtr<WebKitNamedFlow> namedFlow)
3737 : RenderFlowThread(node)
38  , m_flowThreadName(name)
 38 , m_namedFlow(namedFlow)
3939{
 40 m_namedFlow->setRenderer(this);
 41}
 42
 43RenderNamedFlowThread::~RenderNamedFlowThread()
 44{
 45 m_namedFlow->setRenderer(0);
4046}
4147
4248const char* RenderNamedFlowThread::renderName() const

@@const char* RenderNamedFlowThread::renderName() const
4450 return "RenderNamedFlowThread";
4551}
4652
47 
4853RenderObject* RenderNamedFlowThread::nextRendererForNode(Node* node) const
4954{
5055 FlowThreadChildList::const_iterator it = m_flowThreadChildList.begin();

@@void RenderNamedFlowThread::removeRegionFromThread(RenderRegion* renderRegion)
182187 removeDependencyOnFlowThread(renderRegion->parentNamedFlowThread());
183188 }
184189
 190 if (canBeDestroyed()) {
 191 destroy();
 192 return;
 193 }
 194
185195 invalidateRegions();
186196}
187197
188 
189198void RenderNamedFlowThread::checkInvalidRegions()
190199{
191200 for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {

@@void RenderNamedFlowThread::pushDependencies(RenderNamedFlowThreadList& list)
245254 }
246255}
247256
248 WebKitNamedFlow* RenderNamedFlowThread::ensureNamedFlow()
249 {
250  if (!m_namedFlow)
251  m_namedFlow = WebKitNamedFlow::create(this);
252 
253  return m_namedFlow.get();
254 }
255 
256257// The content nodes list contains those nodes with -webkit-flow-into: flow.
257258// An element with display:none should also be listed among those nodes.
258259// The list of nodes is ordered.

@@void RenderNamedFlowThread::unregisterNamedFlowContentNode(Node* contentNode)
283284 contentNode->clearInNamedFlow();
284285 m_contentNodes.remove(contentNode);
285286
 287 if (canBeDestroyed())
 288 destroy();
 289}
 290
 291AtomicString RenderNamedFlowThread::flowThreadName() const
 292{
 293 return m_namedFlow->name();
 294}
 295
 296void RenderNamedFlowThread::willBeDestroyed()
 297{
 298 if (!documentBeingDestroyed())
 299 view()->flowThreadController()->removeFlowThread(this);
 300
 301 RenderFlowThread::willBeDestroyed();
286302}
287303
288304}

Source/WebCore/rendering/RenderNamedFlowThread.h

@@typedef ListHashSet<Node*> NamedFlowContentNodes;
4444
4545class RenderNamedFlowThread : public RenderFlowThread {
4646public:
47  RenderNamedFlowThread(Node*, const AtomicString&);
 47 RenderNamedFlowThread(Node*, PassRefPtr<WebKitNamedFlow>);
 48 virtual ~RenderNamedFlowThread();
4849
49  AtomicString flowThreadName() const { return m_flowThreadName; }
 50 AtomicString flowThreadName() const;
5051
5152 RenderObject* nextRendererForNode(Node*) const;
5253 RenderObject* previousRendererForNode(Node*) const;

@@public:
6364 virtual void addRegionToThread(RenderRegion*) OVERRIDE;
6465 virtual void removeRegionFromThread(RenderRegion*) OVERRIDE;
6566
66  WebKitNamedFlow* ensureNamedFlow();
6767 void registerNamedFlowContentNode(Node*);
6868 void unregisterNamedFlowContentNode(Node*);
6969 const NamedFlowContentNodes& contentNodes() const { return m_contentNodes; }
7070 bool hasContentNode(Node* contentNode) const { ASSERT(contentNode); return m_contentNodes.contains(contentNode); }
7171
 72protected:
 73 virtual void willBeDestroyed() OVERRIDE;
 74
7275private:
7376 virtual const char* renderName() const OVERRIDE;
7477 virtual bool isRenderNamedFlowThread() const OVERRIDE { return true; }

@@private:
7780 void addDependencyOnFlowThread(RenderNamedFlowThread*);
7881 void removeDependencyOnFlowThread(RenderNamedFlowThread*);
7982 void checkInvalidRegions();
 83 inline bool canBeDestroyed() const { return m_regionList.isEmpty() && m_contentNodes.isEmpty(); }
8084
8185private:
82  // The name of the flow thread as specified in CSS.
83  AtomicString m_flowThreadName;
84 
8586 // Observer flow threads have invalid regions that depend on the state of this thread
8687 // to re-validate their regions. Keeping a set of observer threads make it easy
8788 // to notify them when a region was removed from this flow.

LayoutTests/ChangeLog

 12012-06-19 Andrei Bucur <abucur@adobe.com>
 2
 3 [CSS Regions] Fix the lifecycle for the flow objects and their renderers
 4 https://bugs.webkit.org/show_bug.cgi?id=89000
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 These tests expected getFlowByName() to return a valid object even for the NULL flows. They've been modified to
 9 reflect the new behavior.
 10
 11 * fast/regions/webkit-named-flow-content-nodes-expected.txt:
 12 * fast/regions/webkit-named-flow-content-nodes.html:
 13 * fast/regions/webkit-named-flow-flow-added.html:
 14 * fast/regions/webkit-named-flow-invalid-name.html:
 15 * fast/regions/webkit-named-flow-modified-flow.html:
 16 * fast/regions/webkit-named-flow-non-existing-flow.html:
 17 * fast/regions/webkit-named-flow-removed-flow.html:
 18 * platform/chromium-win/fast/regions/region-style-block-background-color2-expected.txt:
 19 * platform/mac/fast/regions/region-style-block-background-color2-expected.txt:
 20
1212012-06-19 Dominik Röttsches <dominik.rottsches@intel.com>
222
323 [GTK] Assert failure in svg/batik/text/textDecoration.svg,textEffect3.svg for 64bit Debug bot

LayoutTests/fast/regions/webkit-named-flow-content-nodes-expected.txt

@@Test for 80134: [CSSRegions]Implement NamedFlow::contentNodes
33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44
55
6 PASS namedFlowContentNodes is non-null.
7 PASS namedFlowContentNodes.length is 0
8 PASS namedFlowContentNodes instanceof NodeList is true
9 PASS namedFlowContentNodes2.length is 0
 6PASS document.webkitGetFlowByName("flow") is null
107PASS namedFlowContentNodes3.length is 1
118PASS namedFlowContentNodes3.item(0).id is "article"
129PASS namedFlowContentNodes4.length is 1

@@PASS namedFlowContentNodes10.item(0).id is "article"
2623PASS namedFlowContentNodes11.length is 5
2724PASS namedFlowContentNodes12.length is 1
2825PASS namedFlowContentNodes12.item(0).id is "article"
29 PASS namedFlowContentNodes10.length is 0
3026PASS namedFlowContentNodes11.length is 0
3127PASS namedFlowContentNodes12.length is 1
3228PASS namedFlowContentNodes12.item(0).id is "article"
 29PASS document.webkitGetFlowByName("flow2") is null
3330PASS namedFlowContentNodes13.length is 0
34 PASS namedFlowContentNodes14.length is 0
3531PASS successfullyParsed is true
3632
3733TEST COMPLETE

LayoutTests/fast/regions/webkit-named-flow-content-nodes.html

1818 -->
1919 <script>
2020 if (window.layoutTestController)
21  window.layoutTestController.dumpAsText();
 21 window.layoutTestController.dumpAsText();
2222 description("Test for 80134: [CSSRegions]Implement NamedFlow::contentNodes");
2323
24  // First time ask for a named flow object, the contentNodes should be empty.
25  var namedFlowContentNodes = document.webkitGetFlowByName("flow").contentNodes;
26  shouldBeNonNull("namedFlowContentNodes");
27  shouldEvaluateTo("namedFlowContentNodes.length", 0);
28  shouldBeTrue("namedFlowContentNodes instanceof NodeList");
29 
3024 // Add an element that would be collected by the named flow but do not add it to the DOM, the contentNodes should be empty.
3125 var article = document.createElement("div");
3226 article.id = "article";
3327 article.style.webkitFlowInto = "flow";
34  var namedFlowContentNodes2 = document.webkitGetFlowByName("flow").contentNodes;
35  shouldEvaluateTo("namedFlowContentNodes2.length", 0);
 28
 29 shouldBeNull('document.webkitGetFlowByName("flow")');
3630
3731 // Append the above element to the DOM. It will be collected by the flow, therefore the contentNodes should have 1 element.
3832 document.body.appendChild(article);

5852
5953 var namedFlowContentNodes5 = document.webkitGetFlowByName("flow").contentNodes;
6054 shouldEvaluateTo("namedFlowContentNodes5.length", 2);
61  shouldBeEqualToString("namedFlowContentNodes5.item(0).id", "article2");
62  shouldBeEqualToString("namedFlowContentNodes5.item(1).id", "article");
 55 shouldBeEqualToString("namedFlowContentNodes5.item(0).id", "article2");
 56 shouldBeEqualToString("namedFlowContentNodes5.item(1).id", "article");
6357
6458 // Adding a region element to flow content into should not influence the content nodes collection.
6559 var regionNode = document.createElement("div");

8983 document.getElementById("article").style.display = "none";
9084 var namedFlowContentNodes9 = document.webkitGetFlowByName("flow").contentNodes;
9185 shouldEvaluateTo("namedFlowContentNodes9.length", 3);
92  shouldBeEqualToString("namedFlowContentNodes9.item(0).id", "article2");
93  shouldBeEqualToString("namedFlowContentNodes9.item(1).id", "span1");
94  shouldBeEqualToString("namedFlowContentNodes9.item(2).id", "article");
 86 shouldBeEqualToString("namedFlowContentNodes9.item(0).id", "article2");
 87 shouldBeEqualToString("namedFlowContentNodes9.item(1).id", "span1");
 88 shouldBeEqualToString("namedFlowContentNodes9.item(2).id", "article");
9589
9690 // Take 'article' node from last position and insert it before 'article2'
9791 article = document.getElementById("article");
9892 document.body.insertBefore(document.body.removeChild(article), article2);
9993 var namedFlowContentNodes10 = document.webkitGetFlowByName("flow").contentNodes;
10094 shouldEvaluateTo("namedFlowContentNodes10.length", 3);
101  shouldBeEqualToString("namedFlowContentNodes10.item(0).id", "article");
 95 shouldBeEqualToString("namedFlowContentNodes10.item(0).id", "article");
10296
10397 // Clone 'article2' including its children.
10498 var article2Clone = document.getElementById("article2").cloneNode(true);

110104 document.body.removeChild(article2Clone);
111105 var namedFlowContentNodes12 = document.webkitGetFlowByName("flow").contentNodes;
112106 shouldEvaluateTo("namedFlowContentNodes12.length", 1);
113  shouldBeEqualToString("namedFlowContentNodes12.item(0).id", "article");
114 
115  // Get the content nodes for another flow, flow2.
116  var namedFlowContentNodes10 = document.webkitGetFlowByName("flow2").contentNodes;
117  shouldEvaluateTo("namedFlowContentNodes10.length", "0");
 107 shouldBeEqualToString("namedFlowContentNodes12.item(0).id", "article");
118108
119109 // Move the content node 'article' from named flow 'flow' to named flow 'flow2'
120110 document.getElementById("article").style.webkitFlowInto = "flow2";

126116
127117 // Remove the content node from dom, content nodes for both 'flow' and 'flow2' should be empty
128118 document.body.removeChild(document.getElementById("article"));
 119
 120 shouldBeNull('document.webkitGetFlowByName("flow2")');
 121
129122 var namedFlowContentNodes13 = document.webkitGetFlowByName("flow").contentNodes;
130  var namedFlowContentNodes14 = document.webkitGetFlowByName("flow2").contentNodes;
131123 shouldEvaluateTo("namedFlowContentNodes13.length", "0");
132  shouldEvaluateTo("namedFlowContentNodes14.length", "0");
133124
134125 document.getElementById("region").style.visibility = "hidden";
135126 </script>

LayoutTests/fast/regions/webkit-named-flow-flow-added.html

4343 function test()
4444 {
4545 namedFlow2 = document.webkitGetFlowByName("flow");
46  if (namedFlow && namedFlow2) {
 46 if (!namedFlow && namedFlow2) {
4747 document.getElementById("result").innerText = "PASS";
4848 document.getElementById("result").className = "pass";
4949 }

LayoutTests/fast/regions/webkit-named-flow-invalid-name.html

2222 assert(nullNamedFlow == null, "Named flow for " + arrFlowInvalidNames[i] + " should be null");
2323 }
2424
25  // It should be possible to get the named flow object for a valid flow name.
 25 // It should not be possible to get the NamedFlow object for an inexistent flow.
2626 var namedFlow = document.webkitGetFlowByName("flow");
27  assert(namedFlow != null, "Named flow for flow should not be null");
 27 assert(namedFlow == null, "Named flow for flow should not be null");
2828 </script>
2929 </body>
3030</html>

LayoutTests/fast/regions/webkit-named-flow-modified-flow.html

4747 {
4848 var namedFlow = document.webkitGetFlowByName("flow");
4949 var namedFlow2 = document.webkitGetFlowByName("flow2");
50  if (namedFlow && namedFlow2) {
 50 if (!namedFlow && namedFlow2) {
5151 document.getElementById("result").innerText = "PASS";
5252 document.getElementById("result").className = "pass";
5353 }

LayoutTests/fast/regions/webkit-named-flow-non-existing-flow.html

2929 layoutTestController.dumpAsText();
3030
3131 var namedFlow = document.webkitGetFlowByName("flow");
32  if (namedFlow) {
 32 if (!namedFlow) {
3333 document.getElementById("result").innerText = "PASS";
3434 document.getElementById("result").className = "pass";
3535 }

LayoutTests/fast/regions/webkit-named-flow-removed-flow.html

4343 function test()
4444 {
4545 namedFlow2 = document.webkitGetFlowByName("flow");
46  if (namedFlow && namedFlow2) {
 46 if (namedFlow && !namedFlow2) {
4747 document.getElementById("result").innerText = "PASS";
4848 document.getElementById("result").className = "pass";
4949 }

LayoutTests/platform/chromium-win/fast/regions/region-style-block-background-color2-expected.txt

@@Flow Threads
2929 text run at (0,0) width 245: "Green background text styled in region1."
3030 Regions for flow 'flow1'
3131 RenderRegion {DIV} #region1 region style: 1
32  Thread with flow-name 'flow2'
3332 Thread with flow-name 'flow3'
3433 layer at (0,0) size 280x80
3534 RenderNamedFlowThread at (0,0) size 280x80

LayoutTests/platform/mac/fast/regions/region-style-block-background-color2-expected.txt

@@Flow Threads
2929 text run at (0,0) width 258: "Green background text styled in region1."
3030 Regions for flow 'flow1'
3131 RenderRegion {DIV} #region1 region style: 1
32  Thread with flow-name 'flow2'
3332 Thread with flow-name 'flow3'
3433 layer at (0,0) size 280x80
3534 RenderNamedFlowThread at (0,0) size 280x80