2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
22 #include "core/rendering/RenderDetailsMarker.h"
24 #include "core/HTMLNames.h"
25 #include "core/dom/Element.h"
26 #include "core/html/HTMLElement.h"
27 #include "core/paint/DetailsMarkerPainter.h"
28 #include "core/rendering/PaintInfo.h"
32 using namespace HTMLNames;
34 RenderDetailsMarker::RenderDetailsMarker(Element* element)
35 : RenderBlockFlow(element)
39 RenderDetailsMarker::Orientation RenderDetailsMarker::orientation() const
41 switch (style()->writingMode()) {
42 case TopToBottomWritingMode:
43 if (style()->isLeftToRightDirection())
44 return isOpen() ? Down : Right;
45 return isOpen() ? Down : Left;
46 case RightToLeftWritingMode:
47 if (style()->isLeftToRightDirection())
48 return isOpen() ? Left : Down;
49 return isOpen() ? Left : Up;
50 case LeftToRightWritingMode:
51 if (style()->isLeftToRightDirection())
52 return isOpen() ? Right : Down;
53 return isOpen() ? Right : Up;
54 case BottomToTopWritingMode:
55 if (style()->isLeftToRightDirection())
56 return isOpen() ? Up : Right;
57 return isOpen() ? Up : Left;
62 void RenderDetailsMarker::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
64 DetailsMarkerPainter(*this).paint(paintInfo, paintOffset);
67 bool RenderDetailsMarker::isOpen() const
69 for (RenderObject* renderer = parent(); renderer; renderer = renderer->parent()) {
70 if (!renderer->node())
72 if (isHTMLDetailsElement(*renderer->node()))
73 return !toElement(renderer->node())->getAttribute(openAttr).isNull();
74 if (isHTMLInputElement(*renderer->node()))