void wxModalEventLoop::DoRun() { wxWindowDisabler disabler(m_modalWindow); wxMacAutoreleasePool autoreleasepool; bool resetGroupParent = false; WindowGroupRef windowGroup = NULL; WindowGroupRef formerParentGroup = NULL; // make sure modal dialogs are in the right layer so that they are not covered if ( m_modalWindow != NULL ) { if ( m_modalWindow->GetParent() == NULL ) { windowGroup = GetWindowGroup(m_modalNativeWindow) ; if ( windowGroup != GetWindowGroupOfClass( kMovableModalWindowClass ) ) { formerParentGroup = GetWindowGroupParent( windowGroup ); SetWindowGroupParent( windowGroup, GetWindowGroupOfClass( kMovableModalWindowClass ) ); resetGroupParent = true; } } } m_modalWindow->SetFocus(); RunAppModalLoopForWindow(m_modalNativeWindow); if ( resetGroupParent ) { SetWindowGroupParent( windowGroup , formerParentGroup ); } }
void RenderFlowThread::repaintRectangleInRegions(const LayoutRect& repaintRect, bool immediate) { if (!shouldRepaint(repaintRect) || !hasValidRegionInfo()) return; for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) { RenderRegion* region = *iter; if (!region->isValid()) continue; // We only have to issue a repaint in this region if the region rect intersects the repaint rect. LayoutRect flippedRegionRect(region->regionRect()); LayoutRect flippedRegionOverflowRect(region->regionOverflowRect()); flipForWritingMode(flippedRegionRect); // Put the region rects into physical coordinates. flipForWritingMode(flippedRegionOverflowRect); LayoutRect clippedRect(repaintRect); clippedRect.intersect(flippedRegionOverflowRect); if (clippedRect.isEmpty()) continue; // Put the region rect into the region's physical coordinate space. clippedRect.setLocation(region->contentBoxRect().location() + (clippedRect.location() - flippedRegionRect.location())); // Now switch to the region's writing mode coordinate space and let it repaint itself. region->flipForWritingMode(clippedRect); LayoutStateDisabler layoutStateDisabler(view()); // We can't use layout state to repaint, since the region is somewhere else. // Can't use currentFlowThread as it possible to have imbricated flow threads and the wrong one could be used, // so, we let each region figure out the proper enclosing flow thread CurrentRenderFlowThreadDisabler disabler(view()); region->repaintRectangle(clippedRect, immediate); } }
void disconnectSubframes(ContainerNode& root, SubframeDisconnectPolicy policy) { #ifndef NDEBUG assertConnectedSubrameCountIsConsistent(root); #endif ASSERT(root.connectedSubframeCount()); Vector<Ref<HTMLFrameOwnerElement>> frameOwners; if (policy == RootAndDescendants) { if (is<HTMLFrameOwnerElement>(root)) frameOwners.append(downcast<HTMLFrameOwnerElement>(root)); } collectFrameOwners(frameOwners, root); // Must disable frame loading in the subtree so an unload handler cannot // insert more frames and create loaded frames in detached subtrees. SubframeLoadingDisabler disabler(root); bool isFirst = true; for (auto& owner : frameOwners) { // Don't need to traverse up the tree for the first owner since no // script could have moved it. if (isFirst || root.containsIncludingShadowDOM(&owner.get())) owner.get().disconnectContentFrame(); isFirst = false; } }
void OptionPage::DisableIfChecked(wxControl *cbx, wxControl *ctrl) { wxCheckBox *cb = dynamic_cast<wxCheckBox*>(cbx); if (!cb) return; ctrl->Enable(!cb->IsChecked()); cb->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, disabler(ctrl, false)); }
PassOwnPtr<Shape> Shape::createRasterShape(Image* image, float threshold, const LayoutRect& imageR, const LayoutRect& marginR, WritingMode writingMode, float margin) { IntRect imageRect = pixelSnappedIntRect(imageR); IntRect marginRect = pixelSnappedIntRect(marginR); OwnPtr<RasterShapeIntervals> intervals = adoptPtr(new RasterShapeIntervals(marginRect.height(), -marginRect.y())); OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageRect.size()); if (image && imageBuffer) { // FIXME: This is not totally correct but it is needed to prevent shapes // that loads SVG Images during paint invalidations to mark layoutObjects for // layout, which is not allowed. See https://crbug.com/429346 ImageObserverDisabler disabler(image); SkPaint paint; IntRect imageSourceRect(IntPoint(), image->size()); IntRect imageDestRect(IntPoint(), imageRect.size()); image->draw(imageBuffer->canvas(), paint, imageDestRect, imageSourceRect, DoNotRespectImageOrientation, Image::DoNotClampImageToSourceRect); WTF::ArrayBufferContents contents; imageBuffer->getImageData(Unmultiplied, IntRect(IntPoint(), imageRect.size()), contents); RefPtr<DOMArrayBuffer> arrayBuffer = DOMArrayBuffer::create(contents); RefPtr<DOMUint8ClampedArray> pixelArray = DOMUint8ClampedArray::create(arrayBuffer, 0, arrayBuffer->byteLength()); unsigned pixelArrayOffset = 3; // Each pixel is four bytes: RGBA. uint8_t alphaPixelThreshold = threshold * 255; ASSERT(static_cast<unsigned>(imageRect.width() * imageRect.height() * 4) == pixelArray->length()); int minBufferY = std::max(0, marginRect.y() - imageRect.y()); int maxBufferY = std::min(imageRect.height(), marginRect.maxY() - imageRect.y()); for (int y = minBufferY; y < maxBufferY; ++y) { int startX = -1; for (int x = 0; x < imageRect.width(); ++x, pixelArrayOffset += 4) { uint8_t alpha = pixelArray->item(pixelArrayOffset); bool alphaAboveThreshold = alpha > alphaPixelThreshold; if (startX == -1 && alphaAboveThreshold) { startX = x; } else if (startX != -1 && (!alphaAboveThreshold || x == imageRect.width() - 1)) { int endX = alphaAboveThreshold ? x + 1 : x; intervals->intervalAt(y + imageRect.y()).unite(IntShapeInterval(startX + imageRect.x(), endX + imageRect.x())); startX = -1; } } } } OwnPtr<RasterShape> rasterShape = adoptPtr(new RasterShape(intervals.release(), marginRect.size())); rasterShape->m_writingMode = writingMode; rasterShape->m_margin = margin; return rasterShape.release(); }
void ChildFrameDisconnector::disconnectCollectedFrameOwners() { // Must disable frame loading in the subtree so an unload handler cannot // insert more frames and create loaded frames in detached subtrees. SubframeLoadingDisabler disabler(root()); for (unsigned i = 0; i < m_frameOwners.size(); ++i) { HTMLFrameOwnerElement* owner = m_frameOwners[i].get(); // Don't need to traverse up the tree for the first owner since no // script could have moved it. if (!i || root().containsIncludingShadowDOM(owner)) owner->disconnectContentFrame(); } }
void RenderFlowThread::repaintRectangleInRegions(const LayoutRect& repaintRect, bool immediate) const { if (!shouldRepaint(repaintRect) || !hasValidRegionInfo()) return; LayoutStateDisabler layoutStateDisabler(view()); // We can't use layout state to repaint, since the regions are somewhere else. // We can't use currentFlowThread as it is possible to have interleaved flow threads and the wrong one could be used. // Let each region figure out the proper enclosing flow thread. CurrentRenderFlowThreadDisabler disabler(view()); for (RenderRegionList::const_iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) { RenderRegion* region = *iter; region->repaintFlowThreadContent(repaintRect, immediate); } }
void HTMLPlugInImageElement::attach() { PostAttachCallbackDisabler disabler(this); bool isImage = isImageType(); if (!isImage) queuePostAttachCallback(&HTMLPlugInImageElement::updateWidgetCallback, this); HTMLPlugInElement::attach(); if (isImage && renderer() && !useFallbackContent()) { if (!m_imageLoader) m_imageLoader = adoptPtr(new HTMLImageLoader(this)); m_imageLoader->updateFromElement(); } }
void RenderFlowThread::repaintRectangleInRegions(const LayoutRect& repaintRect) const { if (!shouldRepaint(repaintRect) || !hasValidRegionInfo()) return; ForceHorriblySlowRectMapping slowRectMapping(*this); // We can't use layout state to repaint, since the regions are somewhere else. // We can't use currentFlowThread as it is possible to have interleaved flow threads and the wrong one could be used. // Let each columnSet figure out the proper enclosing flow thread. CurrentRenderFlowThreadDisabler disabler(view()); for (RenderMultiColumnSetList::const_iterator iter = m_multiColumnSetList.begin(); iter != m_multiColumnSetList.end(); ++iter) { RenderMultiColumnSet* columnSet = *iter; columnSet->repaintFlowThreadContent(repaintRect); } }
void FILEFile::init() { // Open mode for file's open const char *omode = "rb"; if (OpenFlags & Open_Truncate) { if (OpenFlags & Open_Read) omode = "w+b"; else omode = "wb"; } else if (OpenFlags & Open_Create) { if (OpenFlags & Open_Read) omode = "a+b"; else omode = "ab"; } else if (OpenFlags & Open_Write) omode = "r+b"; #ifdef OVR_OS_WIN32 SysErrorModeDisabler disabler(FileName.ToCStr()); #endif #if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400) wchar_t womode[16]; wchar_t *pwFileName = (wchar_t*)OVR_ALLOC((UTF8Util::GetLength(FileName.ToCStr())+1) * sizeof(wchar_t)); UTF8Util::DecodeString(pwFileName, FileName.ToCStr()); OVR_ASSERT(strlen(omode) < sizeof(womode)/sizeof(womode[0])); UTF8Util::DecodeString(womode, omode); _wfopen_s(&fs, pwFileName, womode); OVR_FREE(pwFileName); #else fs = fopen(FileName.ToCStr(), omode); #endif if (fs) rewind (fs); Opened = (fs != NULL); // Set error code if (!Opened) ErrorCode = SFerror(); else { // If we are testing file seek correctness, pre-load the entire file so // that we can do comparison tests later. #ifdef OVR_FILE_VERIFY_SEEK_ERRORS TestPos = 0; fseek(fs, 0, SEEK_END); FileTestLength = ftell(fs); fseek(fs, 0, SEEK_SET); pFileTestBuffer = (UByte*)OVR_ALLOC(FileTestLength); if (pFileTestBuffer) { OVR_ASSERT(FileTestLength == (unsigned)Read(pFileTestBuffer, FileTestLength)); Seek(0, Seek_Set); } #endif ErrorCode = 0; } LastOp = 0; }
void medAnnIntSeedPointHelper::annotationModified( medAnnotationData* annData ) { medSeedPointAnnotationData * spad = qobject_cast<medSeedPointAnnotationData*>(annData); vtkScopedCommandDisabler disabler( d->spCbk ); ActorInfo & actorInfo(this->getActorMap()[spad]); vtkSeedWidget * seedActor2d = vtkSeedWidget::SafeDownCast(actorInfo.actor2d); vtkSeedWidget * seedActor3d = vtkSeedWidget::SafeDownCast(actorInfo.actor3d); const int numSeeds = spad->getNumberOfSeeds(); // Delete excess seeds, and add new seeds. vtkSeedRepresentation * rep2d = seedActor2d->GetSeedRepresentation(); while ( rep2d->GetNumberOfSeeds() > numSeeds ) { seedActor2d->DeleteSeed(rep2d->GetNumberOfSeeds() - 1); } while ( rep2d->GetNumberOfSeeds() < numSeeds ) { int iSeed = rep2d->GetNumberOfSeeds(); seedActor2d->CreateNewHandle()->EnabledOn(); seedActor2d->GetCurrentRenderer()->AddActor( rep2d->GetHandleRepresentation(iSeed) ); } vtkSeedRepresentation * rep3d = seedActor3d->GetSeedRepresentation(); while ( rep3d->GetNumberOfSeeds() > numSeeds ) { seedActor3d->DeleteSeed(rep3d->GetNumberOfSeeds() - 1); } while ( rep3d->GetNumberOfSeeds() < numSeeds ) { int iSeed = rep3d->GetNumberOfSeeds(); seedActor3d->CreateNewHandle()->EnabledOn(); seedActor3d->GetCurrentRenderer()->AddActor( rep3d->GetHandleRepresentation(iSeed) ); } const int selectedSeed = spad->selectedSeed(); // for ( int iSeed(0); iSeed<numSeeds; ++iSeed) { // medAbstractViewCoordinates::qtVector3dToDouble(spad->centerWorld(iSeed), p); // rep2d->GetHandleRepresentation(iSeed)->SetWorldPosition(p); // rep3d->GetHandleRepresentation(iSeed)->SetWorldPosition(p); // int isHighlighted = ( iSeed == selectedSeed ) ? 1 : 0; // rep2d->GetHandleRepresentation(iSeed)->Highlight(isHighlighted); // rep3d->GetHandleRepresentation(iSeed)->Highlight(isHighlighted); // } if ( selectedSeed >= 0 ) { seedActor2d->RestartInteraction(); seedActor3d->RestartInteraction(); } else { seedActor2d->CompleteInteraction(); seedActor3d->CompleteInteraction(); } medAbstractImageView * view = this->getView(); medVtkViewBackend* backend = static_cast<medVtkViewBackend*>(view->backend()); //this->getmseg()->currentView()->Modified(); backend->view2D->Render(); backend->view3D->Render(); return; }