PassOwnPtr<Keyframe::PropertySpecificKeyframe> AnimatableValueKeyframe::createPropertySpecificKeyframe(CSSPropertyID property) const { return adoptPtr(new PropertySpecificKeyframe(offset(), &easing(), propertyValue(property), composite())); }
void ScopedEventQueue::initialize() { ASSERT(!s_instance); OwnPtr<ScopedEventQueue> instance = adoptPtr(new ScopedEventQueue); s_instance = instance.leakPtr(); }
PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::create(const SharedBuffer& data, ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorOption) { OwnPtr<ImageDecoder> actualDecoder = ImageDecoder::create(data, alphaOption, gammaAndColorOption); return actualDecoder ? adoptPtr(new DeferredImageDecoder(actualDecoder.release())) : nullptr; }
PassOwnPtr<WorkerObjectProxy> WorkerObjectProxy::create(WorkerMessagingProxy* messagingProxy) { ASSERT(messagingProxy); return adoptPtr(new WorkerObjectProxy(messagingProxy)); }
PassOwnPtr<InjectedScriptManager> InjectedScriptManager::createForPage() { return adoptPtr(new InjectedScriptManager(&InjectedScriptManager::canAccessInspectedWindow)); }
JSGlobalData::JSGlobalData(GlobalDataType globalDataType, HeapType heapType) : #if ENABLE(ASSEMBLER) executableAllocator(*this), #endif heap(this, heapType) , globalDataType(globalDataType) , clientData(0) , topCallFrame(CallFrame::noCaller()) , arrayConstructorTable(fastNew<HashTable>(JSC::arrayConstructorTable)) , arrayPrototypeTable(fastNew<HashTable>(JSC::arrayPrototypeTable)) , booleanPrototypeTable(fastNew<HashTable>(JSC::booleanPrototypeTable)) , dateTable(fastNew<HashTable>(JSC::dateTable)) , dateConstructorTable(fastNew<HashTable>(JSC::dateConstructorTable)) , errorPrototypeTable(fastNew<HashTable>(JSC::errorPrototypeTable)) , globalObjectTable(fastNew<HashTable>(JSC::globalObjectTable)) , jsonTable(fastNew<HashTable>(JSC::jsonTable)) , mathTable(fastNew<HashTable>(JSC::mathTable)) , numberConstructorTable(fastNew<HashTable>(JSC::numberConstructorTable)) , numberPrototypeTable(fastNew<HashTable>(JSC::numberPrototypeTable)) , objectConstructorTable(fastNew<HashTable>(JSC::objectConstructorTable)) , privateNamePrototypeTable(fastNew<HashTable>(JSC::privateNamePrototypeTable)) , regExpTable(fastNew<HashTable>(JSC::regExpTable)) , regExpConstructorTable(fastNew<HashTable>(JSC::regExpConstructorTable)) , regExpPrototypeTable(fastNew<HashTable>(JSC::regExpPrototypeTable)) , stringConstructorTable(fastNew<HashTable>(JSC::stringConstructorTable)) , identifierTable(globalDataType == Default ? wtfThreadData().currentIdentifierTable() : createIdentifierTable()) , propertyNames(new CommonIdentifiers(this)) , emptyList(new MarkedArgumentBuffer) , parserArena(adoptPtr(new ParserArena)) , keywords(adoptPtr(new Keywords(this))) , interpreter(0) , jsArrayClassInfo(&JSArray::s_info) , jsFinalObjectClassInfo(&JSFinalObject::s_info) #if ENABLE(DFG_JIT) , sizeOfLastScratchBuffer(0) #endif , dynamicGlobalObject(0) , cachedUTCOffset(QNaN) , m_enabledProfiler(0) , m_regExpCache(new RegExpCache(this)) #if ENABLE(REGEXP_TRACING) , m_rtTraceList(new RTTraceList()) #endif #ifndef NDEBUG , exclusiveThread(0) #endif #if CPU(X86) && ENABLE(JIT) , m_timeoutCount(512) #endif , m_newStringsSinceLastHashCons(0) #if ENABLE(ASSEMBLER) , m_canUseAssembler(enableAssembler(executableAllocator)) #endif #if ENABLE(JIT) , m_canUseJIT(m_canUseAssembler && Options::useJIT()) #endif #if ENABLE(YARR_JIT) , m_canUseRegExpJIT(m_canUseAssembler && Options::useRegExpJIT()) #endif #if ENABLE(GC_VALIDATION) , m_initializingObjectClass(0) #endif , m_inDefineOwnProperty(false) , m_codeCache(CodeCache::create()) { interpreter = new Interpreter(*this); // Need to be careful to keep everything consistent here JSLockHolder lock(this); IdentifierTable* existingEntryIdentifierTable = wtfThreadData().setCurrentIdentifierTable(identifierTable); structureStructure.set(*this, Structure::createStructure(*this)); structureRareDataStructure.set(*this, StructureRareData::createStructure(*this, 0, jsNull())); debuggerActivationStructure.set(*this, DebuggerActivation::createStructure(*this, 0, jsNull())); interruptedExecutionErrorStructure.set(*this, InterruptedExecutionError::createStructure(*this, 0, jsNull())); terminatedExecutionErrorStructure.set(*this, TerminatedExecutionError::createStructure(*this, 0, jsNull())); stringStructure.set(*this, JSString::createStructure(*this, 0, jsNull())); notAnObjectStructure.set(*this, JSNotAnObject::createStructure(*this, 0, jsNull())); propertyNameIteratorStructure.set(*this, JSPropertyNameIterator::createStructure(*this, 0, jsNull())); getterSetterStructure.set(*this, GetterSetter::createStructure(*this, 0, jsNull())); apiWrapperStructure.set(*this, JSAPIValueWrapper::createStructure(*this, 0, jsNull())); JSScopeStructure.set(*this, JSScope::createStructure(*this, 0, jsNull())); executableStructure.set(*this, ExecutableBase::createStructure(*this, 0, jsNull())); nativeExecutableStructure.set(*this, NativeExecutable::createStructure(*this, 0, jsNull())); evalExecutableStructure.set(*this, EvalExecutable::createStructure(*this, 0, jsNull())); programExecutableStructure.set(*this, ProgramExecutable::createStructure(*this, 0, jsNull())); functionExecutableStructure.set(*this, FunctionExecutable::createStructure(*this, 0, jsNull())); regExpStructure.set(*this, RegExp::createStructure(*this, 0, jsNull())); sharedSymbolTableStructure.set(*this, SharedSymbolTable::createStructure(*this, 0, jsNull())); structureChainStructure.set(*this, StructureChain::createStructure(*this, 0, jsNull())); sparseArrayValueMapStructure.set(*this, SparseArrayValueMap::createStructure(*this, 0, jsNull())); withScopeStructure.set(*this, JSWithScope::createStructure(*this, 0, jsNull())); unlinkedFunctionExecutableStructure.set(*this, UnlinkedFunctionExecutable::createStructure(*this, 0, jsNull())); unlinkedProgramCodeBlockStructure.set(*this, UnlinkedProgramCodeBlock::createStructure(*this, 0, jsNull())); unlinkedEvalCodeBlockStructure.set(*this, UnlinkedEvalCodeBlock::createStructure(*this, 0, jsNull())); unlinkedFunctionCodeBlockStructure.set(*this, UnlinkedFunctionCodeBlock::createStructure(*this, 0, jsNull())); propertyTableStructure.set(*this, PropertyTable::createStructure(*this, 0, jsNull())); smallStrings.initializeCommonStrings(*this); wtfThreadData().setCurrentIdentifierTable(existingEntryIdentifierTable); #if ENABLE(JIT) jitStubs = adoptPtr(new JITThunks()); performPlatformSpecificJITAssertions(this); #endif interpreter->initialize(this->canUseJIT()); #if ENABLE(JIT) initializeHostCallReturnValue(); // This is needed to convince the linker not to drop host call return support. #endif heap.notifyIsSafeToCollect(); LLInt::Data::performAssertions(*this); if (Options::enableProfiler()) m_perBytecodeProfiler = adoptPtr(new Profiler::Database(*this)); #if ENABLE(DFG_JIT) if (canUseJIT()) m_dfgState = adoptPtr(new DFG::LongLivedState()); #endif }
PassOwnPtr<SpeechInput> SpeechInput::create(SpeechInputClient* client) { return adoptPtr(new SpeechInput(client)); }
PassOwnPtr<MediaPlayer> WebMediaPlayerClientImpl::create(MediaPlayerClient* client) { return adoptPtr(new WebMediaPlayerClientImpl(client)); }
SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector, bool woffEnabled) { // If the font hasn't loaded or an error occurred, then we've got nothing. if (!isValid()) return 0; #if ENABLE(SVG_FONTS) if (!m_font && !m_svgFontFaceElement) { #else if (!m_font) { #endif SimpleFontData* fontData = fontCache()->getCachedFontData(fontDescription, m_string); // We're local. Just return a SimpleFontData from the normal cache. return fontData; } // See if we have a mapping in our FontData cache. unsigned hashKey = (fontDescription.computedPixelSize() + 1) << 6 | fontDescription.widthVariant() << 4 | (fontDescription.textOrientation() == TextOrientationUpright ? 8 : 0) | (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0); if (SimpleFontData* cachedData = m_fontDataTable.get(hashKey)) return cachedData; OwnPtr<SimpleFontData> fontData; // If we are still loading, then we let the system pick a font. if (isLoaded()) { if (m_font) { #if ENABLE(SVG_FONTS) if (m_hasExternalSVGFont) { // For SVG fonts parse the external SVG document, and extract the <font> element. if (!m_font->ensureSVGFontData()) return 0; if (!m_externalSVGFontElement) m_externalSVGFontElement = m_font->getSVGFontById(SVGURIReference::getTarget(m_string)); if (!m_externalSVGFontElement) return 0; SVGFontFaceElement* fontFaceElement = 0; // Select first <font-face> child for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) { if (fontChild->hasTagName(SVGNames::font_faceTag)) { fontFaceElement = static_cast<SVGFontFaceElement*>(fontChild); break; } } if (fontFaceElement) { if (!m_svgFontFaceElement) { // We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement. // Use the imported <font-face> tag as referencing font-face element for these cases. m_svgFontFaceElement = fontFaceElement; } fontData.set(new SimpleFontData(adoptPtr(new SVGFontData(fontFaceElement)), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic)); } } else #endif { // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef. if (!m_font->ensureCustomFontData(woffEnabled)) return 0; fontData.set(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.orientation(), fontDescription.textOrientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false)); } } else { #if ENABLE(SVG_FONTS) // In-Document SVG Fonts if (m_svgFontFaceElement) fontData.set(new SimpleFontData(adoptPtr(new SVGFontData(m_svgFontFaceElement.get())), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic)); #endif } } else { // Kick off the load now. if (CachedResourceLoader* cachedResourceLoader = fontSelector->cachedResourceLoader()) m_font->beginLoadIfNeeded(cachedResourceLoader); // FIXME: m_string is a URL so it makes no sense to pass it as a family name. SimpleFontData* tempData = fontCache()->getCachedFontData(fontDescription, m_string); if (!tempData) tempData = fontCache()->getLastResortFallbackFont(fontDescription); fontData.set(new SimpleFontData(tempData->platformData(), true, true)); } SimpleFontData* fontDataRawPtr = fontData.leakPtr(); m_fontDataTable.set(hashKey, fontDataRawPtr); return fontDataRawPtr; } #if ENABLE(SVG_FONTS) SVGFontFaceElement* CSSFontFaceSource::svgFontFaceElement() const { return m_svgFontFaceElement.get(); } void CSSFontFaceSource::setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement> element) { m_svgFontFaceElement = element; } bool CSSFontFaceSource::isSVGFontFaceSource() const { return m_svgFontFaceElement || m_hasExternalSVGFont; } #endif }
PassOwnPtr<InputMethodContext> InputMethodContext::create(HTMLElement* element) { return adoptPtr(new InputMethodContext(element)); }
void DatabaseThread::start() { if (m_thread) return; m_thread = adoptPtr(blink::Platform::current()->createThread("WebCore: Database")); }
PassOwnPtr<MediaQueryExp> MediaQueryExp::create(const AtomicString& mediaFeature, CSSParserValueList* values) { return adoptPtr(new MediaQueryExp(mediaFeature, values)); }
PassOwnPtr<Keyframe::PropertySpecificKeyframe> AnimatableValueKeyframe::PropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const { return adoptPtr(new AnimatableValueKeyframe::PropertySpecificKeyframe(offset, easing, AnimatableValue::neutralValue(), AnimationEffect::CompositeAdd)); }
PassOwnPtr<Keyframe::PropertySpecificKeyframe> AnimatableValueKeyframe::PropertySpecificKeyframe::cloneWithOffset(double offset) const { Keyframe::PropertySpecificKeyframe* theClone = new PropertySpecificKeyframe(offset, m_easing, m_value); return adoptPtr(theClone); }
PassOwnPtr<PinchViewports> PinchViewports::create(WebViewImpl* owner) { return adoptPtr(new PinchViewports(owner)); }
PassOwnPtr<LocaleWin> LocaleWin::create(LCID lcid) { return adoptPtr(new LocaleWin(lcid)); }
void InspectorConsoleAgent::addInspectedHeapObject(ErrorString*, int inspectedHeapObjectId) { m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(new InspectableHeapObject(inspectedHeapObjectId))); }
void TestController::initialize(int argc, const char* argv[]) { platformInitialize(); bool printSupportedFeatures = false; for (int i = 1; i < argc; ++i) { std::string argument(argv[i]); if (argument == "--timeout" && i + 1 < argc) { m_longTimeout = atoi(argv[++i]); // Scale up the short timeout to match. m_shortTimeout = defaultShortTimeout * m_longTimeout / defaultLongTimeout; continue; } if (argument == "--pixel-tests") { m_dumpPixels = true; continue; } if (argument == "--verbose") { m_verbose = true; continue; } if (argument == "--gc-between-tests") { m_gcBetweenTests = true; continue; } if (argument == "--print-supported-features") { printSupportedFeatures = true; break; } // Skip any other arguments that begin with '--'. if (argument.length() >= 2 && argument[0] == '-' && argument[1] == '-') continue; m_paths.push_back(argument); } if (printSupportedFeatures) { // FIXME: On Windows, DumpRenderTree uses this to expose whether it supports 3d // transforms and accelerated compositing. When we support those features, we // should match DRT's behavior. exit(0); } m_usingServerMode = (m_paths.size() == 1 && m_paths[0] == "-"); if (m_usingServerMode) m_printSeparators = true; else m_printSeparators = m_paths.size() > 1; initializeInjectedBundlePath(); initializeTestPluginDirectory(); WKRetainPtr<WKStringRef> pageGroupIdentifier(AdoptWK, WKStringCreateWithUTF8CString("WebKitTestRunnerPageGroup")); m_pageGroup.adopt(WKPageGroupCreateWithIdentifier(pageGroupIdentifier.get())); m_context.adopt(WKContextCreateWithInjectedBundlePath(injectedBundlePath())); const char* path = libraryPathForTesting(); if (path) { Vector<char> databaseDirectory(strlen(path) + strlen("/Databases") + 1); sprintf(databaseDirectory.data(), "%s%s", path, "/Databases"); WKRetainPtr<WKStringRef> databaseDirectoryWK(AdoptWK, WKStringCreateWithUTF8CString(databaseDirectory.data())); WKContextSetDatabaseDirectory(m_context.get(), databaseDirectoryWK.get()); } platformInitializeContext(); WKContextInjectedBundleClient injectedBundleClient = { 0, this, didReceiveMessageFromInjectedBundle, didReceiveSynchronousMessageFromInjectedBundle }; WKContextSetInjectedBundleClient(m_context.get(), &injectedBundleClient); _WKContextSetAdditionalPluginsDirectory(m_context.get(), testPluginDirectory()); m_mainWebView = adoptPtr(new PlatformWebView(m_context.get(), m_pageGroup.get())); WKPageUIClient pageUIClient = { 0, this, createOtherPage, 0, // showPage 0, // close 0, // takeFocus 0, // focus 0, // unfocus 0, // runJavaScriptAlert 0, // runJavaScriptConfirm 0, // runJavaScriptPrompt 0, // setStatusText 0, // mouseDidMoveOverElement 0, // missingPluginButtonClicked 0, // didNotHandleKeyEvent 0, // toolbarsAreVisible 0, // setToolbarsAreVisible 0, // menuBarIsVisible 0, // setMenuBarIsVisible 0, // statusBarIsVisible 0, // setStatusBarIsVisible 0, // isResizable 0, // setIsResizable getWindowFrameMainPage, setWindowFrameMainPage, runBeforeUnloadConfirmPanel, 0, // didDraw 0, // pageDidScroll exceededDatabaseQuota, 0, // runOpenPanel 0, // decidePolicyForGeolocationPermissionRequest 0, // headerHeight 0, // footerHeight 0, // drawHeader 0, // drawFooter 0, // printFrame 0, // runModal 0, // didCompleteRubberBandForMainFrame 0, // saveDataToFileInDownloadsFolder 0, // shouldInterruptJavaScript }; WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient); WKPageLoaderClient pageLoaderClient = { 0, this, 0, // didStartProvisionalLoadForFrame 0, // didReceiveServerRedirectForProvisionalLoadForFrame 0, // didFailProvisionalLoadWithErrorForFrame 0, // didCommitLoadForFrame 0, // didFinishDocumentLoadForFrame didFinishLoadForFrame, 0, // didFailLoadWithErrorForFrame 0, // didSameDocumentNavigationForFrame 0, // didReceiveTitleForFrame 0, // didFirstLayoutForFrame 0, // didFirstVisuallyNonEmptyLayoutForFrame 0, // didRemoveFrameFromHierarchy 0, // didDisplayInsecureContentForFrame 0, // didRunInsecureContentForFrame 0, // canAuthenticateAgainstProtectionSpaceInFrame 0, // didReceiveAuthenticationChallengeInFrame 0, // didStartProgress 0, // didChangeProgress 0, // didFinishProgress 0, // didBecomeUnresponsive 0, // didBecomeResponsive processDidCrash, 0, // didChangeBackForwardList 0, // shouldGoToBackForwardListItem 0 // didFailToInitializePlugin }; WKPageSetPageLoaderClient(m_mainWebView->page(), &pageLoaderClient); }
PassOwnPtr<SimpleFontData::DerivedFontData> SimpleFontData::DerivedFontData::create(bool forCustomFont) { return adoptPtr(new DerivedFontData(forCustomFont)); }
PassOwnPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, InspectorCompositeState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay) { return adoptPtr(new InspectorProfilerAgent(instrumentingAgents, consoleAgent, inspectorState, injectedScriptManager, overlay)); }
static PassOwnPtr<Task> create(ImageLoader* loader, UpdateFromElementBehavior updateBehavior) { return adoptPtr(new Task(loader, updateBehavior)); }
PassOwnPtr<NetscapePlugin::Timer> NetscapePlugin::Timer::create(NetscapePlugin* netscapePlugin, unsigned timerID, unsigned interval, bool repeat, TimerFunc timerFunc) { return adoptPtr(new Timer(netscapePlugin, timerID, interval, repeat, timerFunc)); }
PassOwnPtr<LocaleICU> LocaleICU::create(const char* localeString) { return adoptPtr(new LocaleICU(localeString)); }
OwnPtr<WebGLLoseContext> WebGLLoseContext::create(WebGLRenderingContext* context) { return adoptPtr(new WebGLLoseContext(context)); }
PassOwnPtr<InjectedScriptManager> InjectedScriptManager::createForWorker() { return adoptPtr(new InjectedScriptManager(&InjectedScriptManager::canAccessInspectedWorkerContext)); }
Extensions3D* GraphicsContext3DInternal::getExtensions() { if (!m_extensions) m_extensions = adoptPtr(new Extensions3DChromium(this)); return m_extensions.get(); }
AnimationPlayerForTesting() { m_compositorPlayer = adoptPtr(CompositorFactory::current().createAnimationPlayer()); }
static PassOwnPtr<MainThreadSharedTimer> mainThreadSharedTimer() { return adoptPtr(new MainThreadSharedTimer); }
PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::createForTesting(PassOwnPtr<ImageDecoder> decoder) { return adoptPtr(new DeferredImageDecoder(decoder)); }
void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* end, int endPos, SelectionRepaintMode blockRepaintMode) { // This code makes no assumptions as to if the rendering tree is up to date or not // and will not try to update it. Currently clearSelection calls this // (intentionally) without updating the rendering tree as it doesn't care. // Other callers may want to force recalc style before calling this. // Make sure both our start and end objects are defined. // Check www.msnbc.com and try clicking around to find the case where this happened. if ((start && !end) || (end && !start)) return; // Just return if the selection hasn't changed. if (m_selectionStart == start && m_selectionStartPos == startPos && m_selectionEnd == end && m_selectionEndPos == endPos) return; // Record the old selected objects. These will be used later // when we compare against the new selected objects. int oldStartPos = m_selectionStartPos; int oldEndPos = m_selectionEndPos; // Objects each have a single selection rect to examine. typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectedObjectMap; SelectedObjectMap oldSelectedObjects; SelectedObjectMap newSelectedObjects; // Blocks contain selected objects and fill gaps between them, either on the left, right, or in between lines and blocks. // In order to get the repaint rect right, we have to examine left, middle, and right rects individually, since otherwise // the union of those rects might remain the same even when changes have occurred. typedef HashMap<RenderBlock*, OwnPtr<RenderBlockSelectionInfo> > SelectedBlockMap; SelectedBlockMap oldSelectedBlocks; SelectedBlockMap newSelectedBlocks; RenderObject* os = m_selectionStart; RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos); bool exploringBackwards = false; bool continueExploring = os && (os != stop); while (continueExploring) { if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) { // Blocks are responsible for painting line gaps and margin gaps. They must be examined as well. oldSelectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, true))); if (blockRepaintMode == RepaintNewXOROld) { RenderBlock* cb = os->containingBlock(); while (cb && !cb->isRenderView()) { OwnPtr<RenderBlockSelectionInfo>& blockInfo = oldSelectedBlocks.add(cb, nullptr).storedValue->value; if (blockInfo) break; blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb)); cb = cb->containingBlock(); } } } os = getNextOrPrevRenderObjectBasedOnDirection(os, stop, continueExploring, exploringBackwards); } // Now clear the selection. SelectedObjectMap::iterator oldObjectsEnd = oldSelectedObjects.end(); for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObjectsEnd; ++i) i->key->setSelectionStateIfNeeded(SelectionNone); // set selection start and end m_selectionStart = start; m_selectionStartPos = startPos; m_selectionEnd = end; m_selectionEndPos = endPos; // Update the selection status of all objects between m_selectionStart and m_selectionEnd if (start && start == end) start->setSelectionStateIfNeeded(SelectionBoth); else { if (start) start->setSelectionStateIfNeeded(SelectionStart); if (end) end->setSelectionStateIfNeeded(SelectionEnd); } RenderObject* o = start; stop = rendererAfterPosition(end, endPos); while (o && o != stop) { if (o != start && o != end && o->canBeSelectionLeaf()) o->setSelectionStateIfNeeded(SelectionInside); o = o->nextInPreOrder(); } if (blockRepaintMode != RepaintNothing) layer()->clearBlockSelectionGapsBounds(); // Now that the selection state has been updated for the new objects, walk them again and // put them in the new objects list. o = start; exploringBackwards = false; continueExploring = o && (o != stop); while (continueExploring) { if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionState() != SelectionNone) { newSelectedObjects.set(o, adoptPtr(new RenderSelectionInfo(o, true))); RenderBlock* cb = o->containingBlock(); while (cb && !cb->isRenderView()) { OwnPtr<RenderBlockSelectionInfo>& blockInfo = newSelectedBlocks.add(cb, nullptr).storedValue->value; if (blockInfo) break; blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb)); cb = cb->containingBlock(); } } o = getNextOrPrevRenderObjectBasedOnDirection(o, stop, continueExploring, exploringBackwards); } if (!m_frameView || blockRepaintMode == RepaintNothing) return; // Have any of the old selected objects changed compared to the new selection? for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObjectsEnd; ++i) { RenderObject* obj = i->key; RenderSelectionInfo* newInfo = newSelectedObjects.get(obj); RenderSelectionInfo* oldInfo = i->value.get(); if (!newInfo || oldInfo->rect() != newInfo->rect() || oldInfo->state() != newInfo->state() || (m_selectionStart == obj && oldStartPos != m_selectionStartPos) || (m_selectionEnd == obj && oldEndPos != m_selectionEndPos)) { oldInfo->repaint(); if (newInfo) { newInfo->repaint(); newSelectedObjects.remove(obj); } } } // Any new objects that remain were not found in the old objects dict, and so they need to be updated. SelectedObjectMap::iterator newObjectsEnd = newSelectedObjects.end(); for (SelectedObjectMap::iterator i = newSelectedObjects.begin(); i != newObjectsEnd; ++i) i->value->repaint(); // Have any of the old blocks changed? SelectedBlockMap::iterator oldBlocksEnd = oldSelectedBlocks.end(); for (SelectedBlockMap::iterator i = oldSelectedBlocks.begin(); i != oldBlocksEnd; ++i) { RenderBlock* block = i->key; RenderBlockSelectionInfo* newInfo = newSelectedBlocks.get(block); RenderBlockSelectionInfo* oldInfo = i->value.get(); if (!newInfo || oldInfo->rects() != newInfo->rects() || oldInfo->state() != newInfo->state()) { oldInfo->repaint(); if (newInfo) { newInfo->repaint(); newSelectedBlocks.remove(block); } } } // Any new blocks that remain were not found in the old blocks dict, and so they need to be updated. SelectedBlockMap::iterator newBlocksEnd = newSelectedBlocks.end(); for (SelectedBlockMap::iterator i = newSelectedBlocks.begin(); i != newBlocksEnd; ++i) i->value->repaint(); }