Page* ChromeClientBlackBerry::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features)
{
    PageGroupLoadDeferrer deferrer(m_webPage->d->m_page, true);
    TimerBase::fireTimersInNestedEventLoop();

    int x = features.xSet ? features.x : 0;
    int y = features.ySet ? features.y : 0;
    int width = features.widthSet? features.width : -1;
    int height = features.heightSet ? features.height : -1;
    unsigned flags = 0;

    if (features.menuBarVisible)
        flags |= Olympia::WebKit::WebPageClient::FlagWindowHasMenuBar;
    if (features.statusBarVisible)
        flags |= Olympia::WebKit::WebPageClient::FlagWindowHasStatusBar;
    if (features.toolBarVisible)
        flags |= Olympia::WebKit::WebPageClient::FlagWindowHasToolBar;
    if (features.locationBarVisible)
        flags |= Olympia::WebKit::WebPageClient::FlagWindowHasLocationBar;
    if (features.scrollbarsVisible)
        flags |= Olympia::WebKit::WebPageClient::FlagWindowHasScrollBar;
    if (features.resizable)
        flags |= Olympia::WebKit::WebPageClient::FlagWindowIsResizable;
    if (features.fullscreen)
        flags |= Olympia::WebKit::WebPageClient::FlagWindowIsFullScreen;
    if (features.dialog)
        flags |= Olympia::WebKit::WebPageClient::FlagWindowIsDialog;

    Olympia::WebKit::WebPage* webPage = m_webPage->client()->createWindow(x, y, width, height, flags);
    if (!webPage)
        return 0;

    Page* newPage = webPage->d->m_page;
    if (!request.resourceRequest().isNull())
        newPage->mainFrame()->loader()->load(request.resourceRequest(), false);
    return newPage;
}
Exemple #2
0
QImage Score::createThumbnail()
      {
      LayoutMode mode = layoutMode();
      setLayoutMode(LayoutMode::PAGE);
      doLayout();

      Page* page = pages().at(0);
      QRectF fr  = page->abbox();
      qreal mag  = 256.0 / qMax(fr.width(), fr.height());
      int w      = int(fr.width() * mag);
      int h      = int(fr.height() * mag);

      QImage pm(w, h, QImage::Format_ARGB32_Premultiplied);

      int dpm = lrint(DPMM * 1000.0);
      pm.setDotsPerMeterX(dpm);
      pm.setDotsPerMeterY(dpm);
      pm.fill(0xffffffff);

      double pr = MScore::pixelRatio;
      MScore::pixelRatio = 1.0;

      QPainter p(&pm);
      p.setRenderHint(QPainter::Antialiasing, true);
      p.setRenderHint(QPainter::TextAntialiasing, true);
      p.scale(mag, mag);
      print(&p, 0);
      p.end();

      MScore::pixelRatio = pr;

      if (layoutMode() != mode) {
            setLayoutMode(mode);
            doLayout();
            }
      return pm;
      }
Exemple #3
0
Heap::Page *Heap::WorkPage(int k) // get a new workpage with empty blocks
{
	LLOG("AllocK - next work not available " << k << " empty: " << (void *)empty[k]);
	Page *page = empty[k]; // hot empty page of the same klass
	empty[k] = NULL;
	if(!page) { // try to reacquire pages freed remotely
		LLOG("AllocK - trying FreeRemote");
		SmallFreeRemote();
		if(work[k]->freelist) { // partially free page found
			LLOG("AllocK - work available after FreeRemote " << k);
			return work[k];
		}
		page = empty[k]; // hot empty page
		empty[k] = NULL;
	}
	if(!page)
		for(int i = 0; i < NKLASS; i++) // Try hot empty page of different klass
			if(empty[i]) {
				LLOG("AllocK - free page available for reformatting " << k);
				page = empty[i];
				empty[i] = NULL;
				page->Format(k); // reformat the page for the required klass
				break;
			}
	if(!page) { // Attempt to find page in global storage of free pages
		Mutex::Lock __(mutex);
		aux.SmallFreeRemoteRaw();
		if(aux.work[k]->next != aux.work[k]) { // Try page of the same klass first
			page = aux.work[k]->next;
			page->Unlink();
			LLOG("AllocK - adopting aux page " << k << " page: " << (void *)page << ", free " << (void *)page->freelist);
		}
		if(!page && aux.empty[k]) { // Try hot empty page of the same klass
			page = aux.empty[k];
			aux.empty[k] = page->next;
			LLOG("AllocK - empty aux page available of the same format " << k << " page: " << (void *)page << ", free " << (void *)page->freelist);
		}
		if(!page)
			for(int i = 0; i < NKLASS; i++) // Finally try to to find hot page of different klass
				if(aux.empty[i]) {
					page = aux.empty[i];
					aux.empty[i] = page->next;
					page->Format(k);
					LLOG("AllocK - empty aux page available for reformatting " << k << " page: " << (void *)page << ", free " << (void *)page->freelist);
					break;
				}
		if(!page) { // No free memory was found, ask system for the new page
			page = (Page *)AllocRaw4KB(Ksz(k));
			LLOG("AllocK - allocated new system page " << (void *)page << " " << k);
			page->Format(k);
		}
		page->heap = this;
	}
	page->Link(work[k]);
	ASSERT(page->klass == k);
	return page;
}
void DocumentStyleSheetCollection::updateInjectedStyleSheetCache() const
{
    if (m_injectedStyleSheetCacheValid)
        return;
    m_injectedStyleSheetCacheValid = true;
    m_injectedUserStyleSheets.clear();
    m_injectedAuthorStyleSheets.clear();

    Page* owningPage = m_document->page();
    if (!owningPage)
        return;
        
    const PageGroup& pageGroup = owningPage->group();
    const UserStyleSheetMap* sheetsMap = pageGroup.userStyleSheets();
    if (!sheetsMap)
        return;

    UserStyleSheetMap::const_iterator end = sheetsMap->end();
    for (UserStyleSheetMap::const_iterator it = sheetsMap->begin(); it != end; ++it) {
        const UserStyleSheetVector* sheets = it->value.get();
        for (unsigned i = 0; i < sheets->size(); ++i) {
            const UserStyleSheet* sheet = sheets->at(i).get();
            if (sheet->injectedFrames() == InjectInTopFrameOnly && m_document->ownerElement())
                continue;
            if (!UserContentURLPattern::matchesPatterns(m_document->url(), sheet->whitelist(), sheet->blacklist()))
                continue;
            RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cast<Document*>(m_document), sheet->url());
            bool isUserStyleSheet = sheet->level() == UserStyleUserLevel;
            if (isUserStyleSheet)
                m_injectedUserStyleSheets.append(groupSheet);
            else
                m_injectedAuthorStyleSheets.append(groupSheet);
            groupSheet->contents()->setIsUserStyleSheet(isUserStyleSheet);
            groupSheet->contents()->parseString(sheet->source());
        }
    }
}
Exemple #5
0
void File::addpage(Page &page,long pageno)
{
	int freespace = 0;

	int record_num = 0;

	if(pageno >= page_num_ ){
		for(long i = page_num_; i < pageno; ++i){
			fseek(fp_,(i+1)*page_size_ + 2*sizeof(long) - 2*sizeof(int),SEEK_SET);
			fwrite(&record_num,sizeof(int),1,fp_);
			fwrite(&freespace,sizeof(int),1,fp_);
		}
		
		page_num_ = pageno + 1;
	}

	char *bits = new (std::nothrow) char[page_size_];

	if(bits == NULL){
		fprintf(stderr,"no enough memory!\n");
		exit(-1);
	}

	memset(bits,0,page_size_);
	
	page.set_page_size(page_size_);
	page.tobinary(bits);

	fseek(fp_,0,SEEK_SET);
	fwrite(&page_num_,sizeof(long),1,fp_);
	fwrite(&page_size_,sizeof(long),1,fp_);

	fseek(fp_,pageno*page_size_+2*sizeof(long),SEEK_SET);
	fwrite(bits,sizeof(char),page_size_,fp_);
	
	delete [] bits;
}
Exemple #6
0
const Status HeapFileScan::getRandomRecord(const RID &  rid, 
					   Record & rec)
{
   // Solution Starts
    Page* page;
    Status status;

    if ((curPageNo > 0) && 
	(rid.pageNo != curPageNo))
    {
	// there is a page pinned which is not the desired page, unpin it
        status = bufMgr->unPinPage(file, curPageNo, 
		dirtyFlag);
	if (status != OK) return status;
	curPageNo = -1;
	curPage   = NULL;
    }

    if (curPageNo < 1) {        // no current page?
	// get prepared to read the desired page
	curPageNo = rid.pageNo; // extract page # from rid
	dirtyFlag = false;

	// read desired page
	status = bufMgr->readPage(file, curPageNo, 
				  curPage);
	if (status != OK) return status;
    }

    page = curPage;
    status = page->getRecord(rid, rec);
    curRec.pageNo = rid.pageNo;
    curRec.slotNo = rid.slotNo;

    return status;
   // Solution Ends
}
Exemple #7
0
const Vector<RefPtr<CSSStyleSheet> >* DocumentStyleSheetCollection::pageGroupUserSheets() const
{
    if (m_pageGroupUserSheetCacheValid)
        return m_pageGroupUserSheets.get();
    
    m_pageGroupUserSheetCacheValid = true;
    
    Page* owningPage = m_document->page();
    if (!owningPage)
        return 0;
        
    const PageGroup& pageGroup = owningPage->group();
    const UserStyleSheetMap* sheetsMap = pageGroup.userStyleSheets();
    if (!sheetsMap)
        return 0;

    UserStyleSheetMap::const_iterator end = sheetsMap->end();
    for (UserStyleSheetMap::const_iterator it = sheetsMap->begin(); it != end; ++it) {
        const UserStyleSheetVector* sheets = it->second.get();
        for (unsigned i = 0; i < sheets->size(); ++i) {
            const UserStyleSheet* sheet = sheets->at(i).get();
            if (sheet->injectedFrames() == InjectInTopFrameOnly && m_document->ownerElement())
                continue;
            if (!UserContentURLPattern::matchesPatterns(m_document->url(), sheet->whitelist(), sheet->blacklist()))
                continue;
            RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cast<Document*>(m_document), sheet->url());
            if (!m_pageGroupUserSheets)
                m_pageGroupUserSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet> >);
            m_pageGroupUserSheets->append(groupSheet);
            groupSheet->contents()->setIsUserStyleSheet(sheet->level() == UserStyleUserLevel);
            groupSheet->contents()->parseString(sheet->source());
        }
    }

    return m_pageGroupUserSheets.get();
}
Exemple #8
0
void RenderVideo::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
    MediaPlayer* mediaPlayer = mediaElement()->player();
    bool displayingPoster = videoElement()->shouldDisplayPosterImage();

    Page* page = 0;
    if (Frame* frame = this->frame())
        page = frame->page();

    if (!displayingPoster) {
        if (!mediaPlayer) {
            if (page && paintInfo.phase == PaintPhaseForeground)
                page->addRelevantUnpaintedObject(this, visualOverflowRect());
            return;
        }
        updatePlayer();
    }

    LayoutRect rect = videoBox();
    if (rect.isEmpty()) {
        if (page && paintInfo.phase == PaintPhaseForeground)
            page->addRelevantUnpaintedObject(this, visualOverflowRect());
        return;
    }
    rect.moveBy(paintOffset);

    if (page && paintInfo.phase == PaintPhaseForeground)
        page->addRelevantRepaintedObject(this, rect);

    if (displayingPoster)
        paintIntoRect(paintInfo.context, rect);
    else if (document()->view() && document()->view()->paintBehavior() & PaintBehaviorFlattenCompositingLayers)
        mediaPlayer->paintCurrentFrameInContext(paintInfo.context, pixelSnappedIntRect(rect));
    else
        mediaPlayer->paint(paintInfo.context, pixelSnappedIntRect(rect));
}
Exemple #9
0
void Console::profileEnd(const JSC::UString& title, ScriptCallStack* callStack)
{
    Page* page = this->page();
    if (!page)
        return;

#if ENABLE(INSPECTOR)
    if (!page->inspectorController()->profilerEnabled())
        return;
#endif

    RefPtr<JSC::Profile> profile = JSC::Profiler::profiler()->stopProfiling(callStack->state(), title);
    if (!profile)
        return;

    m_profiles.append(profile);

#if ENABLE(INSPECTOR)
    if (Page* page = this->page()) {
        const ScriptCallFrame& lastCaller = callStack->at(0);
        page->inspectorController()->addProfile(profile, lastCaller.lineNumber(), lastCaller.sourceURL());
    }
#endif
}
void WindowProxy::setDOMWindow(AbstractDOMWindow* newDOMWindow)
{
    ASSERT(newDOMWindow);

    if (m_jsWindowProxies.isEmpty())
        return;

    ASSERT(m_frame);

    JSLockHolder lock(commonVM());

    for (auto& windowProxy : jsWindowProxiesAsVector()) {
        if (&windowProxy->wrapped() == newDOMWindow)
            continue;

        windowProxy->setWindow(*newDOMWindow);

        ScriptController* scriptController = nullptr;
        Page* page = nullptr;
        if (is<Frame>(*m_frame)) {
            auto& frame = downcast<Frame>(*m_frame);
            scriptController = &frame.script();
            page = frame.page();
        }

        // ScriptController's m_cacheableBindingRootObject persists between page navigations
        // so needs to know about the new JSDOMWindow.
        if (auto* cacheableBindingRootObject = scriptController ? scriptController->existingCacheableBindingRootObject() : nullptr)
            cacheableBindingRootObject->updateGlobalObject(windowProxy->window());

        windowProxy->attachDebugger(page ? page->debugger() : nullptr);
        if (page)
            windowProxy->window()->setProfileGroup(page->group().identifier());
        windowProxy->window()->setConsoleClient(page ? &page->console() : nullptr);
    }
}
Exemple #11
0
Operator::GetNextResultT ConsumeOp::getNext(unsigned short threadid)
{
	CtInt val = 0;
	dbgassert(vec.at(threadid) != NULL);
	Page* out = vec[threadid];
	GetNextResultT result;

	assertaddresslocal(&val);

	const int tupw = nextOp->getOutSchema().getTupleSize();

	do {
		result = nextOp->getNext(threadid);
		dbgassert(result.first != Error);

		Page* in = result.second;
		Page::Iterator it = in->createIterator();

		void* tuple;
		while ( (tuple = it.next()) ) 
		{
			CtInt* casttuple = (CtInt*) tuple;
			for (int i=0; i<(tupw/4); ++i)
			{
				val ^= casttuple[i];
			}
		}
	} while(result.first == Operator::Ready);

	assertaddresslocal(&val);

	void* dest = out->allocateTuple();
	schema.writeData(dest, 0, &val);

	return make_pair(Finished, out);
}
Exemple #12
0
void Console::timeEnd(ExecState* exec, const ArgList& args)
{
    UString title;
    if (args.size() >= 1)
        title = valueToStringWithUndefinedOrNullCheck(exec, args.at(exec, 0));
    if (title.isNull())
        return;

    Page* page = this->page();
    if (!page)
        return;

    double elapsed;
    if (!page->inspectorController()->stopTiming(title, elapsed))
        return;

    String message = String(title) + String::format(": %.0fms", elapsed);

    KURL url;
    unsigned lineNumber;
    retrieveLastCaller(exec, url, lineNumber);

    page->inspectorController()->addMessageToConsole(JSMessageSource, LogMessageLevel, message, lineNumber, url.string());
}
Exemple #13
0
bool Shelfscreen::readBook(QString book)
{
    for (int loopc=0; loopc<elements.size(); loopc++)
    {
        ShelfElement & se = elements[loopc];
        if(se.book->getFullName() == book)
        {
            se.book->open();
            settings->setCurrentBook(se.book->getFullName());
            settings->setCurrentPage(0);
            BookDevice * bd = new BookDevice(se.book);
            bd->open(QIODevice::ReadOnly);
            Parser * parser = new Parser(bd, se.book);
            Page * page = new Page(se.book, parser);
            top_level->addWidget(page);
            page->setPage(0);
            top_level->setCurrentWidget(page);
            current_page = page;
            return true;
        }
    }
    
    return false;  
}
Exemple #14
0
int File::getpage(Page &page,long  pageno)
{
	if(pageno >= page_num_){
		fprintf(stderr,"you tried to read past the end of the file\n");
		return -1;
	}

	char *bits = new (std::nothrow) char[page_size_];

	if(bits == NULL){
		fprintf(stderr,"no enough memory!\n");
		exit(-1);
	}

	fseek(fp_,pageno*page_size_+2*sizeof(long),SEEK_SET);
	fread(bits,sizeof(char),page_size_,fp_);
	
	page.set_page_size(page_size_);

	page.frombinary(bits);
	
	delete [] bits;
	return 0;
}
Exemple #15
0
void Console::addMessage(MessageType type, MessageLevel level, PassRefPtr<ScriptArguments> prpArguments,  PassRefPtr<ScriptCallStack> prpCallStack, bool acceptNoArguments)
{
    RefPtr<ScriptArguments> arguments = prpArguments;
    RefPtr<ScriptCallStack> callStack = prpCallStack;

    Page* page = this->page();
    if (!page)
        return;

    const ScriptCallFrame& lastCaller = callStack->at(0);

    if (!acceptNoArguments && !arguments->argumentCount())
        return;

    if (Console::shouldPrintExceptions()) {
        printSourceURLAndLine(lastCaller.sourceURL(), 0);
        printMessageSourceAndLevelPrefix(JSMessageSource, level);

        for (unsigned i = 0; i < arguments->argumentCount(); ++i) {
            String argAsString;
            if (arguments->argumentAt(i).getString(arguments->globalState(), argAsString))
                printf(" %s", argAsString.utf8().data());
        }
        printf("\n");
    }

    String message;
    for (unsigned i = 0; i < arguments->argumentCount(); ++i) {
        message.append(arguments->argumentAt(i).toString(arguments->globalState()));
        if (i < arguments->argumentCount() - 1)
            message.append(' ');
    }
    page->chrome()->client()->addMessageToConsole(JSMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL(), prpCallStack);

    InspectorInstrumentation::addMessageToConsole(page, JSMessageSource, type, level, message, arguments, callStack);
}
Exemple #16
0
void HistoryController::updateBackForwardListClippedAtTarget(bool doClip)
{
    // In the case of saving state about a page with frames, we store a tree of items that mirrors the frame tree.  
    // The item that was the target of the user's navigation is designated as the "targetItem".  
    // When this function is called with doClip=true we're able to create the whole tree except for the target's children, 
    // which will be loaded in the future. That part of the tree will be filled out as the child loads are committed.

    Page* page = m_frame->page();
    if (!page)
        return;

    if (m_frame->loader()->documentLoader()->urlForHistory().isEmpty())
        return;

    Frame* mainFrame = page->mainFrame();
    ASSERT(mainFrame);
    FrameLoader* frameLoader = mainFrame->loader();

    frameLoader->checkDidPerformFirstNavigation();

    RefPtr<HistoryItem> topItem = frameLoader->history()->createItemTree(m_frame, doClip);
    LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", topItem.get(), m_frame->loader()->documentLoader()->url().string().ascii().data());
    page->backForward()->addItem(topItem.release());
}
// Main funnel for navigating to a previous location (back/forward, non-search snap-back)
// This includes recursion to handle loading into framesets properly
void HistoryController::goToItem(HistoryItem* targetItem, FrameLoadType type)
{
    ASSERT(!m_frame->tree()->parent());
    
    // shouldGoToHistoryItem is a private delegate method. This is needed to fix:
    // <rdar://problem/3951283> can view pages from the back/forward cache that should be disallowed by Parental Controls
    // Ultimately, history item navigations should go through the policy delegate. That's covered in:
    // <rdar://problem/3979539> back/forward cache navigations should consult policy delegate
    Page* page = m_frame->page();
    if (!page)
        return;
    if (!m_frame->loader()->client()->shouldGoToHistoryItem(targetItem))
        return;

    // Set the BF cursor before commit, which lets the user quickly click back/forward again.
    // - plus, it only makes sense for the top level of the operation through the frametree,
    // as opposed to happening for some/one of the page commits that might happen soon
    BackForwardList* bfList = page->backForwardList();
    HistoryItem* currentItem = bfList->currentItem();    
    bfList->goToItem(targetItem);
    Settings* settings = m_frame->settings();
    page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : targetItem);
    recursiveGoToItem(targetItem, currentItem, type);
}
Exemple #18
0
String Console::lastWMLErrorMessage() const
{
#if ENABLE(INSPECTOR)
    Page* page = this->page();
    if (!page)
        return String();

    const Vector<ConsoleMessage*>& consoleMessages = page->inspectorController()->consoleMessages();
    if (consoleMessages.isEmpty())
        return String();

    Vector<ConsoleMessage*>::const_iterator it = consoleMessages.begin();
    const Vector<ConsoleMessage*>::const_iterator end = consoleMessages.end();

    for (; it != end; ++it) {
        ConsoleMessage* message = *it;
        if (message->source() != WMLMessageSource)
            continue;

        return message->message();
    }
#endif
    return String();
}
Exemple #19
0
void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, const String& url, unsigned lineNumber, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier)
{
    if (muteCount && source != ConsoleAPIMessageSource)
        return;

    Page* page = this->page();
    if (!page)
        return;

    page->chrome()->client()->addMessageToConsole(source, type, level, message, lineNumber, url);

    if (callStack)
        InspectorInstrumentation::addMessageToConsole(page, source, type, level, message, callStack, requestIdentifier);
    else
        InspectorInstrumentation::addMessageToConsole(page, source, type, level, message, url, lineNumber, requestIdentifier);

    if (!Console::shouldPrintExceptions())
        return;

    printSourceURLAndLine(url, lineNumber);
    printMessageSourceAndLevelPrefix(source, level);

    printf(" %s\n", message.utf8().data());
}
Exemple #20
0
bool Geolocation::startUpdating(GeoNotifier* notifier)
{
#if ENABLE(CLIENT_BASED_GEOLOCATION)
    // FIXME: Pass options to client.

    if (!isAllowed()) {
        m_startRequestPermissionNotifier = notifier;
        requestPermission();
        return true;
    }
    
    if (!m_frame)
        return false;

    Page* page = m_frame->page();
    if (!page)
        return false;

    page->geolocationController()->addObserver(this);
    return true;
#else
    return m_service->startUpdating(notifier->m_options.get());
#endif
}
PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf)
{
    const HashSet<Page*>& pages = page->group().pages();

    HashSet<Page*>::const_iterator end = pages.end();
    for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
        Page* otherPage = *it;
        if ((deferSelf || otherPage != page)) {
            if (!otherPage->defersLoading()) {
                m_deferredFrames.append(otherPage->mainFrame());

                // This code is not logically part of load deferring, but we do not want JS code executed beneath modal
                // windows or sheets, which is exactly when PageGroupLoadDeferrer is used.
                for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext())
                    frame->document()->suspendScheduledTasks(ActiveDOMObject::WillDeferLoading);
            }
        }
    }

    size_t count = m_deferredFrames.size();
    for (size_t i = 0; i < count; ++i)
        if (Page* page = m_deferredFrames[i]->page())
            page->setDefersLoading(true);
}
Exemple #22
0
  void defaultPivotTest() {
    ham_key_t key = {};
    ham_record_t rec = {};

    char buffer[80] = {0};
    for (int i = 11; i >= 0; i--) {
      *(int *)&buffer[0] = i;
      key.data = &buffer[0];
      key.size = sizeof(buffer);

      REQUIRE(0 == ham_db_insert(m_db, 0, &key, &rec, 0));
    }

    /* now verify that the index has 3 pages - root and two pages in
     * level 1 - both are 50% full
     *
     * the first page is the old root page, which became an index
     * page after the split
     */
    Page *page;
    PBtreeNode *node;
    REQUIRE((page = fetch_page(m_environ->get_page_size() * 1)));
    REQUIRE((Page::kTypeBindex & page->get_type()));
    node = PBtreeNode::from_page(page);
    REQUIRE(7 == node->get_count());

    REQUIRE((page = fetch_page(m_environ->get_page_size() * 2)));
    REQUIRE((Page::kTypeBindex & page->get_type()));
    node = PBtreeNode::from_page(page);
    REQUIRE(5 == node->get_count());

    REQUIRE((page = fetch_page(m_environ->get_page_size() * 3)));
    REQUIRE((Page::kTypeBindex & page->get_type()));
    node = PBtreeNode::from_page(page);
    REQUIRE(1 == node->get_count());
  }
Exemple #23
0
void checkPageAlloc()
{
    cerr << fmtTitle("alloc", '.') << endl;

    typedef BlockPage<Policy> Page;

    Page* page = createPage<Policy>();
    auto& log = Page::log;

    array<void*, Page::NumBlocks> blocks;

    for (size_t i = 0; i < Page::NumBlocks; ++i) {
        locklessCheck(page->hasFreeBlock(), log);

        void* block = page->alloc();
        fillBlock<Policy>(block, i);

        page->free(blocks[i] = block);

        if (!i) {
            locklessCheckEq(
                    uintptr_t(page) + (Page::MetadataBlocks * Policy::BlockSize),
                    uintptr_t(blocks[0]),
                    log);
        }
        else {
            locklessCheckGt(blocks[i], page, log);
            locklessCheckLe(
                    uintptr_t(blocks[i]) + Policy::BlockSize,
                    uintptr_t(page) + Policy::PageSize,
                    log);

            locklessCheckEq(
                    uintptr_t(blocks[i-1]) + Policy::BlockSize,
                    uintptr_t(blocks[i]),
                    log);
        }

        locklessCheckEq(page, Page::pageForBlock(blocks[i]), log);
    }

    for (size_t iteration = 0; iteration < 2; ++iteration) {
        for (size_t i = 0; i < Page::NumBlocks; ++i)
            locklessCheckEq(blocks[i], page->alloc(), log);

        for (size_t i = 0; i < Page::NumBlocks; ++i)
            page->free(blocks[i]);
    }

    locklessCheck(page->kill(), log);
}
Exemple #24
0
bool BarProp::visible() const
{
    if (!m_frame)
        return false;
    Page* page = m_frame->page();
    if (!page)
        return false;

    switch (m_type) {
    case Locationbar:
    case Personalbar:
    case Toolbar:
        return page->chrome().toolbarsVisible();
    case Menubar:
        return page->chrome().menubarVisible();
    case Scrollbars:
        return page->chrome().scrollbarsVisible();
    case Statusbar:
        return page->chrome().statusbarVisible();
    }

    ASSERT_NOT_REACHED();
    return false;
}
Exemple #25
0
void Page::updatePage(Page &newPage){

    webpageP->mainFrame()->setHtml(newPage.getHtml()); // This takes 50 ms!
    int prevs = mDOMNodes.size(); //temp
    mDOMNodes.clear();//We migth need to wait here?
    setDOMNodes(webpageP->mainFrame()->documentElement());
    //Now all the DOMNodes are updated to the new one
    mBentoTree->mHeight=newPage.mBentoTree->mHeight;
    mBentoTree->mNumNodes=newPage.mBentoTree->mNumNodes;
    mColor=newPage.mColor;
    mPageID=newPage.mPageID;
    mURL=newPage.mURL;
    ComputedStyleList=newPage.ComputedStyleList;
    copyPage(mBentoTree->mRootBlock,newPage.mBentoTree->mRootBlock);

}
void CachedPage::restore(Page& page)
{
    ASSERT(m_cachedMainFrame);
    ASSERT(m_cachedMainFrame->view()->frame().isMainFrame());
    ASSERT(!page.subframeCount());

    m_cachedMainFrame->open();
    
    // Restore the focus appearance for the focused element.
    // FIXME: Right now we don't support pages w/ frames in the b/f cache.  This may need to be tweaked when we add support for that.
    Document* focusedDocument = page.focusController().focusedOrMainFrame().document();
    if (Element* element = focusedDocument->focusedElement()) {
#if PLATFORM(IOS)
        // We don't want focused nodes changing scroll position when restoring from the cache
        // as it can cause ugly jumps before we manage to restore the cached position.
        page.mainFrame().selection().suppressScrolling();
#endif
        element->updateFocusAppearance(true);
#if PLATFORM(IOS)
        page.mainFrame().selection().restoreScrolling();
#endif
    }

    if (m_needStyleRecalcForVisitedLinks) {
        for (Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext())
            frame->document()->visitedLinkState().invalidateStyleForAllLinks();
    }

#if USE(ACCELERATED_COMPOSITING)
    if (m_needsDeviceScaleChanged) {
        page.mainFrame().deviceOrPageScaleFactorChanged();
    }
#endif

    if (m_needsFullStyleRecalc)
        page.setNeedsRecalcStyleInAllFrames();

#if ENABLE(VIDEO_TRACK)
    if (m_needsCaptionPreferencesChanged)
        page.captionPreferencesChanged();
#endif

    clear();
}
Exemple #27
0
TEST(Page, GetByteAtOffset) {
  stringstream input_stream;
  input_stream << '\0' << '1' << '\n' << ' ';

  Page* page = Page::read_from_input(input_stream);

  ASSERT_EQ(4, page->size());
  EXPECT_EQ('\0', page->get_byte_at_offset(0));
  EXPECT_EQ('1', page->get_byte_at_offset(1));
  EXPECT_EQ('\n', page->get_byte_at_offset(2));
  EXPECT_EQ(' ', page->get_byte_at_offset(3));
}
Exemple #28
0
void pagesManager::megrePagesToFile( int begin, int end, FILE* tempFptr ) {
    //get last Page for output
    Page *lastPage = &pages[ end + 1 ];
    lastPage->clearPage();
    
    //keep track of pages
    int *offsets = new int[end - begin + 1];
    memset( offsets, 0, ( end - begin + 1 ) * 4 );

    while ( true ) {       //when the pages have not been read
        int min = -1;    //find the minimize of the first entry of pages
        bool first = true;
        
        for ( int i = begin ; i <= end; i++ ) {
            //printPage( pages[i].getData() );
            if ( offsets[ i - begin ] < pages[i].getOffset() ) {   //if this page is not been read at end

                if ( first ) {                  //init the min
                    first = false;
                    min = i;
                } else if( compare( pages[i].getData() + offsets[i-begin],
                                   pages[min].getData() + offsets[min-begin] ) < 0 ) {
                    min = i;
                }
            }
        }   //for loop end, min save the value of the pageIndex of min

        while ( !lastPage->insertDataToPage( pages[min].getData() + offsets[min-begin], 8 ) ) {  //insert the min value to the output page
            //if insert fail
            //write page to file
            lastPage->writePageToFile( tempFptr );
            lastPage->clearPage();
        }
        offsets[ min - begin ] += 8;    //next entry
        
        //exam if all pages has been read
        int i;
        for ( i = begin ; i <= end; i++ ) {
            if ( offsets[ i - begin ] < pages[i].getOffset() ) {   //if a page is not at the end
                break;
            }
        }
        
        if ( i == end + 1 ) {     //if all pages has been read, break the loop
            break;
        }
    }
    //write remain page
    lastPage->writePageToFile( tempFptr );
    
    clearPages( begin, end + 1 );
}
Exemple #29
0
void test12() {
  PageId firstPageID = 1;
  const bool notDirty = 0;
  const bool isDirty = 1;
  Page *testPage; 

  // Test unPinPage sets dirty bit to true
  bufMgr->readPage(file1ptr, firstPageID, testPage);
  sprintf((char*)tmpbuf, "Testing unPinPage");
  const RecordId& rid = testPage->insertRecord(tmpbuf);
  bufMgr->unPinPage(file1ptr, firstPageID, isDirty);
  bufMgr->flushFile(file1ptr);
  
  bufMgr->readPage(file1ptr, firstPageID, testPage);
  if(strncmp(testPage->getRecord(rid).c_str(), tmpbuf , strlen(tmpbuf)) != 0)
    {
       PRINT_ERROR("ERROR :: UnPinPage did not set dirty bit correctly");
    }
  testPage->deleteRecord(rid);
  bufMgr->unPinPage(file1ptr, firstPageID, notDirty);
  
  // Test unPinPage does not set dirty bit to false
  bufMgr->readPage(file1ptr, firstPageID, testPage);
  sprintf((char*)tmpbuf, "Testing unPinPage");
  const RecordId& rid2 = testPage->insertRecord(tmpbuf); // rid2 == rid since we're the only users?
  bufMgr->unPinPage(file1ptr, firstPageID, isDirty);
  bufMgr->readPage(file1ptr, firstPageID, testPage);
  bufMgr->unPinPage(file1ptr, firstPageID, notDirty);
  bufMgr->flushFile(file1ptr);
  
  bufMgr->readPage(file1ptr, firstPageID, testPage);
  if(strncmp(testPage->getRecord(rid2).c_str(), tmpbuf , strlen(tmpbuf)) != 0)
    {
       PRINT_ERROR("ERROR :: UnPinPage did not set dirty bit correctly");
    }
  testPage->deleteRecord(rid2);
  bufMgr->unPinPage(file1ptr, firstPageID, notDirty);

  // Flush file to attain guaranteed post test state.
  bufMgr->flushFile(file1ptr);

  std::cout << "Test 12 passed" << "\n";
}
Exemple #30
0
void parseMaxTextFiles( Page& page, const Sequence<String>& fileLocations )
{
	IPIterator<String>* it = fileLocations.positions();
	while ( it->hasNext() )
	{
		IPosition<String>* p = it->next();
		{
			const String& location = p->getElement();
			const char* _location = location.getChars();
			File file( _location );
//			const char* _absolute = file.getPath().getAbsolute().getChars();
			if ( file.exists() )
			{
				FileInputStream   in( file );
				page.parse( in );
			}
		}
		delete p;
	}
	delete it;
}