Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: Source/core/rendering/InlineTextBox.cpp

Issue 23983002: Expose InlineTextBoxes in the accessibility tree. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove unused include Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/InlineTextBox.h ('k') | Source/core/rendering/RenderText.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/rendering/InlineTextBox.h" 24 #include "core/rendering/InlineTextBox.h"
25 25
26 #include "core/accessibility/AXObjectCache.h"
26 #include "core/dom/Document.h" 27 #include "core/dom/Document.h"
27 #include "core/dom/DocumentMarkerController.h" 28 #include "core/dom/DocumentMarkerController.h"
28 #include "core/dom/RenderedDocumentMarker.h" 29 #include "core/dom/RenderedDocumentMarker.h"
29 #include "core/dom/Text.h" 30 #include "core/dom/Text.h"
30 #include "core/editing/Editor.h" 31 #include "core/editing/Editor.h"
31 #include "core/editing/InputMethodController.h" 32 #include "core/editing/InputMethodController.h"
32 #include "core/page/Frame.h" 33 #include "core/page/Frame.h"
33 #include "core/page/Page.h" 34 #include "core/page/Page.h"
34 #include "core/page/Settings.h" 35 #include "core/page/Settings.h"
35 #include "core/platform/graphics/DrawLooper.h" 36 #include "core/platform/graphics/DrawLooper.h"
36 #include "core/platform/graphics/FontCache.h" 37 #include "core/platform/graphics/FontCache.h"
37 #include "core/platform/graphics/GraphicsContextStateSaver.h" 38 #include "core/platform/graphics/GraphicsContextStateSaver.h"
39 #include "core/platform/graphics/WidthIterator.h"
38 #include "core/rendering/EllipsisBox.h" 40 #include "core/rendering/EllipsisBox.h"
39 #include "core/rendering/HitTestResult.h" 41 #include "core/rendering/HitTestResult.h"
40 #include "core/rendering/PaintInfo.h" 42 #include "core/rendering/PaintInfo.h"
41 #include "core/rendering/RenderBR.h" 43 #include "core/rendering/RenderBR.h"
42 #include "core/rendering/RenderBlock.h" 44 #include "core/rendering/RenderBlock.h"
43 #include "core/rendering/RenderCombineText.h" 45 #include "core/rendering/RenderCombineText.h"
44 #include "core/rendering/RenderRubyRun.h" 46 #include "core/rendering/RenderRubyRun.h"
45 #include "core/rendering/RenderRubyText.h" 47 #include "core/rendering/RenderRubyText.h"
46 #include "core/rendering/RenderTheme.h" 48 #include "core/rendering/RenderTheme.h"
47 #include "core/rendering/style/ShadowData.h" 49 #include "core/rendering/style/ShadowData.h"
(...skipping 14 matching lines...) Expand all
62 64
63 COMPILE_ASSERT(sizeof(InlineTextBox) == sizeof(SameSizeAsInlineTextBox), InlineT extBox_should_stay_small); 65 COMPILE_ASSERT(sizeof(InlineTextBox) == sizeof(SameSizeAsInlineTextBox), InlineT extBox_should_stay_small);
64 66
65 typedef WTF::HashMap<const InlineTextBox*, LayoutRect> InlineTextBoxOverflowMap; 67 typedef WTF::HashMap<const InlineTextBox*, LayoutRect> InlineTextBoxOverflowMap;
66 static InlineTextBoxOverflowMap* gTextBoxesWithOverflow; 68 static InlineTextBoxOverflowMap* gTextBoxesWithOverflow;
67 69
68 static const int misspellingLineThickness = 3; 70 static const int misspellingLineThickness = 3;
69 71
70 void InlineTextBox::destroy() 72 void InlineTextBox::destroy()
71 { 73 {
74 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache())
75 cache->remove(this);
76
72 if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow) 77 if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow)
73 gTextBoxesWithOverflow->remove(this); 78 gTextBoxesWithOverflow->remove(this);
74 InlineBox::destroy(); 79 InlineBox::destroy();
75 } 80 }
76 81
77 void InlineTextBox::markDirty(bool dirty) 82 void InlineTextBox::markDirty(bool dirty)
78 { 83 {
79 if (dirty) { 84 if (dirty) {
80 m_len = 0; 85 m_len = 0;
81 m_start = 0; 86 m_start = 0;
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 return false; 1472 return false;
1468 1473
1469 // Offsets at the end are "out" for line breaks (they are on the next line). 1474 // Offsets at the end are "out" for line breaks (they are on the next line).
1470 if (isLineBreak()) 1475 if (isLineBreak())
1471 return false; 1476 return false;
1472 1477
1473 // Offsets at the end are "in" for normal boxes (but the caller has to check affinity). 1478 // Offsets at the end are "in" for normal boxes (but the caller has to check affinity).
1474 return true; 1479 return true;
1475 } 1480 }
1476 1481
1482 void InlineTextBox::characterWidths(Vector<float>& widths) const
1483 {
1484 FontCachePurgePreventer fontCachePurgePreventer;
1485
1486 RenderText* textObj = textRenderer();
1487 RenderStyle* styleToUse = textObj->style(isFirstLineStyle());
1488 const Font& font = styleToUse->font();
1489
1490 TextRun textRun = constructTextRun(styleToUse, font);
1491
1492 GlyphBuffer glyphBuffer;
1493 WidthIterator it(&font, textRun);
1494 float lastWidth = 0;
1495 widths.resize(m_len);
1496 for (unsigned i = 0; i < m_len; i++) {
1497 it.advance(i + 1, &glyphBuffer);
1498 widths[i] = it.m_runWidthSoFar - lastWidth;
1499 lastWidth = it.m_runWidthSoFar;
1500 }
1501 }
1502
1503 bool InlineTextBox::isRTL() const
igoroliveira 2013/10/03 03:11:55 InlineBox::direction() is not enough here?
dmazzoni 2013/10/03 03:22:33 Thanks, that's obviously what I was looking for.
1504 {
1505 FontCachePurgePreventer fontCachePurgePreventer;
1506
1507 RenderText* textObj = textRenderer();
1508 RenderStyle* styleToUse = textObj->style(isFirstLineStyle());
1509 const Font& font = styleToUse->font();
1510
1511 TextRun textRun = constructTextRun(styleToUse, font);
1512 return textRun.rtl();
1513 }
1514
1477 TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, St ringBuilder* charactersWithHyphen) const 1515 TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, St ringBuilder* charactersWithHyphen) const
1478 { 1516 {
1479 ASSERT(style); 1517 ASSERT(style);
1480 1518
1481 RenderText* textRenderer = this->textRenderer(); 1519 RenderText* textRenderer = this->textRenderer();
1482 ASSERT(textRenderer); 1520 ASSERT(textRenderer);
1483 ASSERT(textRenderer->text()); 1521 ASSERT(textRenderer->text());
1484 1522
1485 StringView string = textRenderer->text().createView(); 1523 StringView string = textRenderer->text().createView();
1486 unsigned startPos = start(); 1524 unsigned startPos = start();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); 1584 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj);
1547 const int rendererCharacterOffset = 24; 1585 const int rendererCharacterOffset = 24;
1548 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) 1586 for (; printedCharacters < rendererCharacterOffset; printedCharacters++)
1549 fputc(' ', stderr); 1587 fputc(' ', stderr);
1550 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); 1588 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata());
1551 } 1589 }
1552 1590
1553 #endif 1591 #endif
1554 1592
1555 } // namespace WebCore 1593 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/InlineTextBox.h ('k') | Source/core/rendering/RenderText.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698