WebCore/rendering/SVGTextQuery.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2     Copyright (C) Research In Motion Limited 2010. All rights reserved.
       
     3 
       
     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.
       
     8 
       
     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.
       
    13 
       
    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.
       
    18 */
       
    19 
       
    20 #ifndef SVGTextQuery_h
       
    21 #define SVGTextQuery_h
       
    22 
       
    23 #if ENABLE(SVG)
       
    24 #include "FloatRect.h"
       
    25 #include <wtf/Vector.h>
       
    26 
       
    27 namespace WebCore {
       
    28 
       
    29 class InlineFlowBox;
       
    30 class RenderObject;
       
    31 class RenderStyle;
       
    32 class SVGInlineTextBox;
       
    33 struct SVGTextChunkPart;
       
    34 
       
    35 class SVGTextQuery {
       
    36 public:
       
    37     SVGTextQuery(RenderObject*);
       
    38 
       
    39     unsigned numberOfCharacters() const;
       
    40     float textLength() const;
       
    41     float subStringLength(unsigned startPosition, unsigned length) const;
       
    42     FloatPoint startPositionOfCharacter(unsigned position) const;
       
    43     FloatPoint endPositionOfCharacter(unsigned position) const;
       
    44     float rotationOfCharacter(unsigned position) const;
       
    45     FloatRect extentOfCharacter(unsigned position) const;
       
    46     int characterNumberAtPosition(const FloatPoint&) const;
       
    47 
       
    48     // Public helper struct. Private classes in SVGTextQuery inherit from it.
       
    49     struct Data;
       
    50 
       
    51 private:
       
    52     typedef bool (SVGTextQuery::*ProcessTextChunkPartCallback)(Data*, const SVGInlineTextBox*, const SVGTextChunkPart&) const;
       
    53     bool executeQuery(Data*, ProcessTextChunkPartCallback) const;
       
    54 
       
    55     void collectTextBoxesInFlowBox(InlineFlowBox*);
       
    56     float measureCharacterRange(const SVGInlineTextBox*, RenderStyle*, bool isVerticalText, int startPosition, int length) const;
       
    57     bool mapStartAndLengthIntoChunkPartCoordinates(Data*, const SVGInlineTextBox*, const SVGTextChunkPart&, int& startPosition, int& endPosition) const;
       
    58 
       
    59 private:
       
    60     bool numberOfCharactersCallback(Data*, const SVGInlineTextBox*, const SVGTextChunkPart&) const;
       
    61     bool textLengthCallback(Data*, const SVGInlineTextBox*, const SVGTextChunkPart&) const;
       
    62     bool subStringLengthCallback(Data*, const SVGInlineTextBox*, const SVGTextChunkPart&) const;
       
    63     bool startPositionOfCharacterCallback(Data*, const SVGInlineTextBox*, const SVGTextChunkPart&) const;
       
    64     bool endPositionOfCharacterCallback(Data*, const SVGInlineTextBox*, const SVGTextChunkPart&) const;
       
    65     bool rotationOfCharacterCallback(Data*, const SVGInlineTextBox*, const SVGTextChunkPart&) const;
       
    66     bool extentOfCharacterCallback(Data*, const SVGInlineTextBox*, const SVGTextChunkPart&) const;
       
    67     bool characterNumberAtPositionCallback(Data*, const SVGInlineTextBox*, const SVGTextChunkPart&) const;
       
    68 
       
    69 private:
       
    70     Vector<SVGInlineTextBox*> m_textBoxes;
       
    71 };
       
    72 
       
    73 }
       
    74 
       
    75 #endif
       
    76 #endif