bool Page::findString(const String& target, TextCaseSensitivity caseSensitivity, FindDirection direction, bool shouldWrap) { if (target.isEmpty() || !mainFrame()) return false; Frame* frame = focusController()->focusedOrMainFrame(); Frame* startFrame = frame; do { if (frame->findString(target, direction == FindDirectionForward, caseSensitivity == TextCaseSensitive, false, true)) { if (frame != startFrame) startFrame->selection()->clear(); focusController()->setFocusedFrame(frame); return true; } frame = incrementFrame(frame, direction == FindDirectionForward, shouldWrap); } while (frame && frame != startFrame); // Search contents of startFrame, on the other side of the selection that we did earlier. // We cheat a bit and just research with wrap on if (shouldWrap && !startFrame->selection()->isNone()) { bool found = startFrame->findString(target, direction == FindDirectionForward, caseSensitivity == TextCaseSensitive, true, true); focusController()->setFocusedFrame(frame); return found; } return false; }
PassRefPtr<Range> Page::rangeOfString(const String& target, Range* referenceRange, FindOptions options) { if (target.isEmpty() || !mainFrame()) return 0; if (referenceRange && referenceRange->ownerDocument()->page() != this) return 0; bool shouldWrap = options & WrapAround; Frame* frame = referenceRange ? referenceRange->ownerDocument()->frame() : mainFrame(); Frame* startFrame = frame; do { if (RefPtr<Range> resultRange = frame->editor().rangeOfString(target, frame == startFrame ? referenceRange : 0, options & ~WrapAround)) return resultRange.release(); frame = incrementFrame(frame, !(options & Backwards), shouldWrap); } while (frame && frame != startFrame); // Search contents of startFrame, on the other side of the reference range that we did earlier. // We cheat a bit and just search again with wrap on. if (shouldWrap && referenceRange) { if (RefPtr<Range> resultRange = startFrame->editor().rangeOfString(target, referenceRange, options | WrapAround | StartInSelection)) return resultRange.release(); } return 0; }
bool Page::findString(const String& target, FindOptions options) { if (target.isEmpty() || !mainFrame()) return false; bool shouldWrap = options & WrapAround; Frame* frame = focusController()->focusedOrMainFrame(); Frame* startFrame = frame; do { if (frame->editor().findString(target, (options & ~WrapAround) | StartInSelection)) { if (frame != startFrame) startFrame->selection()->clear(); focusController()->setFocusedFrame(frame); return true; } frame = incrementFrame(frame, !(options & Backwards), shouldWrap); } while (frame && frame != startFrame); // Search contents of startFrame, on the other side of the selection that we did earlier. // We cheat a bit and just research with wrap on if (shouldWrap && !startFrame->selection()->isNone()) { bool found = startFrame->editor().findString(target, options | WrapAround | StartInSelection); focusController()->setFocusedFrame(frame); return found; } return false; }
void AnimationRenderer::update(GameObject& owner) { Point cameraPos = textureSheet_->getWindow()->getCamera().getPos(); drawDest_.x = owner.getPosX() - cameraPos.x; drawDest_.y = owner.getPosY() - cameraPos.y; drawSrc_ = textureSheet_->getFrame(currFrame_); MySDL_RenderCopy(textureSheet_->getWindow()->getRenderer(), textureSheet_->getTexture(), drawSrc_, &drawDest_); incrementFrame(); }
void Page::unmarkAllTextMatches() { if (!mainFrame()) return; Frame* frame = mainFrame(); do { frame->document()->markers()->removeMarkers(DocumentMarker::TextMatch); frame = incrementFrame(frame, true, false); } while (frame); }
unsigned int Page::markAllMatchesForText(const String& target, TextCaseSensitivity caseSensitivity, bool shouldHighlight, unsigned limit) { if (target.isEmpty() || !mainFrame()) return 0; unsigned matches = 0; Frame* frame = mainFrame(); do { frame->setMarkedTextMatchesAreHighlighted(shouldHighlight); matches += frame->markAllMatchesForText(target, caseSensitivity == TextCaseSensitive, (limit == 0) ? 0 : (limit - matches)); frame = incrementFrame(frame, true, false); } while (frame); return matches; }
unsigned Page::findMatchesForText(const String& target, FindOptions options, unsigned maxMatchCount, ShouldHighlightMatches shouldHighlightMatches, ShouldMarkMatches shouldMarkMatches) { if (target.isEmpty() || !mainFrame()) return 0; unsigned matchCount = 0; Frame* frame = mainFrame(); do { if (shouldMarkMatches == MarkMatches) frame->editor().setMarkedTextMatchesAreHighlighted(shouldHighlightMatches == HighlightMatches); matchCount += frame->editor().countMatchesForText(target, 0, options, maxMatchCount ? (maxMatchCount - matchCount) : 0, shouldMarkMatches == MarkMatches, 0); frame = incrementFrame(frame, true, false); } while (frame); return matchCount; }
void Page::findStringMatchingRanges(const String& target, FindOptions options, int limit, Vector<RefPtr<Range> >* matchRanges, int& indexForSelection) { indexForSelection = 0; if (!mainFrame()) return; Frame* frame = mainFrame(); Frame* frameWithSelection = 0; do { frame->editor().countMatchesForText(target, 0, options, limit ? (limit - matchRanges->size()) : 0, true, matchRanges); if (frame->selection()->isRange()) frameWithSelection = frame; frame = incrementFrame(frame, true, false); } while (frame); if (matchRanges->isEmpty()) return; if (frameWithSelection) { indexForSelection = NoMatchAfterUserSelection; RefPtr<Range> selectedRange = frameWithSelection->selection()->selection().firstRange(); if (options & Backwards) { for (size_t i = matchRanges->size(); i > 0; --i) { if (selectedRange->compareBoundaryPoints(Range::END_TO_START, matchRanges->at(i - 1).get(), IGNORE_EXCEPTION) > 0) { indexForSelection = i - 1; break; } } } else { for (size_t i = 0; i < matchRanges->size(); ++i) { if (selectedRange->compareBoundaryPoints(Range::START_TO_END, matchRanges->at(i).get(), IGNORE_EXCEPTION) < 0) { indexForSelection = i; break; } } } } else { if (options & Backwards) indexForSelection = matchRanges->size() - 1; else indexForSelection = 0; } }