1926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)/* 2926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2012 Google Inc. All rights reserved. 3926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 4926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without 5926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * modification, are permitted provided that the following conditions are 6926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * met: 7926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 8926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * * Redistributions of source code must retain the above copyright 9926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * notice, this list of conditions and the following disclaimer. 10926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * * Neither the name of Google Inc. nor the names of its 11926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * contributors may be used to endorse or promote products derived from 12926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * this software without specific prior written permission. 13926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 14926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) */ 26926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 27926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#ifndef NodeRenderingTraversal_h 28926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#define NodeRenderingTraversal_h 29926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 3053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/dom/Element.h" 31926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 32c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 33926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 34926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)class InsertionPoint; 3509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class RenderObject; 36926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 37926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)namespace NodeRenderingTraversal { 38926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 39926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)class ParentDetails { 40926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)public: 41926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) ParentDetails() 42926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) : m_insertionPoint(0) 43926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) { } 44926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 4519cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles) const InsertionPoint* insertionPoint() const { return m_insertionPoint; } 46926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 4719cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles) void didTraverseInsertionPoint(const InsertionPoint*); 48926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 49926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) bool operator==(const ParentDetails& other) 50926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) { 5143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return m_insertionPoint == other.m_insertionPoint; 52926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) } 53926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 54926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)private: 5519cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles) const InsertionPoint* m_insertionPoint; 56926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}; 57926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 58c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)ContainerNode* parent(const Node*, ParentDetails* = 0); 5909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)bool contains(const ContainerNode*, const Node*); 60926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)Node* nextSibling(const Node*); 61926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)Node* previousSibling(const Node*); 62d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)Node* previous(const Node*, const Node* stayWithin); 63d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)Node* next(const Node*, const Node* stayWithin); 6409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)RenderObject* nextSiblingRenderer(const Node*); 6509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)RenderObject* previousSiblingRenderer(const Node*); 6609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)RenderObject* nextInTopLayer(const Element*); 67926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 683c9e4aeaee9f9b0a9a814da07bcb33319c7ea363Ben Murdochinline Element* parentElement(const Node* node) 693c9e4aeaee9f9b0a9a814da07bcb33319c7ea363Ben Murdoch{ 709e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles) ContainerNode* found = parent(node); 713c9e4aeaee9f9b0a9a814da07bcb33319c7ea363Ben Murdoch return found && found->isElementNode() ? toElement(found) : 0; 723c9e4aeaee9f9b0a9a814da07bcb33319c7ea363Ben Murdoch} 733c9e4aeaee9f9b0a9a814da07bcb33319c7ea363Ben Murdoch 74926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} 75926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 76c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 77926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 78926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#endif 79