Diff
Modified: trunk/Source/WebCore/ChangeLog (174875 => 174876)
--- trunk/Source/WebCore/ChangeLog 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/ChangeLog 2014-10-20 05:17:06 UTC (rev 174876)
@@ -1,5 +1,53 @@
2014-10-19 Chris Dumez <[email protected]>
+ Kill toRenderedDocumentMarker() by using tighter typing
+ https://bugs.webkit.org/show_bug.cgi?id=137858
+
+ Reviewed by Darin Adler.
+
+ Kill toRenderedDocumentMarker() by using tighter typing. This method
+ was doing no type validation, just a static_cast<>().
+
+ No new tests, no behavior change.
+
+ * dom/DocumentMarkerController.cpp:
+ (WebCore::DocumentMarkerController::addTextMatchMarker):
+ (WebCore::DocumentMarkerController::markersFor):
+ (WebCore::DocumentMarkerController::markersInRange):
+ (DocumentMarkerController::hasMarkers):
+ * dom/DocumentMarkerController.h:
+ * dom/RenderedDocumentMarker.h:
+ (WebCore::toRenderedDocumentMarker): Deleted.
+ * editing/AlternativeTextController.cpp:
+ (WebCore::markersHaveIdenticalDescription):
+ (WebCore::AlternativeTextController::respondToChangedSelection):
+ (WebCore::AlternativeTextController::recordSpellcheckerResponseForModifiedCorrection):
+ (WebCore::AlternativeTextController::processMarkersOnTextToBeReplacedByResult):
+ (WebCore::AlternativeTextController::applyDictationAlternative):
+ * editing/CompositeEditCommand.cpp:
+ (WebCore::copyMarkers):
+ (WebCore::CompositeEditCommand::replaceTextInNodePreservingMarkers):
+ * editing/DeleteSelectionCommand.cpp:
+ (WebCore::DeleteSelectionCommand::originalStringForAutocorrectionAtBeginningOfSelection):
+ * editing/Editor.cpp:
+ (WebCore::Editor::updateMarkersForWordsAffectedByEditing):
+ (WebCore::Editor::selectionStartHasMarkerFor):
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::paintDocumentMarker):
+ (WebCore::InlineTextBox::paintTextMatchMarker):
+ (WebCore::InlineTextBox::computeRectForReplacementMarker):
+ (WebCore::InlineTextBox::paintDocumentMarkers):
+ * rendering/InlineTextBox.h:
+ * rendering/svg/SVGInlineFlowBox.cpp:
+ (WebCore::SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer):
+ * testing/Internals.cpp:
+ (WebCore::Internals::markerAt):
+ (WebCore::Internals::markerRangeForNode):
+ (WebCore::Internals::markerDescriptionForNode):
+ * testing/Internals.h:
+
+2014-10-19 Chris Dumez <[email protected]>
+
Use is<>() / downcast<>() for all remaining RenderObject subclasses
https://bugs.webkit.org/show_bug.cgi?id=137845
Modified: trunk/Source/WebCore/dom/DocumentMarkerController.cpp (174875 => 174876)
--- trunk/Source/WebCore/dom/DocumentMarkerController.cpp 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/dom/DocumentMarkerController.cpp 2014-10-20 05:17:06 UTC (rev 174876)
@@ -101,8 +101,8 @@
// the whole purpose of tickmarks on the scrollbar is to show where
// matches off-screen are (that haven't been painted yet).
Node* node = textPiece->startContainer();
- Vector<DocumentMarker*> markers = markersFor(node);
- static_cast<RenderedDocumentMarker*>(markers[markers.size() - 1])->setRenderedRect(range->boundingBox());
+ Vector<RenderedDocumentMarker*> markers = markersFor(node);
+ markers[markers.size() - 1]->setRenderedRect(range->boundingBox());
}
}
}
@@ -376,9 +376,9 @@
return 0;
}
-Vector<DocumentMarker*> DocumentMarkerController::markersFor(Node* node, DocumentMarker::MarkerTypes markerTypes)
+Vector<RenderedDocumentMarker*> DocumentMarkerController::markersFor(Node* node, DocumentMarker::MarkerTypes markerTypes)
{
- Vector<DocumentMarker*> result;
+ Vector<RenderedDocumentMarker*> result;
MarkerList* list = m_markers.get(node);
if (!list)
return result;
@@ -391,12 +391,12 @@
return result;
}
-Vector<DocumentMarker*> DocumentMarkerController::markersInRange(Range* range, DocumentMarker::MarkerTypes markerTypes)
+Vector<RenderedDocumentMarker*> DocumentMarkerController::markersInRange(Range* range, DocumentMarker::MarkerTypes markerTypes)
{
if (!possiblyHasMarkers(markerTypes))
- return Vector<DocumentMarker*>();
+ return Vector<RenderedDocumentMarker*>();
- Vector<DocumentMarker*> foundMarkers;
+ Vector<RenderedDocumentMarker*> foundMarkers;
Node* startContainer = range->startContainer();
ASSERT(startContainer);
@@ -405,10 +405,7 @@
Node* pastLastNode = range->pastLastNode();
for (Node* node = range->firstNode(); node != pastLastNode; node = NodeTraversal::next(node)) {
- Vector<DocumentMarker*> markers = markersFor(node);
- Vector<DocumentMarker*>::const_iterator end = markers.end();
- for (Vector<DocumentMarker*>::const_iterator it = markers.begin(); it != end; ++it) {
- DocumentMarker* marker = *it;
+ for (auto* marker : markersFor(node)) {
if (!markerTypes.contains(marker->type()))
continue;
if (node == startContainer && marker->endOffset() <= static_cast<unsigned>(range->startOffset()))
@@ -679,10 +676,7 @@
Node* pastLastNode = range->pastLastNode();
for (Node* node = range->firstNode(); node != pastLastNode; node = NodeTraversal::next(node)) {
- Vector<DocumentMarker*> markers = markersFor(node);
- Vector<DocumentMarker*>::const_iterator end = markers.end();
- for (Vector<DocumentMarker*>::const_iterator it = markers.begin(); it != end; ++it) {
- DocumentMarker* marker = *it;
+ for (auto* marker : markersFor(node)) {
if (!markerTypes.contains(marker->type()))
continue;
if (node == startContainer && marker->endOffset() <= static_cast<unsigned>(range->startOffset()))
Modified: trunk/Source/WebCore/dom/DocumentMarkerController.h (174875 => 174876)
--- trunk/Source/WebCore/dom/DocumentMarkerController.h 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/dom/DocumentMarkerController.h 2014-10-20 05:17:06 UTC (rev 174876)
@@ -84,8 +84,8 @@
void setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool);
DocumentMarker* markerContainingPoint(const LayoutPoint&, DocumentMarker::MarkerType);
- WEBCORE_EXPORT Vector<DocumentMarker*> markersFor(Node*, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
- WEBCORE_EXPORT Vector<DocumentMarker*> markersInRange(Range*, DocumentMarker::MarkerTypes);
+ WEBCORE_EXPORT Vector<RenderedDocumentMarker*> markersFor(Node*, DocumentMarker::MarkerTypes = DocumentMarker::AllMarkers());
+ WEBCORE_EXPORT Vector<RenderedDocumentMarker*> markersInRange(Range*, DocumentMarker::MarkerTypes);
WEBCORE_EXPORT Vector<IntRect> renderedRectsForMarkers(DocumentMarker::MarkerType);
void clearDescriptionOnMarkersIntersectingRange(Range*, DocumentMarker::MarkerTypes);
Modified: trunk/Source/WebCore/dom/RenderedDocumentMarker.h (174875 => 174876)
--- trunk/Source/WebCore/dom/RenderedDocumentMarker.h 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/dom/RenderedDocumentMarker.h 2014-10-20 05:17:06 UTC (rev 174876)
@@ -62,11 +62,6 @@
invalidate();
}
-inline RenderedDocumentMarker* toRenderedDocumentMarker(DocumentMarker* marker)
-{
- return static_cast<RenderedDocumentMarker*>(marker);
-}
-
} // namespace
#endif
Modified: trunk/Source/WebCore/editing/AlternativeTextController.cpp (174875 => 174876)
--- trunk/Source/WebCore/editing/AlternativeTextController.cpp 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/editing/AlternativeTextController.cpp 2014-10-20 05:17:06 UTC (rev 174876)
@@ -37,6 +37,7 @@
#include "Frame.h"
#include "FrameView.h"
#include "Page.h"
+#include "RenderedDocumentMarker.h"
#include "SpellingCorrectionCommand.h"
#include "TextCheckerClient.h"
#include "TextCheckingHelper.h"
@@ -114,7 +115,7 @@
return markerTypesForAppliedDictationAlternative;
}
-static bool markersHaveIdenticalDescription(const Vector<DocumentMarker*>& markers)
+static bool markersHaveIdenticalDescription(const Vector<RenderedDocumentMarker*>& markers)
{
if (markers.isEmpty())
return true;
@@ -469,13 +470,8 @@
return;
Node* node = position.containerNode();
- Vector<DocumentMarker*> markers = node->document().markers().markersFor(node);
- size_t markerCount = markers.size();
- for (size_t i = 0; i < markerCount; ++i) {
- const DocumentMarker* marker = markers[i];
- if (!marker)
- continue;
-
+ for (auto* marker : node->document().markers().markersFor(node)) {
+ ASSERT(marker);
if (respondToMarkerAtEndOfWord(*marker, position))
break;
}
@@ -554,7 +550,7 @@
if (!rangeOfCorrection)
return;
DocumentMarkerController& markers = rangeOfCorrection->startContainer()->document().markers();
- Vector<DocumentMarker*> correctedOnceMarkers = markers.markersInRange(rangeOfCorrection, DocumentMarker::Autocorrected);
+ Vector<RenderedDocumentMarker*> correctedOnceMarkers = markers.markersInRange(rangeOfCorrection, DocumentMarker::Autocorrected);
if (correctedOnceMarkers.isEmpty())
return;
@@ -613,10 +609,9 @@
Position precedingCharacterPosition = beginningOfRange.previous();
RefPtr<Range> precedingCharacterRange = Range::create(*m_frame.document(), precedingCharacterPosition, beginningOfRange);
- Vector<DocumentMarker*> markers = markerController.markersInRange(precedingCharacterRange.get(), DocumentMarker::DeletedAutocorrection);
-
- for (size_t i = 0; i < markers.size(); ++i) {
- if (markers[i]->description() == stringToBeReplaced)
+ Vector<RenderedDocumentMarker*> markers = markerController.markersInRange(precedingCharacterRange.get(), DocumentMarker::DeletedAutocorrection);
+ for (const auto* marker : markers) {
+ if (marker->description() == stringToBeReplaced)
return false;
}
@@ -735,9 +730,9 @@
if (!selection || !editor.shouldInsertText(alternativeString, selection.get(), EditorInsertActionPasted))
return;
DocumentMarkerController& markers = selection->startContainer()->document().markers();
- Vector<DocumentMarker*> dictationAlternativesMarkers = markers.markersInRange(selection.get(), DocumentMarker::DictationAlternatives);
- for (size_t i = 0; i < dictationAlternativesMarkers.size(); ++i)
- removeDictationAlternativesForMarker(dictationAlternativesMarkers[i]);
+ Vector<RenderedDocumentMarker*> dictationAlternativesMarkers = markers.markersInRange(selection.get(), DocumentMarker::DictationAlternatives);
+ for (auto* marker : dictationAlternativesMarkers)
+ removeDictationAlternativesForMarker(marker);
applyAlternativeTextToRange(selection.get(), alternativeString, AlternativeTextTypeDictationAlternatives, markerTypesForAppliedDictationAlternative());
#else
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (174875 => 174876)
--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2014-10-20 05:17:06 UTC (rev 174876)
@@ -57,6 +57,7 @@
#include "RemoveNodePreservingChildrenCommand.h"
#include "RenderBlockFlow.h"
#include "RenderText.h"
+#include "RenderedDocumentMarker.h"
#include "ReplaceNodeWithSpanCommand.h"
#include "ReplaceSelectionCommand.h"
#include "ScopedEventQueue.h"
@@ -574,7 +575,7 @@
return Position(textNode.release(), start.offsetInContainerNode() + text.length());
}
-static void copyMarkers(const Vector<DocumentMarker*>& markerPointers, Vector<DocumentMarker>& markers)
+static void copyMarkers(const Vector<RenderedDocumentMarker*>& markerPointers, Vector<RenderedDocumentMarker>& markers)
{
size_t arraySize = markerPointers.size();
markers.reserveCapacity(arraySize);
@@ -586,15 +587,15 @@
{
RefPtr<Text> node(prpNode);
DocumentMarkerController& markerController = document().markers();
- Vector<DocumentMarker> markers;
+ Vector<RenderedDocumentMarker> markers;
copyMarkers(markerController.markersInRange(Range::create(document(), node, offset, node, offset + count).get(), DocumentMarker::AllMarkers()), markers);
replaceTextInNode(node, offset, count, replacementText);
RefPtr<Range> newRange = Range::create(document(), node, offset, node, offset + replacementText.length());
- for (size_t i = 0; i < markers.size(); ++i)
+ for (const auto& marker : markers)
#if PLATFORM(IOS)
- markerController.addMarker(newRange.get(), markers[i].type(), markers[i].description(), markers[i].alternatives(), markers[i].metadata());
+ markerController.addMarker(newRange.get(), marker.type(), marker.description(), marker.alternatives(), marker.metadata());
#else
- markerController.addMarker(newRange.get(), markers[i].type(), markers[i].description());
+ markerController.addMarker(newRange.get(), marker.type(), marker.description());
#endif // PLATFORM(IOS)
}
Modified: trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp (174875 => 174876)
--- trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp 2014-10-20 05:17:06 UTC (rev 174876)
@@ -41,6 +41,7 @@
#include "NodeTraversal.h"
#include "RenderTableCell.h"
#include "RenderText.h"
+#include "RenderedDocumentMarker.h"
#include "Text.h"
#include "VisibleUnits.h"
@@ -765,9 +766,8 @@
return String();
RefPtr<Range> rangeOfFirstCharacter = Range::create(document(), startOfSelection.deepEquivalent(), nextPosition.deepEquivalent());
- Vector<DocumentMarker*> markers = document().markers().markersInRange(rangeOfFirstCharacter.get(), DocumentMarker::Autocorrected);
- for (size_t i = 0; i < markers.size(); ++i) {
- const DocumentMarker* marker = markers[i];
+ Vector<RenderedDocumentMarker*> markers = document().markers().markersInRange(rangeOfFirstCharacter.get(), DocumentMarker::Autocorrected);
+ for (auto* marker : markers) {
int startOffset = marker->startOffset();
if (startOffset == startOfSelection.deepEquivalent().offsetInContainerNode())
return marker->description();
Modified: trunk/Source/WebCore/editing/Editor.cpp (174875 => 174876)
--- trunk/Source/WebCore/editing/Editor.cpp 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/editing/Editor.cpp 2014-10-20 05:17:06 UTC (rev 174876)
@@ -71,6 +71,7 @@
#include "RemoveFormatCommand.h"
#include "RenderBlock.h"
#include "RenderTextControl.h"
+#include "RenderedDocumentMarker.h"
#include "RenderedPosition.h"
#include "ReplaceSelectionCommand.h"
#include "Settings.h"
@@ -2753,9 +2754,9 @@
// of marker that contains the word in question, and remove marker on that whole range.
RefPtr<Range> wordRange = Range::create(document(), startOfFirstWord.deepEquivalent(), endOfLastWord.deepEquivalent());
- Vector<DocumentMarker*> markers = document().markers().markersInRange(wordRange.get(), DocumentMarker::DictationAlternatives);
- for (size_t i = 0; i < markers.size(); ++i)
- m_alternativeTextController->removeDictationAlternativesForMarker(markers[i]);
+ Vector<RenderedDocumentMarker*> markers = document().markers().markersInRange(wordRange.get(), DocumentMarker::DictationAlternatives);
+ for (auto* marker : markers)
+ m_alternativeTextController->removeDictationAlternativesForMarker(marker);
#if PLATFORM(IOS)
document().markers().removeMarkers(wordRange.get(), DocumentMarker::Spelling | DocumentMarker::CorrectionIndicator | DocumentMarker::SpellCheckingExemption | DocumentMarker::DictationAlternatives | DocumentMarker::DictationPhraseWithAlternatives, DocumentMarkerController::RemovePartiallyOverlappingMarker);
@@ -3542,9 +3543,8 @@
unsigned int startOffset = static_cast<unsigned int>(from);
unsigned int endOffset = static_cast<unsigned int>(from + length);
- Vector<DocumentMarker*> markers = document().markers().markersFor(node);
- for (size_t i = 0; i < markers.size(); ++i) {
- DocumentMarker* marker = markers[i];
+ Vector<RenderedDocumentMarker*> markers = document().markers().markersFor(node);
+ for (auto* marker : markers) {
if (marker->startOffset() <= startOffset && endOffset <= marker->endOffset() && marker->type() == markerType)
return true;
}
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (174875 => 174876)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2014-10-20 05:17:06 UTC (rev 174876)
@@ -509,7 +509,7 @@
}
}
- GraphicsContext* context = paintInfo.context;
+ GraphicsContext& context = *paintInfo.context;
const RenderStyle& lineStyle = this->lineStyle();
@@ -523,7 +523,7 @@
bool shouldRotate = !isHorizontal() && !combinedText;
if (shouldRotate)
- context->concatCTM(rotation(boxRect, Clockwise));
+ context.concatCTM(rotation(boxRect, Clockwise));
// Determine whether or not we have composition underlines to draw.
bool containsComposition = renderer().textNode() && renderer().frame().editor().compositionNode() == renderer().textNode();
@@ -616,18 +616,18 @@
else
textOrigin.setX(roundToDevicePixel(LayoutUnit(textOrigin.x()), renderer().document().deviceScaleFactor()));
- TextPainter textPainter(*context, paintSelectedTextOnly, paintSelectedTextSeparately, font, sPos, ePos, length, emphasisMark, combinedText, textRun, boxRect, textOrigin, emphasisMarkOffset, textShadow, selectionShadow, isHorizontal(), textPaintStyle, selectionPaintStyle);
+ TextPainter textPainter(context, paintSelectedTextOnly, paintSelectedTextSeparately, font, sPos, ePos, length, emphasisMark, combinedText, textRun, boxRect, textOrigin, emphasisMarkOffset, textShadow, selectionShadow, isHorizontal(), textPaintStyle, selectionPaintStyle);
textPainter.paintText();
// Paint decorations
TextDecoration textDecorations = lineStyle.textDecorationsInEffect();
if (textDecorations != TextDecorationNone && paintInfo.phase != PaintPhaseSelection) {
- updateGraphicsContext(*context, textPaintStyle);
+ updateGraphicsContext(context, textPaintStyle);
if (combinedText)
- context->concatCTM(rotation(boxRect, Clockwise));
- paintDecoration(*context, boxOrigin, textDecorations, lineStyle.textDecorationStyle(), textShadow, textPainter);
+ context.concatCTM(rotation(boxRect, Clockwise));
+ paintDecoration(context, boxOrigin, textDecorations, lineStyle.textDecorationStyle(), textShadow, textPainter);
if (combinedText)
- context->concatCTM(rotation(boxRect, Counterclockwise));
+ context.concatCTM(rotation(boxRect, Counterclockwise));
}
if (paintInfo.phase == PaintPhaseForeground) {
@@ -660,7 +660,7 @@
}
if (shouldRotate)
- context->concatCTM(rotation(boxRect, Counterclockwise));
+ context.concatCTM(rotation(boxRect, Counterclockwise));
}
void InlineTextBox::selectionStartEnd(int& sPos, int& ePos)
@@ -681,10 +681,10 @@
ePos = std::min(endPos - m_start, (int)m_len);
}
-void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, Color textColor)
+void InlineTextBox::paintSelection(GraphicsContext& context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, Color textColor)
{
#if ENABLE(TEXT_SELECTION)
- if (context->paintingDisabled())
+ if (context.paintingDisabled())
return;
// See if we have a selection to paint at all.
@@ -702,8 +702,8 @@
if (textColor == c)
c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
- GraphicsContextStateSaver stateSaver(*context);
- updateGraphicsContext(*context, TextPaintStyle(c, style.colorSpace())); // Don't draw text at all!
+ GraphicsContextStateSaver stateSaver(context);
+ updateGraphicsContext(context, TextPaintStyle(c, style.colorSpace())); // Don't draw text at all!
// If the text is truncated, let the thing being painted in the truncation
// draw its own highlight.
@@ -730,7 +730,7 @@
LayoutRect selectionRect = LayoutRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_logicalWidth, selectionHeight);
font.adjustSelectionRectForText(textRun, selectionRect, sPos, ePos);
- context->fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), textRun.ltr()), c, style.colorSpace());
+ context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), textRun.ltr()), c, style.colorSpace());
#else
UNUSED_PARAM(context);
UNUSED_PARAM(boxOrigin);
@@ -740,7 +740,7 @@
#endif
}
-void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, int startPos, int endPos)
+void InlineTextBox::paintCompositionBackground(GraphicsContext& context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, int startPos, int endPos)
{
int offset = m_start;
int sPos = std::max(startPos - offset, 0);
@@ -749,15 +749,15 @@
if (sPos >= ePos)
return;
- GraphicsContextStateSaver stateSaver(*context);
+ GraphicsContextStateSaver stateSaver(context);
Color compositionColor = Color::compositionFill;
- updateGraphicsContext(*context, TextPaintStyle(compositionColor, style.colorSpace())); // Don't draw text at all!
+ updateGraphicsContext(context, TextPaintStyle(compositionColor, style.colorSpace())); // Don't draw text at all!
LayoutUnit deltaY = renderer().style().isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
LayoutRect selectionRect = LayoutRect(boxOrigin.x(), boxOrigin.y() - deltaY, 0, selectionHeight());
TextRun textRun = constructTextRun(style, font);
font.adjustSelectionRectForText(textRun, selectionRect, sPos, ePos);
- context->fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), textRun.ltr()), compositionColor, style.colorSpace());
+ context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), textRun.ltr()), compositionColor, style.colorSpace());
}
static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorationStyle)
@@ -1061,7 +1061,7 @@
}
}
-void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPoint& boxOrigin, DocumentMarker* marker, const RenderStyle& style, const Font& font, bool grammar)
+void InlineTextBox::paintDocumentMarker(GraphicsContext& context, const FloatPoint& boxOrigin, RenderedDocumentMarker& marker, const RenderStyle& style, const Font& font, bool grammar)
{
// Never print spelling/grammar markers (5327887)
if (renderer().document().printing())
@@ -1075,17 +1075,17 @@
// Determine whether we need to measure text
bool markerSpansWholeBox = true;
- if (m_start <= (int)marker->startOffset())
+ if (m_start <= (int)marker.startOffset())
markerSpansWholeBox = false;
- if ((end() + 1) != marker->endOffset()) // end points at the last char, not past it
+ if ((end() + 1) != marker.endOffset()) // end points at the last char, not past it
markerSpansWholeBox = false;
if (m_truncation != cNoTruncation)
markerSpansWholeBox = false;
- bool isDictationMarker = marker->type() == DocumentMarker::DictationAlternatives;
+ bool isDictationMarker = marker.type() == DocumentMarker::DictationAlternatives;
if (!markerSpansWholeBox || grammar || isDictationMarker) {
- int startPosition = std::max<int>(marker->startOffset() - m_start, 0);
- int endPosition = std::min<int>(marker->endOffset() - m_start, m_len);
+ int startPosition = std::max<int>(marker.startOffset() - m_start, 0);
+ int endPosition = std::min<int>(marker.endOffset() - m_start, m_len);
if (m_truncation != cNoTruncation)
endPosition = std::min<int>(endPosition, m_truncation);
@@ -1107,7 +1107,7 @@
if (grammar || isDictationMarker) {
markerRect.move(-boxOrigin.x(), -boxOrigin.y());
markerRect = renderer().localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox();
- toRenderedDocumentMarker(marker)->setRenderedRect(markerRect);
+ marker.setRenderedRect(markerRect);
}
}
@@ -1128,15 +1128,15 @@
// In larger fonts, though, place the underline up near the baseline to prevent a big gap.
underlineOffset = baseline + 2;
}
- pt->drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y() + underlineOffset), width, lineStyleForMarkerType(marker->type()));
+ context.drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y() + underlineOffset), width, lineStyleForMarkerType(marker.type()));
}
-void InlineTextBox::paintTextMatchMarker(GraphicsContext* context, const FloatPoint& boxOrigin, DocumentMarker* marker, const RenderStyle& style, const Font& font)
+void InlineTextBox::paintTextMatchMarker(GraphicsContext& context, const FloatPoint& boxOrigin, RenderedDocumentMarker& marker, const RenderStyle& style, const Font& font)
{
LayoutUnit selectionHeight = this->selectionHeight();
- int sPos = std::max(marker->startOffset() - m_start, (unsigned)0);
- int ePos = std::min(marker->endOffset() - m_start, (unsigned)m_len);
+ int sPos = std::max(marker.startOffset() - m_start, (unsigned)0);
+ int ePos = std::min(marker.endOffset() - m_start, (unsigned)m_len);
TextRun run = constructTextRun(style, font);
// Always compute and store the rect associated with this marker. The computed rect is in absolute coordinates.
@@ -1145,31 +1145,31 @@
font.adjustSelectionRectForText(run, renderedRect, sPos, ePos);
IntRect markerRect = enclosingIntRect(renderedRect);
markerRect = renderer().localToAbsoluteQuad(FloatQuad(markerRect)).enclosingBoundingBox();
- toRenderedDocumentMarker(marker)->setRenderedRect(markerRect);
+ marker.setRenderedRect(markerRect);
// Optionally highlight the text
if (renderer().frame().editor().markedTextMatchesAreHighlighted()) {
- Color color = marker->activeMatch() ? renderer().theme().platformActiveTextSearchHighlightColor() : renderer().theme().platformInactiveTextSearchHighlightColor();
- GraphicsContextStateSaver stateSaver(*context);
- updateGraphicsContext(*context, TextPaintStyle(color, style.colorSpace())); // Don't draw text at all!
+ Color color = marker.activeMatch() ? renderer().theme().platformActiveTextSearchHighlightColor() : renderer().theme().platformInactiveTextSearchHighlightColor();
+ GraphicsContextStateSaver stateSaver(context);
+ updateGraphicsContext(context, TextPaintStyle(color, style.colorSpace())); // Don't draw text at all!
// Use same y positioning and height as for selection, so that when the selection and this highlight are on
// the same word there are no pieces sticking out.
LayoutUnit deltaY = renderer().style().isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
LayoutRect selectionRect = LayoutRect(boxOrigin.x(), boxOrigin.y() - deltaY, 0, selectionHeight);
font.adjustSelectionRectForText(run, selectionRect, sPos, ePos);
- context->fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), run.ltr()), color, style.colorSpace());
+ context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), run.ltr()), color, style.colorSpace());
}
}
-void InlineTextBox::computeRectForReplacementMarker(DocumentMarker* marker, const RenderStyle& style, const Font& font)
+void InlineTextBox::computeRectForReplacementMarker(RenderedDocumentMarker& marker, const RenderStyle& style, const Font& font)
{
// Replacement markers are not actually drawn, but their rects need to be computed for hit testing.
LayoutUnit top = selectionTop();
LayoutUnit h = selectionHeight();
- int sPos = std::max(marker->startOffset() - m_start, (unsigned)0);
- int ePos = std::min(marker->endOffset() - m_start, (unsigned)m_len);
+ int sPos = std::max(marker.startOffset() - m_start, (unsigned)0);
+ int ePos = std::min(marker.endOffset() - m_start, (unsigned)m_len);
TextRun run = constructTextRun(style, font);
// Compute and store the rect associated with this marker.
@@ -1177,22 +1177,19 @@
font.adjustSelectionRectForText(run, selectionRect, sPos, ePos);
IntRect markerRect = enclosingIntRect(selectionRect);
markerRect = renderer().localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox();
- toRenderedDocumentMarker(marker)->setRenderedRect(markerRect);
+ marker.setRenderedRect(markerRect);
}
-void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, bool background)
+void InlineTextBox::paintDocumentMarkers(GraphicsContext& context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, bool background)
{
if (!renderer().textNode())
return;
- Vector<DocumentMarker*> markers = renderer().document().markers().markersFor(renderer().textNode());
- Vector<DocumentMarker*>::const_iterator markerIt = markers.begin();
+ Vector<RenderedDocumentMarker*> markers = renderer().document().markers().markersFor(renderer().textNode());
// Give any document markers that touch this run a chance to draw before the text has been drawn.
// Note end() points at the last char, not one past it like endOffset and ranges do.
- for ( ; markerIt != markers.end(); ++markerIt) {
- DocumentMarker* marker = *markerIt;
-
+ for (auto* marker : markers) {
// Paint either the background markers or the foreground markers, but not both
switch (marker->type()) {
case DocumentMarker::Grammar:
@@ -1232,22 +1229,22 @@
case DocumentMarker::Spelling:
case DocumentMarker::CorrectionIndicator:
case DocumentMarker::DictationAlternatives:
- paintDocumentMarker(pt, boxOrigin, marker, style, font, false);
+ paintDocumentMarker(context, boxOrigin, *marker, style, font, false);
break;
case DocumentMarker::Grammar:
- paintDocumentMarker(pt, boxOrigin, marker, style, font, true);
+ paintDocumentMarker(context, boxOrigin, *marker, style, font, true);
break;
#if PLATFORM(IOS)
// FIXME: See <rdar://problem/8933352>. Also, remove the PLATFORM(IOS)-guard.
case DocumentMarker::DictationPhraseWithAlternatives:
- paintDocumentMarker(pt, boxOrigin, marker, style, font, true);
+ paintDocumentMarker(context, boxOrigin, *marker, style, font, true);
break;
#endif
case DocumentMarker::TextMatch:
- paintTextMatchMarker(pt, boxOrigin, marker, style, font);
+ paintTextMatchMarker(context, boxOrigin, *marker, style, font);
break;
case DocumentMarker::Replacement:
- computeRectForReplacementMarker(marker, style, font);
+ computeRectForReplacementMarker(*marker, style, font);
break;
#if ENABLE(TELEPHONE_NUMBER_DETECTION)
case DocumentMarker::TelephoneNumber:
@@ -1260,7 +1257,7 @@
}
}
-void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, const FloatPoint& boxOrigin, const CompositionUnderline& underline)
+void InlineTextBox::paintCompositionUnderline(GraphicsContext& context, const FloatPoint& boxOrigin, const CompositionUnderline& underline)
{
if (m_truncation == cFullTruncation)
return;
@@ -1300,9 +1297,9 @@
start += 1;
width -= 2;
- ctx->setStrokeColor(underline.color, renderer().style().colorSpace());
- ctx->setStrokeThickness(lineThickness);
- ctx->drawLineForText(FloatPoint(boxOrigin.x() + start, boxOrigin.y() + logicalHeight() - lineThickness), width, renderer().document().printing());
+ context.setStrokeColor(underline.color, renderer().style().colorSpace());
+ context.setStrokeThickness(lineThickness);
+ context.drawLineForText(FloatPoint(boxOrigin.x() + start, boxOrigin.y() + logicalHeight() - lineThickness), width, renderer().document().printing());
}
int InlineTextBox::caretMinOffset() const
Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (174875 => 174876)
--- trunk/Source/WebCore/rendering/InlineTextBox.h 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h 2014-10-20 05:17:06 UTC (rev 174876)
@@ -30,7 +30,7 @@
namespace WebCore {
struct CompositionUnderline;
-class DocumentMarker;
+class RenderedDocumentMarker;
class TextPainter;
const unsigned short cNoTruncation = USHRT_MAX;
@@ -148,17 +148,17 @@
virtual float positionForOffset(int offset) const;
protected:
- void paintCompositionBackground(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, int startPos, int endPos);
- void paintDocumentMarkers(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, bool background);
- void paintCompositionUnderline(GraphicsContext*, const FloatPoint& boxOrigin, const CompositionUnderline&);
+ void paintCompositionBackground(GraphicsContext&, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, int startPos, int endPos);
+ void paintDocumentMarkers(GraphicsContext&, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, bool background);
+ void paintCompositionUnderline(GraphicsContext&, const FloatPoint& boxOrigin, const CompositionUnderline&);
private:
void paintDecoration(GraphicsContext&, const FloatPoint& boxOrigin, TextDecoration, TextDecorationStyle, const ShadowData*, TextPainter&);
- void paintSelection(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, Color textColor);
- void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, const RenderStyle&, const Font&, bool grammar);
- void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, const RenderStyle&, const Font&);
+ void paintSelection(GraphicsContext&, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, Color textColor);
+ void paintDocumentMarker(GraphicsContext&, const FloatPoint& boxOrigin, RenderedDocumentMarker&, const RenderStyle&, const Font&, bool grammar);
+ void paintTextMatchMarker(GraphicsContext&, const FloatPoint& boxOrigin, RenderedDocumentMarker&, const RenderStyle&, const Font&);
- void computeRectForReplacementMarker(DocumentMarker*, const RenderStyle&, const Font&);
+ void computeRectForReplacementMarker(RenderedDocumentMarker&, const RenderStyle&, const Font&);
TextRun::ExpansionBehavior expansionBehavior() const
{
Modified: trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp (174875 => 174876)
--- trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp 2014-10-20 05:17:06 UTC (rev 174876)
@@ -83,12 +83,8 @@
RenderStyle& style = textRenderer->style();
AffineTransform fragmentTransform;
- Vector<DocumentMarker*> markers = textRenderer->document().markers().markersFor(&textNode);
-
- Vector<DocumentMarker*>::iterator markerEnd = markers.end();
- for (Vector<DocumentMarker*>::iterator markerIt = markers.begin(); markerIt != markerEnd; ++markerIt) {
- DocumentMarker* marker = *markerIt;
-
+ Vector<RenderedDocumentMarker*> markers = textRenderer->document().markers().markersFor(&textNode);
+ for (auto* marker : markers) {
// SVG is only interessted in the TextMatch marker, for now.
if (marker->type() != DocumentMarker::TextMatch)
continue;
@@ -128,7 +124,7 @@
}
}
- toRenderedDocumentMarker(marker)->setRenderedRect(textRenderer->localToAbsoluteQuad(markerRect).enclosingBoundingBox());
+ marker->setRenderedRect(textRenderer->localToAbsoluteQuad(markerRect).enclosingBoundingBox());
}
}
Modified: trunk/Source/WebCore/testing/Internals.cpp (174875 => 174876)
--- trunk/Source/WebCore/testing/Internals.cpp 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/testing/Internals.cpp 2014-10-20 05:17:06 UTC (rev 174876)
@@ -85,6 +85,7 @@
#include "RenderMenuList.h"
#include "RenderTreeAsText.h"
#include "RenderView.h"
+#include "RenderedDocumentMarker.h"
#include "RuntimeEnabledFeatures.h"
#include "SchemeRegistry.h"
#include "ScrollingCoordinator.h"
@@ -779,39 +780,39 @@
return node->document().markers().markersFor(node, markerTypes).size();
}
-DocumentMarker* Internals::markerAt(Node* node, const String& markerType, unsigned index, ExceptionCode& ec)
+RenderedDocumentMarker* Internals::markerAt(Node* node, const String& markerType, unsigned index, ExceptionCode& ec)
{
node->document().updateLayoutIgnorePendingStylesheets();
if (!node) {
ec = INVALID_ACCESS_ERR;
- return 0;
+ return nullptr;
}
DocumentMarker::MarkerTypes markerTypes = 0;
if (!markerTypesFrom(markerType, markerTypes)) {
ec = SYNTAX_ERR;
- return 0;
+ return nullptr;
}
node->document().frame()->editor().updateEditorUINowIfScheduled();
- Vector<DocumentMarker*> markers = node->document().markers().markersFor(node, markerTypes);
+ Vector<RenderedDocumentMarker*> markers = node->document().markers().markersFor(node, markerTypes);
if (markers.size() <= index)
- return 0;
+ return nullptr;
return markers[index];
}
PassRefPtr<Range> Internals::markerRangeForNode(Node* node, const String& markerType, unsigned index, ExceptionCode& ec)
{
- DocumentMarker* marker = markerAt(node, markerType, index, ec);
+ RenderedDocumentMarker* marker = markerAt(node, markerType, index, ec);
if (!marker)
- return 0;
+ return nullptr;
return Range::create(node->document(), node, marker->startOffset(), node, marker->endOffset());
}
String Internals::markerDescriptionForNode(Node* node, const String& markerType, unsigned index, ExceptionCode& ec)
{
- DocumentMarker* marker = markerAt(node, markerType, index, ec);
+ RenderedDocumentMarker* marker = markerAt(node, markerType, index, ec);
if (!marker)
return String();
return marker->description();
Modified: trunk/Source/WebCore/testing/Internals.h (174875 => 174876)
--- trunk/Source/WebCore/testing/Internals.h 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebCore/testing/Internals.h 2014-10-20 05:17:06 UTC (rev 174876)
@@ -46,7 +46,6 @@
class DOMStringList;
class DOMWindow;
class Document;
-class DocumentMarker;
class Element;
class Frame;
class InspectorFrontendChannelDummy;
@@ -57,6 +56,7 @@
class Node;
class Page;
class Range;
+class RenderedDocumentMarker;
class ScriptExecutionContext;
class SerializedScriptValue;
class SourceBuffer;
@@ -351,7 +351,7 @@
Frame* frame() const;
Vector<String> iconURLs(Document*, int iconTypesMask) const;
- DocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionCode&);
+ RenderedDocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionCode&);
#if ENABLE(INSPECTOR)
RefPtr<DOMWindow> m_frontendWindow;
std::unique_ptr<InspectorFrontendClientDummy> m_frontendClient;
Modified: trunk/Source/WebKit/ChangeLog (174875 => 174876)
--- trunk/Source/WebKit/ChangeLog 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebKit/ChangeLog 2014-10-20 05:17:06 UTC (rev 174876)
@@ -1,3 +1,14 @@
+2014-10-19 Chris Dumez <[email protected]>
+
+ Kill toRenderedDocumentMarker() by using tighter typing
+ https://bugs.webkit.org/show_bug.cgi?id=137858
+
+ Reviewed by Darin Adler.
+
+ Update symbol export for Windows due to argument type change.
+
+ * WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in:
+
2014-10-17 [email protected] <[email protected]>
[WinCairo] Accelerated compositing is not implemented.
Modified: trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in (174875 => 174876)
--- trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in 2014-10-20 03:42:03 UTC (rev 174875)
+++ trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in 2014-10-20 05:17:06 UTC (rev 174876)
@@ -427,7 +427,7 @@
symbolWithPointer(?setAutofilled@HTMLInputElement@WebCore@@QAEX_N@Z, ?setAutofilled@HTMLInputElement@WebCore@@QEAAX_N@Z)
symbolWithPointer(?setDocumentState@HistoryItem@WebCore@@QAEXABV?$Vector@VString@WTF@@$0A@VCrashOnOverflow@2@@WTF@@@Z, ?setDocumentState@HistoryItem@WebCore@@QEAAXAEBV?$Vector@VString@WTF@@$0A@VCrashOnOverflow@2@@WTF@@@Z)
symbolWithPointer(?overrideUserPreferredLanguages@WebCore@@YAXABV?$Vector@VString@WTF@@$0A@VCrashOnOverflow@2@@WTF@@@Z, ?overrideUserPreferredLanguages@WebCore@@YAXAEBV?$Vector@VString@WTF@@$0A@VCrashOnOverflow@2@@WTF@@@Z)
- symbolWithPointer(?markersFor@DocumentMarkerController@WebCore@@QAE?AV?$Vector@PAVDocumentMarker@WebCore@@$0A@VCrashOnOverflow@WTF@@@WTF@@PAVNode@2@VMarkerTypes@DocumentMarker@2@@Z, ?markersFor@DocumentMarkerController@WebCore@@QEAA?AV?$Vector@PEAVDocumentMarker@WebCore@@$0A@VCrashOnOverflow@WTF@@@WTF@@PEAVNode@2@VMarkerTypes@DocumentMarker@2@@Z)
+ symbolWithPointer(?markersFor@DocumentMarkerController@WebCore@@QAE?AV?$Vector@PAVRenderedDocumentMarker@WebCore@@$0A@VCrashOnOverflow@WTF@@@WTF@@PAVNode@2@VMarkerTypes@DocumentMarker@2@@Z, ?markersFor@DocumentMarkerController@WebCore@@QEAA?AV?$Vector@PEAVRenderedDocumentMarker@WebCore@@$0A@VCrashOnOverflow@WTF@@@WTF@@PEAVNode@2@VMarkerTypes@DocumentMarker@2@@Z)
symbolWithPointer(?getReferencedFilePaths@FormController@WebCore@@SA?AV?$Vector@VString@WTF@@$0A@VCrashOnOverflow@2@@WTF@@ABV34@@Z, ?getReferencedFilePaths@FormController@WebCore@@SA?AV?$Vector@VString@WTF@@$0A@VCrashOnOverflow@2@@WTF@@AEBV34@@Z)
symbolWithPointer(?iconURLs@Document@WebCore@@QAEABV?$Vector@UIconURL@WebCore@@$0A@VCrashOnOverflow@WTF@@@WTF@@H@Z, ?iconURLs@Document@WebCore@@QEAAAEBV?$Vector@UIconURL@WebCore@@$0A@VCrashOnOverflow@WTF@@@WTF@@H@Z)
?userPreferredLanguages@WebCore@@YA?AV?$Vector@VString@WTF@@$0A@VCrashOnOverflow@2@@WTF@@XZ